Stop Wasting CDs; Install Linux Straight from an ISO

GNU/Linux comes in many different flavours, apart from the fact that each individual distro has a new release almost every six months, if not less. I have a habit of trying out every new version the moment it comes out, and I’m sure many of you do too.

Now, let’s assume you have downloaded a new version of a distro and are in the mood to try it out right away. It’s past midnight and you realise that you’ve run out of blank CDs/DVDs. So you will have to wait till the morning when the shops open, to be able to burn the distro image in order to install it. I’m sure a lot of us often face this problem. In this article I’ll share a simple trick by which you can install the new distro without burning it to a CD/DVD. The only requirement is that you should have a pre-installed GNU/Linux system—which you already have, I assume.

All Linux installers use two files to boot a computer: a kernel and an initial root filesystem—also known as the RAM disk or initrd image. This initrd image contains a set of executables and drivers that are needed to mount the real root filesystem. When the real root filesystem mounts, the initrd is unmounted and its memory is freed. These two files are named differently in different distros—refer to the following table for their names.

Distro Kernel path RAM disk path
Fedora /isolinux/vmlinuz /isolinux/initrd.img
RHEL5/CentOS5 /isolinux/vmlinuz /isolinux/initrd.img
openSUSE /boot/i386/loader/linux /boot/i386/loader/initrd
Mandriva /i586/isolinux/alt0/vmlinuz /i586/isolinux/alt0/all.rdz
Ubuntu /casper/vmlinuz /casper/initrd.gz
Debian /install.386/vmlinuz /isolinux/initrd.img

The first thing you need to do is place the ISO image(s) inside a directory. Some installers are not able to read the ISO images if they are placed inside a directory. So, just to be on the safe side, place them in the root of the file system. The partition on the hard disk holding the ISO files must be formatted with the ext2, ext3 or vfat files system.

In our example, let’s go ahead and do it with an old Fedora 9 ISO image. Follow these steps to begin with:

# mkdir /fedora
# cp /home/sandeep/Fedora-9-i386-DVD.iso /fedora/fedora9.iso

Now extract the kernel and initrd files from the ISO image and place them in the same directory in which you placed the ISO. You can use File Roller, the archive manager for GNOME, to extract the files. Just right click on the ISO and select “Open with File Roller”. It displays the contents of the ISO image. Then navigate to the isolinux directory—in Fedora 9 these two files are placed inside the isolinux directory; it’s often different for other distros, so please refer to Table 1 for the paths. Select the kernel and initrd files, and extract them to the location where your ISO image exists.

The second method is to mount the ISO image and extract the files. Run the following commands to do this:

# mount -o loop /fedora/fedora9.iso /media/iso
# cd /media/iso/isolinux
# cp vmlinuz initrd.img /fedora/

I have mounted the ISO image without providing the -t iso9660 option (to specify the type of media as an ISO filesystem). It worked for me. If the above mount command doesn’t work, do add this option along with the rest of the mount command above.

Note: Fedora 10 has introduced a change in the Anaconda installer. So, in addition to the vmlinuz and initrd.gz files, you will also need to copy the images/install.img file, create a directory called /fedora/images, and place the install.img file there.

Now, it’s time to edit the /boot/grub/menu.lst file on the system I’m currently using—Ubuntu 8.10. Note that this is the location of the Grub menu in almost all distros, except for Fedora/Red Hat, where it’s called /boot/grub/grub.conf. Append the following entry there:

title Install Linux
root (hdX,Y)
kernel /distro/Linux_kernel
initrd /distro/Ram_disk

In this case…

  1. ‘title’ is the name you want to display in your GRUB menu
  2. ‘root’ is the hard disk partition that contains the ISO image
  3. ‘kernel’ is the Linux kernel
  4. ‘initrd’ is the initial RAM disk image

Likewise, the menu.lst entry for the ISO file looks like what’s shown below:

title Install Fedora 9
root (hd4,0)
kernel /fedora/vmlinuz
initrd /fedora/initrd.img

