Installing Ubuntu (12.04 LTS 64-bit) from an ISO Image on Hard Drive

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.


HOWTO: ISO Booting with Grub 2
HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

This entry was posted in Uncategorized and tagged , , , , . Bookmark the permalink.

5 Responses to Installing Ubuntu (12.04 LTS 64-bit) from an ISO Image on Hard Drive

  1. kobra says:

    hi, your directions are looking great but are just not working out for me; i’m trying with ubunti 12.10 on a win7 32bit/win7 64bit / ubuntu triple boot getting the ubuntu install to start with grub. but i get read out of range error after the linux /casper/vmlinuz … command (this is load kernel, right?)

    full command I give is:
    linux casper/vmlinuz/ boot=casper iso-scan/filename=/path_to_iso/ubuntu-12.10. … .iso noprompt noeject toram

    im going to check on that error message

  2. Papapau says:

    Still no answer for kobra’s problem?

    Read out of range in executing commands after set root=(loop)

  3. rodke says:

    hola amigos
    intente este tutorial para formatear una dell inspirion 3458o ya que despues de instalar los controladores oficiales de la pagina de nvidea mate el grafico trate reinstalarlo instalar otros incluso pasarme al controlador nouveau y no ubu caso en fin buscando encontre este tuto y se las particiones y todo pero aun asi no arranca el grub, sabes q particiones son las necesaria para este equipo o alguna configuracion (lo ise con ubuntu 14.04 y debian 8 con xfce) bueno yo no soy muy conosedor pero a de ser algo sencillo, pero ami me a sacado canas verdes XD…

    bueno de ante mano muchas gracias y epero puedan darme alguna sugerencia pues trabajo con el pc y lo necesito. :)

    • Taro says:

      Rodke — Sorry I cannot understand Spanish… Google Translate tells me that this is probably not a SPAM from a bot, but could you try using English for a more effective response from me? Thank you.

Leave a Reply

Your email address will not be published. Required fields are marked *