Why installing from Linux?

If you already have ubuntu installed, you would normally upgrade to the next version by simply using the Update Manager.

If upgrading is not an option you need to use the downloaded ISO. This may be the case if your current linux is not ubuntu, or if your current ubuntu is several versions old, say, 7.10 while you want to upgrade to 11.10.

Normally you would simply burn the downloaded ISO to a CD or create a bootable USB stick. Burning an error-free CD is not completely trivial, or the PC may not have an optical drive. Then, some older PCs cannot boot from USB, which is often attributed to a "buggy BIOS".

If you also prefer not to do a network installation, then you might try to "Install from Linux".

The advantage of using an existing linux is that you can use the existing grub to boot the new kernel from the hard disk, while this new kernel can subsequently access (the rest of) the ISO from the USB device, without being obstructed by the "buggy BIOS".

The disadvantage of this method is that you need to mess a little with a grub config file. You may also find that current Ubuntu versions provide a grub-2 config file, while your older Ubuntu installation may only have (legacy) grub-1 installed. But it takes only three lines of grub commands.

Live CD

The Live CD is also known as the "Desktop Installer". It is the default Ubuntu installation CD. The ISO you downloaded has the name "desktop" in its name; these are the instructions to use. If your ISO has "alternate" in its name, you are using an alternate installation CD and should see the next section.

UNetbootin is a utility that can do much of the following automatically.

If you already have a working linux system, installing without external media is easy. You need to create a new partition, copy the CD contents over to it, boot from the new partition, and proceed as if you were installing from a CD. Note that you can't use what will be the root partition for the CD contents, as the installer is stubborn on formatting it (it will fail).

The benefits of installing without external media are that it can save you time if you are already familiar with the process, and you get a very usable system upon booting into the installer because it is running from a hard drive rather than a CD.

Step 1. Use gparted to create a new primary partition and format it to ext3. You need slightly more than 700MB of free space on it. 750MB should be sufficient. Let's say the name of the partition is /dev/sda1. If your new ubuntu install is going to coexist with your old system, you might find it convenient to create space for your new system as well at this point using gparted.

Note If you just want to replace your old linux system (especially when you already separated system files and user data into different partitions), you do not even have to create a new partition here. Just put the kernel and initrd.gz from the downloaded ISO in the existing /boot directory and put the rest on a bootable USB as described below. After booting the new Ubuntu, you may install on the existing linux partition.

Step 2. Copy CD contents over to the new partition using the command

 mkdir /tmp/install_cd
 mkdir /tmp/installer

 sudo mount disk-image.iso -o loop /tmp/install_cd
 sudo mount /dev/sda1 /tmp/installer

 sudo rsync -a /tmp/install_cd/ /tmp/installer

 sudo umount /tmp/install_cd
 sudo umount /tmp/installer

Replace the name of the ISO to whatever you downloaded and /dev/sda1 with whatever your new partition is.

Step 3. Edit your grub configuration file (typically /etc/grub.conf or /boot/grub/menu.lst) to boot from the new partition by adding the lines

title           installer
root            (hd0,0)
kernel          /casper/vmlinuz boot=casper root=/dev/ram ramdisk_size=1048576 rw
initrd          /casper/initrd.gz

The first line after the title tells grub which partition contains the installer. hd0 stands for "first hard disk," and the 0 following it standards for first partition. You will need to change this if your installer partition is different from /dev/sda1. sdaN becomes (hd0, N-1), sdbN becomes (hd1,N-1) and so on. As you can see, grub starts counting from 0, which can be confusing.

If you are trying to use Hard Disk installation with Ubuntu 9.10 chances are initrd.gz is renamed as initrd.lz now. So rename accordingly in menu.lst.

With Grub2, the bootloader in new installations of 9.10, the procedure is a little different. You should edit the file /etc/grub.d/40_custom and add the lines

menuentry "installer" {
        insmod ext2
        set root=(hd0,1)
        linux /casper/vmlinuz boot=casper root=/dev/ram1 ramdisk_size=1048576 rw
        initrd /casper/initrd.lz
}

Having done that run update-grub to rebuild the grub configuration. Note that Grub 2 counts drives from 0, but partitions from 1, so /dev/sda1 becomes (hd0,1).