Now you are ready to install your new Linux distro directly from the hard disk without the need for a CD/DVD drive. Reboot your system and select the ‘Install Fedora 9’ entry from your GRUB menu.

Figure 1 shows what the GRUB menu looks like after rebooting my system.

Figure 1: The "Install Fedora 9" GRUB entry

Figure 1: The "Install Fedora 9" GRUB entry

Obviously, I selected the ‘Install Fedora 9’ entry and it has started booting my system with the help of vmlinuz and initrd.img files. The set-up prompts me to choose a language and keyboard layout. Then it prompts me to select the ‘Installation Method’ as shown in Figure 2.

Figure 2: Select "Hard drive" for "Installation Method"

Figure 2: Select "Hard drive" for "Installation Method"

In this screen you need to select the ‘Hard drive’ option and proceed to the next screen. Here, you have to select the appropriate partition and the directory where the installation image exists. In my system, the installation image exists in the /fedora directory of /dev/sda5 partition. This is shown in Figure 3.

Figure 3: Select the partition and the sub-directory where the ISO image resides

Figure 3: Select the partition and the sub-directory where the ISO image resides

After this, it picks up the Anaconda installer of Fedora 9 (or any other installer, as in your case) from the prescribed location, and proceeds with the regular installation procedure just like you’d get if you were installing from a bootable optical media. Follow the steps as you would to install the distro. Figure 4 shows the package installation in action. After that’s done, reboot and you’ll be able to use your newly installed operating system.

Figure 4: Fedora 9 installation in progress

Figure 4: Fedora 9 installation in progress

