Sunday, July 27, 2008

Install Ubuntu 8.04 from Hard Disk

According to Ubuntu official website, installing Ubuntu 8.04 or upgrade to Ubuntu 8.04 from older version need CD. But in fact, burning a CD is not necessary. If you have installed a distribution of Linux but have no CD writer, you can also install Ubuntu 8.04 by the ISO file. I installed it from hard disk just now and now I am going to write something about how to do it.

First, make sure that you have more than one partitions (except swap partition). For example, I have two partitions /dev/sda1 (mounted as /) and /dev/sda5 (mounted as /home). Since I planned to install Ubuntu 8.04 on /dev/sda1. I downloaded the desktop iso file from here and save it in /home, the /dev/sda5 partition. So the full path of the ISO file is: /home/ubuntu-8.04.1-desktop-i386.iso.

Second, extract /casper/vmlinuz and /casper/initrd.gz from the ISO file. Since I had installed Ubuntu 7.10, I need to execute the following commands:
cd /home
sudo mount -o loop ubuntu-8.04.1-desktop-i386.iso /media/cdrom0
sudo cp /media/cdrom/casper/vmlinuz .
sudo cp /media/cdrom/casper/initrd.gz .

Now edit the grub configuration file /boot/grub/menu.lst. Add this item:
title Install Ubuntu
root (hd0,4)
kernel /vmlinuz boot=casper iso-scan/filename=/ubuntu-8.04.1-desktop-i386.iso
initrd /initrd.gz

Note: the red text (hd0,4) means the fifth partition on the first hard disk. i.e. it means /dev/sda5. The partition number of grub is from zero, not one.

Save menu.lst and reboot your computer. You can start Ubuntu 8.04 live CD from grub and install it to your hard disk as using CD. The only thing you must care about is that you mustn't format the partition which contains the ISO file. In my installation, the ISO file is at /sda5 so I can't format it. In addition, I mounted /home onto /dev/sda5.

12 comments:

Sean said...

Thanks! This is exactly what I was looking for as a backup for a pristine custom install.

Nikesh Jauhari said...

And for fedora : http://linuxpoison.blogspot.com/2008/06/installing-fedora-from-hard-drive.html

Prakash said...

If you try to install Linux on some other harddisk's partition connected on the system ,this trick wont work.I think this needs the detection of 2 nd harddisk.

Stefan Saraev said...

Thanks, works for me, but not before "umount -l /dev/sda4"

/dev/sda4 was partition where vmlinuz, initrd and iso file are located

nick said...

Many thanks to all, this also worked for me today on reinstallation of Intrepid 8.10 on my laptop. I also needed to:
umount -l /dev/sdaX
where the iso image was before it worked.
It did not work from a fat32 partition of the same harddisk due to file permission problems.

Bob said...

Thank you very much for this tutorial. In my line of work, it's very helpful.

I put PCs together from discarded machines. I install Ubuntu on each machine using the OEM configuration. This allows the user to set up their own personal info.

This step helps eliminate the need to include a setup CD or DVD (I sometimes user a larger Ubuntu flavor like SuperOS or UltimateEdition).

Anonymous said...

Hi there, very interesting, just what I was looking for ...

> sudo cp /media/cdrom/casper/vmlinuz .
> sudo cp /media/cdrom/casper/initrd.gz .

Why do you need to copy these files and won't they mess up your base installation ?

Anonymous said...

*sigh* I tried this with the iso image was on a fat32 partition and after failing to boot the iso a few times, my FAT32 partition got trashed....I've had a little more luck with the iso on an ext4 partition.

Maria Jane said...

This is what I was looking for backup of harddisk.

javieth said...

I had a problem with my hard disc few time ago, how ever i could solve the problem and now my computer is really nice. after that i could see costa rica homes for sale and i loved too much because i always have been interested in visit this beautiful country.

Anonymous said...

great walkthrough, though for me it ends up busybox and no install.And since im really bad at linux i have noe clue what is wrong. I have mine in /usr but i cant really understand if that is the problem. Any ideas on what i can do?

Kabeer Ahmed said...

Any idea you could kindly update this installation procedure for Ubuntu 11.04? I need this procedure to update my distribution from time to time. I tried following the procedure for 11.04 but didnt get it to work due to probably changes in grub etc.