Note You do not need to modify the grub config of the existing linux system, if you feel uncomfortable modifying an otherwise fine running system. Instead, you may create a new menu.lst file on the new partition, preferably in directory /boot/grub/. Then, reboot, and when the (old) grub menu appears, press 'c' to get the grub command line. Then, type: configfile (hd0,1)/boot/grub/menu.lst to switch over to your new grub menu. Tip: use the tab-key halfway typing to have grub help you complete the command, or grub commands such as search or help.

Step 4. Reboot, and choose "installer" from the grub boot menu, and continue as if you were installing from CD.

Note: if you unpacked the livecd on the same disk where you want to install Ubuntu, chances are you'll run into LP#288675, and be unable to select a partition. The workaround by Nick Spencer ("sudo umount -l -r -f /dev/sda3 or sudo umount -l -r -f /cdrom (where sda3 was the device mounted as cdrom)") is a rather terrible hack, but usable as a workaround.

Note2: Instead of using 'workaround', an alternative is to modify the file /etc/mtab by erasing the line that specifies the partition where the cdrom is mounted. This way the kernel thinks that the /cdrom is not mounted and will not show the advice when installing ubuntu. I think this procedure is less dangerous than the one in the previous note.

Note3: Instead of the above 'workarounds', you may simply use the boot option live-media=/dev/sdb1 or LIVEMEDIA=/dev/sdb1, referring to the USB device holding the ISO. This would be the "bootable usb", even if your pc has a "buggy BIOS" and cannot boot from USB. The running kernel can access the USB device. This boot option is documented in http://manpages.ubuntu.com/manpages/karmic/man7/casper7.html, but unfortunately not supported by Ubuntu 11.10. Use the patch I filed as bug fix in https://bugs.launchpad.net/ubuntu/+source/casper/+bug/423616 while this is not yet put back in the ISO. Warning: this implies building a new initrd.gz which is not very trivial, although this forum has a good manual.

Alternate CD

As of December 29th 2007, the instructions above do not apply to the alternate CD provided for Ubuntu 7.10 (Gutsy Gibbon). Significant changes are required. Procedure 1 below has been used successfully with Gutsy (Ubuntu 7.10) and Procedure 2 with Hardy (Ubuntu 8.04).

Before going any further please note that the alternate CD contains documentation which can help with fixing problems or adapting solutions to your own situation. The documentation is located in doc/install/manual/ on the alternate CD. Please refer to that documentation as needed.

Note that Procedure 2 is potentially less disruptive because it does not call for a new partition.

For a simpler installation method which generally does not require re-partitioning, and downloads the packages at install time rather than requiring an ISO, see Installation/NetbootInstallFromInternet.

Procedure 1

I used the following procedure for Gutsy. It can also be used for Hardy.

Step 1. Use gparted to create a new primary partition and format it to ext3. You need slightly more than 700MB of free space on it. 750MB should be sufficient. Let's say the name of the partition is /dev/sda1. If your new ubuntu install is going to coexist with your old system, you might find it convenient to create space for your new system as well at this point using gparted.

Step 2. Copy your alternate ISO to the root of the partition you created in step 1. You need to copy the ISO itself rather than the contents of the ISO.

Step 3. Grab the initrd.gz and vmlinuz files found in the following sub-directory of a Ubuntu mirror:

dists/gutsy/main/installer-i386/current/images/hd-media/

For example in the UK the files may be found at http://gb.archive.ubuntu.com/ubuntu/dists/gutsy/main/installer-i386/current/images/hd-media/

Put these files in your newly created partition. They can be in the root of the partition or in a sub-directory.

Step 4. Edit your grub configuration file (typically /etc/grub.conf or /boot/grub/menu.lst) to boot from the new partition by adding the lines:

title           installer
root            (hd0,0)
kernel          /install/vmlinuz root=/dev/ram ramdisk_size=1048576 rw
initrd          /install/initrd.gz

If you use LILO, see the official documentation on the alternate CD for how to configure LILO. Or you can adapt the lines above for LILO if you know Grub and LILO well.