Easy enough, right? So, I hope you’ll start using this simple trick to install the newly released GNU/Linux distros and stop worrying about whether you have the required blank optical media. And the additional environmental benefit is less use of non-biodegradable plastic materials (which is what a CD/DVD is made out of).

  • sriram

    excellent tip.

  • tonylijo

    i am trying to install debian lenny through grub but i am unable to load the iso image in booting plese help me

  • http://www.facebook.com/abhishekoza Abhishek Oza

    Hi Sandeep,
    Thanks for the great tutorial. But I have a question..
    I am a newbie to linux .While installing my distro if I want to format my whole hard-drive , is there any way I can install the distro from a USB stick..

  • http://www.facebook.com/abhishekoza Abhishek Oza

    Hi Sandeep,
    Thanks for the great tutorial. But I have a question..
    I am a newbie to linux .While installing my distro if I want to format my whole hard-drive , is there any way I can install the distro from a USB stick..

  • dgmahesh

    Really an echo friendly idea….!!
    I've been wasting lot of CDs and DVDs all these days….

  • dgmahesh

    Really an echo friendly idea….!!
    I've been wasting lot of CDs and DVDs all these days….

  • http://www.xtenders.blogspot.com/ Aneesh

    Use virtual box or others and take screen shots than just photographing.

  • ershadk

    This is very useful, Thank you very much.

  • babumathew

    Is there any other way, if i don't have a CD/DVD and other linux distros are not installed.. ?

  • http://www.xtenders.blogspot.com/ Aneesh

    You can use unetbootin to make a live pendrive using image and install with that.

  • lalitsingh

    I have tried all the above tips and installation also start till reading the file vmlinuz and initrd.img
    after that message comes “waiting for hardware to initialize” and after that nothing happens.
    Right now I am using RHEL 5 and wanted to go to Fedora 11. I wanted to use USB for installation. My laptop is Toshiba TECRA A1 series and pendrive i m using is Sandisk Moserbear and HP I tried all

  • Akjadoliya

    good tips kkkk

  • http://sawrub-blog.blogspot.com/ Sawrub
  • http://sawrub-blog.blogspot.com/ Sawrub
  • sandeepyadav

    Hi,

    While installing Ubuntu I made some changes to boot the ISO image.. Its a debian product, so the same trick work for Debian OS also.. try it.. mail me for further help..

    To Install Ubuntu 8.10 Live CD, you need to pass two parameters to the kernel.

    1) boot=casper where casper is a directory contains the vmlinuz and initrd.gz files.

    2) iso-scan/filename=/ubuntu/ubuntu-8.10-desktop-i386.iso

    where /ubuntu/ubuntu-8.10-desktop-i386.iso is the path to your ISO image on harddisk. We have to give this because in Live mode there is no role of harddisk while booting the OS. So Kernel will use this ISO to boot the OS in Live mode.

    For installing Ubuntu 8.10 ISO from Harddisk, enter the following statements to your grub.conf file.

    title Install Ubuntu Live CD
    root (hdX,Y)
    kernel /ubuntu/vmlinuz boot=casper iso-scan/filename=/ubuntu/ubuntu-8.10-desktop-i386.iso
    initrd /ubuntu/initrd.gz

    When you select this entry in GRUB menu, the system will boot into Live mode. From there you can install it into your harddisk.

    Thanks,
    Sandeep Kumar Yadav

  • sandeepyadav

    Hi Abhi,
    With Ubuntu Live CD you can create “USB startup Disk”. With the help of this you can boot Ubuntu Live OS from USB. The fact is that your BIOS must support USB booting.. Keep the ISO in USB which you want to install…
    Mail me if you need any help..

  • balwa

    Execellent ,
    It will help us a lot .
    Thank You

  • anuvratparashar

    I am gonna give it a try… I wouldn't have bothered but my laptop refuses to boot from ISO images that I burn, while they work fine on my desktop moreover the disks that come with LFY also work fine with my laptop.

  • bsmanyan

    Hi Sandeep,

    I tried the above procedure to install RHEL5 ( already it has got RHEL4 ) but while booting into the kernel
    it says “Error 15: File not found” and did not proceed further.

    Please tell me where is the issue

  • bsmanyan

    Hi Sandeep,

    I followed your procedure to install RHEL5 ( it already had RHEL4 ) but while trying to boot
    from the RHEL5 kernel it says
    Error 15: File not found

    Can you tell me where is the issue ??

    I have the ISO and vmlinuz & initrd.img under /rhel5 and made the grub entries as above.

  • http://kulkarnivd1989.blogspot.com vinayak kulkarni

    nice tutorial
    but one case should be noted
    debian provides linux kernel and ram-disk files seperately for booting from hdd
    so they need to be downloaded
    beyond this it works

  • http://www.mycdrive.co.cc Rusty Synate

    How shall i find out which root partition contains the iso file.

    All i can find is like hda,sda or something like that.

    What is (hd4,0) and how to detect in mine.

  • http://nofile pramod

    hi i am using ubuntu 10.04 here there is no file named menu.lst in mu /boot/grub folder

  • rupesh

    thanks sandeep!
    it is nice, working flawlessly.
    actually it is a trailer of power of linux.

  • rupesh

    i used root directory – /dev/sda1 in my case
    and give argument as
    root (hd0,0) in menu.lst file

    plz clear root (hdX,Y) for my /dev/sda2 /usr partition

  • parag

    Hi Sandeep,

    Thanks for the article. But I want to know whether the same procedure can be applied to a BSD image (like PCBSD8.0-x64-DVD.iso)? If yes I want to know what are the Kernel path & RAM Disk path?

  • Badri

    I am using Ubuntu 10.04, and there isn’t any /boot/grub/menu.lst file. I decided to search for a grub.conf file, and I found a file called grub.cfg. Is this the file I need to edit?

  • Parag

    All who tried the above procedure for Ubuntu 10.04, should know that it’s GRUB2 not the GRUB which is the default bootloader in Ubuntu 10.04 LTS. So, you have to change accordingly. For more help check the Ubuntu community page of GRUB2 (https://help.ubuntu.com/community/Grub2)

  • http://parin.isa-geek.com FOSSmaniac

    Thanks Sandeep!!
    I have tried the above method with Fedora 12 and Fedora 13, it works smooth!!

  • http://knsridhar.blogspot.com knsridhar

    sir
    when i insert ur cd it do not run as it is runs on windows why linux cds should auto run

  • Pingback: Cannot install 11.3 from USB flash drive

  • S.J.KUMAR

    It’s great. & thank u
    keep giving such good information

  • http://www.itech7.com Nilesh

    Another easy way, use a pen drive.

    dd if=ISOImage of=/dev/sdc

    You should binary write the pen drive directly, not /dev/sdc1 and the pen drive should not be mounted.

    Then boot from bios using the pen drive.

    After done with the installation, you can reparation the pen drive using cfdisk, fdisk, etc.

  • Syam.s

    Great information man ……. You rocks!!!

  • Gnanaguru

    If anyone uses ACER laptops , Surely this might be useful within six months of buying !!! .

  • http://www.opensourceforu.com Rahul

    Hi Sandeep,

    I followed your procedure to install RHEL5 ( it already had RHEL4 ) but while trying to boot
    from the RHEL5 kernel it says
    Error 15: File not found

    Can you tell me where is the issue ??

    I have the ISO and vmlinuz & initrd.img under /rhel5 and made the grub entries as above.

  • Anuvrat Parashar

    @sandeepyadav
    thanks a lot
    please get that tip about ubuntu included in the main article … worked with ubuntu 10.10 too :)

  • http://www.google.com mukesh

    Hello…
    Please help me out

    i am having a problem while installing RHEL 6 in dual boot configuration. when i select “install or upgrade an existing system” then after displaying “waiting for hardware to initialize” a black blank screen appears with an underscore blinking, instead of displaying gui or media check screen …….

    when i type something on the screen nothing happens, until i press “Crtl+C”. then it displays messages about swap and file system and at the last line it shows “preparing to reboot”..

    i’ve used same DVD in vmware, it worked fine there….
    any idea guys…
    waiting for your kind response…..

  • http://krishnababug.com Krishna

    This is what Im thinking since many days !
    Nicely written .thanks

  • Gautam

    Superb tip. Very handy for old laptops that don’t recognize USB drives and whose CD drives don’t work.

  • Pingback: Where can I find generic vmlinuz and initrd.img files?

  • Pingback: Where can I find generic vmlinuz and initrd.img files? | Coders & Admins

  • UbuntuFan

    Thanks, saved me a CD :)

  • utsav

    this trick is very interesting for everyone who are trying to test new distro of Linux.This is helpage to the professionals and home users get the most out of it.It saves not only external medium but also saves the e-wasting.Good trick nice

  • http://www.facebook.com/santosh.assisi Santosh Kumar

    Good for checking out new destro.

  • https://plus.google.com/u/0/114184704645402597895 Ratul Minhaz

    I think it should be, but still, is this applicable for the newer distros? I mean, this article was written in ’09!

  • vania

    the distro that i’ve tried to install this way (alt linux 6) wouldn’t mount the iso no matter what, so i had to give up. But i’ll keep trying the next time when i install something else.

    • Stidn

      No point, unless you’re using the old grub, as grub has been replaced with grub2 which uses a complete different layout from the old grub.

  • Awaludin Mastur

    Hi,

    I have problem this installation method, I have followed the steps in this blog, but I can’t get my linux boot properly.

    I have copied my iso linux-lite-xxxxx.iso into my root directory
    /litelinux
    and put both vmlinuz and initrd.gz on /litelinux too
    then I edit my grub.cfg

    menuentry “Install Linux Lite 2.0.32bit”{
    recordfail=1
    if [ -n ${have_grubenv} ]; then save_env recordfail;fi
    set quiet=1
    insmod ext2
    set root=(hd0,1)
    linux /litelinux/vmlinuz root=/dev/sda1 ro
    initrd /litelinux/initrd.gz
    }

    but I got busybox when I boot, please advice.

    Thanks

    Awaludin

All published articles are released under Creative Commons Attribution-NonCommercial 3.0 Unported License, unless otherwise noted.
Open Source For You is powered by WordPress, which gladly sits on top of a CentOS-based LEMP stack.

Creative Commons License.