Sometimes it’s useful to be able to install Linux off an ISO image on hard drive for whatever reason. My Dell XPS 630i has had some issues when I was installing Debian off an install CD/USB, likely related to how GRUB 2 does not gracefully deals with SATA configuration particular to this machine (the install process doesn’t appear to recognize /dev/sdaX properly at some point, ending up in IO errors or kernel panic). In any case, I could solve this by installing Linux off a pre-partitioned hard drive. This time, I install Ubuntu. (I’m giving my XPS 630i away before moving back to the States!)
Here goes the procedure. I assume that I am installing Ubuntu from scratch and hard drive has been formatted.
First, I need a Linux Live media, whatever from which I can boot the computer. I burn a CD for this particular post. Go to the Ubuntu website, download an ISO image (here ubuntu-12.04-desktop-amd64.iso), and burn a Live CD.
Boot up the computer off Ubuntu Live (do not install at this point!) and prepare the disk partitions, using GParted. It would be best to create full partition scheme at this point, so during the installation I can simply format them without repartitioning. For Ubuntu, the root partition (“/”) must be at least 2.5 GB, otherwise the installer may complain. Typically, a /boot partition needs to be about 300 MB or so, but I store all my ISO files under /boot/iso, so I will use 3 GB for the partition just in case. (For an Ubuntu ISO image, 700 MB may be enough but for Linux Mint, I may need 2 GB, for example; I can also store multiple ISO images if I wish.) Here’s the partition scheme:
Filesystem Size Mounted on /dev/sda5 3G / /dev/sda6 3G /boot /dev/sda7 10G /tmp /dev/sda8 6G /var /dev/sda9 10G /usr /dev/sda10 20G /usr/local /dev/sda11 8G Linux Swap /dev/sda12 690G /home
Then on Terminal I install GRUB 2 on /dev/sda:
$ sudo mount /dev/sda5 /mnt $ sudo mkdir /mnt/boot $ sudo mount /dev/sda6 /mnt/boot $ sudo grub-install --root-directory=/mnt /dev/sda $ sudo mkdir /mnt/boot/boot-isos $ sudo cp ~/Downloads/ubuntu-12.04-desktop-amd64.iso /mnt/boot/boot-isos $ sudo umount /mnt/boot $ sudo umount /mnt
I assumed that the ISO image was already downloaded to ~/Downloads directory. Now, reboot and on the GRUB prompt, follow this to boot off the ISO image:
$ set prefix=(hd0,6)/grub $ insmod linux $ insmod loopback $ insmod iso9660 $ loopback loop (hd0,6)/boot-isos/ubuntu-12.04-desktop-amd64.iso $ set root=(loop) $ linux /casper/vmlinuz boot=casper iso-scan/filename=/boot-isos/ubuntu-12.04-desktop-amd64.iso noprompt noeject toram $ initrd /casper/initrd.lz $ boot
The machine should boot into Ubuntu Live. Once in Ubuntu, I should unmount /isodevice:
$ sudo umount -l -r -f /isodevice
Then I can simply run the installer on Ubuntu. In order to prevent the installer from stalling (see this bug report), I had to “format” all partitions except /boot. But otherwise everything should go fine.