The first line after the title tells grub which partition contains the installer. hd0 stands for "first hard disk," and the 0 following it standards for first partition. You will need to change this if your installer partition is different from /dev/sda1. sdaN becomes (hd0, N-1), sdbN becomes (hd1,N-1) and so on. As you can see, grub starts counting from 0, which can be confusing. The paths for the kernel and the initrd were set to start with /install/ in my setup but you could put those files in the root of the install partition and have them be /vmlinuz and /initrd.gz if you so wish.

As specified in the above, the installer will run without a preseed file. The preseed tells the installer what kind of system you are trying to install and it automatically selects some options for you during installation. For instance, using the ubuntu.seed file tells the installer that you want to install a full "desktop" system, with Gnome and everything. If you do not select a preseed file, it is unclear what the installer thinks. In my (LouisDominiqueDubeau) experience, it installs some sort of CLI or server form of Ubuntu. This is not disastrous but it may not be what you want. In Hardy in particular, running the installer without a seed results in LILO installed as the boot loader rather than Grub. Ugly... So it is better to select a seed. Adding the parameter file=/cdrom/preseed/ubuntu.seed to the kernel line above should take care of the problem. If installing Kubuntu, select kubuntu.seed instead. Adapt to other situations as needed.

Step 5. Reboot, and choose "installer" from the grub boot menu, and continue as normal.

Procedure 2

In this procedure you do not create a new partition to hold the installer. This procedure was used for Hardy. It may be adaptable for Gutsy.

Step 1. Copy your alternate ISO to the root of any partition that the installer can mount. You need to copy the ISO itself rather than the contents of the ISO. The important part here is that you must find a partition that the installer can mount, as it will search during the install procedure. If you use the traditional partitioning system used by DOS since ages immemorial, then any filesystem supported by Ubuntu should work. In particular ext2/ext3/ntfs/fat/vfat should all work. If you use LVM, things are trickier. As of April 26th 2008, the installer is unable to find an ISO stored on a partition managed in LVM. The installer can install Ubuntu in an LVM partition but in the stage at which it looks for the ISO it has not yet loaded the LVM modules so it cannot find the ISO if it is on an LVM partition. An enterprising person should be able to work around that problem but by default the installer won't find the ISO if it is on an LVM partition. If you have Windows installed, then the Windows partition, which normally is not managed by LVM (because I don't think Windows supports LVM), can hold the ISO.

Step 2. Grab the initrd.gz and vmlinuz files found in the following subdirectory of a Ubuntu mirror:

dists/hardy/main/installer-i386/current/images/hd-media/

For example in the UK the files may be found at http://gb.archive.ubuntu.com/ubuntu/dists/hardy/main/installer-i386/current/images/hd-media/

You will want to put these files in your normal /boot/ directory. It may be a good idea to create a subdirectory like newinstall, hardy-install, or something similar.

Step 3. Read the information at step 4 of procedure 1 above and then come back here: the information there will tell you what hd0,0 means and will inform you about seeds, etc. Edit your grub configuration file (typically /etc/grub.conf or /boot/grub/menu.lst) to boot from the new partition by adding the lines:

title installer
root (hd0,0)
kernel /boot/newinstall/vmlinuz
initrd /boot/newinstall/initrd.gz

If you want a preseed file, change the kernel line to:

kernel (hd0,0)/newinstall/vmlinuz file=/cdrom/preseed/ubuntu.seed

Note that some users report working installs with grub without seeds and/or seeds not working with this method. Adapt as needed to your situation.

Step 4. Reboot, and choose "installer" from the grub boot menu, and continue the installation as normal.

Alternate CD Alternate Method

I have a machine without a CD-ROM drive but with a network connection, and I struggled with these instructions for many days. Finally, I stumbled upon some straightforward solutions which appear to work for me.

1. Obtain Alternate CD. (This method may work for other CDs, I have not tried)

2. Mount at a temporary location, as described previously.

3. Copy vmlinuz and initrd.gz from mounted installation media to normal location on current linux root (the one to be replaced)

4. Unmount CDROM image.

5. Copy image as is to selected partition, i.e. cat "image" > /dev/hdXX

6. Configure grub or LILO as above

7. Reboot.

8. When choosing CD-ROM drive, choose manually, do not install a driver, for the device enter the partition to which you copied the image.

9. Continue installation as normal.

So far so good! I'll let you know if it breaks later :P

Without CD

You can install Ubuntu directly from Ubuntu using debootstrap. Debootstrap installs some essential packages in a directory for use with chroot. Note that the essential packages does not in itself make the system bootable. It just installs what you need to chroot to that directory and use apt-get to install other packages which make ubuntu usable.

Step 1. First check that you have debootstrap installed.

sudo apt-get install debootstrap

(NOTE: if you want to install a newer release than your current system, you normally need to install the backported debootstrap version, see: UbuntuBackports)

Step 2. Partition device and make a filesystem.

We will assume /dev/sda is the storage device for your fresh install.

Remove former partitions and create the new one.

sudo fdisk /dev/sda

WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
         switch off the mode (command 'c') and change display units to
         sectors (command 'u').

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00031196

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        2550    20482843+  83  Linux
/dev/sda2            2551       30394   223656930   8e  Linux LVM

Command (m for help): d
Partition number (1-4): 1

Command (m for help): d
Selected partition 2

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-30394, default 1): 
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-30394, default 30394): 
Using default value 30394

Command (m for help): p

Disk /dev/sda: 250.0 GB, 250000000000 bytes
255 heads, 63 sectors/track, 30394 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00031196

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1               1       30394   244139773+  83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.

Make the filesystem

sudo mkfs.ext4 /dev/sda1

Step 3. Mount that new partition.

sudo mkdir /mnt/installer
sudo mount /dev/sda1 /mnt/installer

Step 4. Download and install base system packages.

sudo debootstrap lucid /mnt/installer

Step 5. Copy files to the new install to keep your repositories

sudo cp /etc/apt/sources.list /mnt/installer/etc/apt/

Step 6. Chroot to your new install.

sudo mount --bind /dev /mnt/installer/dev
sudo mount --bind /dev/pts /mnt/installer/dev/pts
sudo mount -t proc proc /mnt/installer/proc
sudo mount -t sysfs sys /mnt/installer/sys
sudo chroot /mnt/installer

Step 7. Upgrade the new install. Install language-pack-en-base to prevent warnings about locale settings during the upgrade.

apt-get update
apt-get install language-pack-en-base
apt-get upgrade

You may have also noticed that the wrong timezone was selected when tzdata was setup. Run this to correct your timezone.

dpkg-reconfigure tzdata

If you are using Software RAID and/or LVM, you should install these packages before installing a kernel:

apt-get install mdadm lvm2

Step 8. Install Grub and Linux Kernel.

apt-get install grub-pc linux-image

Step 9. Add user and/or set root password.

To add a user and set a password for that user.

adduser <username>

You may also want to add your user to the sudo group so that user can run programs as root.

gpasswd -a <username> sudo

To set a root password:

(NOTE: You must at least set a root password if you aren't adding a user)

passwd

It should now be safe to reboot; you may want the next few things.

Step 10. If you want to access it with ssh after reboot.

Use vi or install nano to edit /etc/hostname.

Remove any text in this file and add the hostname you would like.

vi /etc/hostname

edit /etc/network/interfaces

vi /etc/network/interfaces

Add these lines to /etc/network/interfaces. This will start eth0 at boot and request an IPv4 address with dhclient.

auto eth0
iface eth0 inet dhcp

Next you need to install ssh

apt-get install openssh-server

Your computer should be safe to reboot now. If you want the Ubuntu Gnome desktop, continue with Step 11.

Step 11. Install ubuntu-desktop.

apt-get install ubuntu-desktop ubuntu-standard

ToDo:

mkswap /dev/sdbXy
edit /etc/fstab
? edit /etc/hosts
? edit default language
? edit /etc/environment
? edit /etc/default/locale
? edit autologin
? edit /etc/lightdm/lightdm.conf

Step 12. Reboot and keep those fingers crossed.

Troubleshooting

  • If you are having issues installing grub, and dpkg-reconfigure grub-pc does not give you a chance to select the device you want to install grub to, make sure you have mounted /dev in your chroot. Review step 6.


CategoryInstallation

Installation/FromLinux (last edited 2014-01-01 04:25:50 by publicface)