Sandbox

DRAFT TESTING of GRUB2/ISOBoot

Introduction

Ubuntu ISOs are designed to allow booting directly from the hard drive using GRUB 2. This eliminates the need for burning a CD/DVD. It permits the user to boot and use the "Try It" feature of the Ubuntu installation CD as well as to install Ubuntu directly from an ISO on the hard drive. In addition to Ubuntu ISOs, many other Linux distributions as well as popular rescue CDs can be booted directly from an ISO file.

important.png In order to use this feature, GRUB 2 must already be installed on the system. GRUB Legacy can not use this feature.

All GRUB references on this page refer to GRUB 2 (version 1.97 or later) unless otherwise noted.

This guide will detail how to:

  • Download and store Ubuntu ISOs
  • Create a GRUB 2 menuentry for running the ISO directly from a file
  • Install Ubuntu directly from an ISO file via the GRUB 2 menu

Additionally, examples of GRUB 2 menuentries for other operating system and utility CDs are provided on the Grub2/ISOBoot/Examples page.

Downloading the ISO

Downloading

The user should decide beforehand which ISO to download. The Desktop version is available in 32-bit and 64-bit versions. The 32-bit version (-i386) will run on a 64-bit computer, but a 64-bit version (-amd64) will not run on a 32-bit computer. There are also Server versions, as well as an Alternate CD version for users having special requirements or using RAID and/or LVM.

Ubuntu CD/DVDs can be downloaded from the official Ubuntu site: Ubuntu Download page. Links to installation help and alternative download sites are accessible from that page as well.

ISO File Location

The Ubuntu default download location is normally to the user's Downloads folder, but the ISO may also appear on the Desktop or another location defined by the user. The Desktop version filename for officially released versions of Ubuntu uses the format of ubuntu-XX.XX-desktop-amd64.iso for the 64-bit version and ubuntu-XX.XX-desktop-i386.iso for the 32-bit version, with XX.XX being the release number (such as 12.04, 11.10, etc).

Storing the ISO

Once downloaded, the user must decide where to store the file. Typically, the ISO CD image is approximately 700 MB, while the DVD version is even larger. Storing it on a non-system partition should be considered if space is limited on the system (/) partition. Additionally, users making system backups might wish to exclude the folder in which the ISO is stored if the file remains on the system (/) partition.

For purposes of this guide, the ISO will be placed in the user's Downloads folder (/home/username/Downloads).

Note: Storing the ISO file in /boot is not recommended if you are using a small, separate /boot partition.

  • The ISO file may be stored on any partition accessible to GRUB 2. The partition format does not need to be ext3/4.
  • If stored on a partition with a different format than the system, the filesystem's module (ntfs, reiserfs, etc) may need to be included in the menuentry for GRUB to be able to access the file.
  • The ISO can be stored on a system (/) partition since the partition is not mounted once the ISO is booted.
  • If the system uses a separate partition for a system folder such as /home or /boot, the user must ensure to properly identify the location of the ISO in the menuentry's PATH. In such cases, since the partition is directly mounted by GRUB 2, the address would not include /home or /boot.

Exploring the ISO Contents

For troubleshooting purposes or to inspect the contents of the ISO, the user can mount the ISO and use the Ubuntu file browser. To accomplish this:

  1. Boot into your normal Linux operating system.
  2. Create a specific mount point, if desired. An existing mount point may also be used.
  3. Mount the ISO
    • Example: sudo mount -o loop /home/username/Downloads/ubuntu-desktop-amd64.iso /mnt/iso/

  4. Open a file browser to view the contents
    • sudo mkdir /mnt/iso # Optional - the ISO file can be mounted on an existing mount point if desired.
      sudo mount -o loop /<path>/<filename>.iso /mnt/iso
      gksu nautilus /mnt/iso
      sudo umount /mnt/iso # When finished inspecting the contents.

Note: Some non-Ubuntu ISOs contain an initrd image with a .gz extension rather than the .lz extension used by the latest versions of Ubuntu. If the initrd.img file cannot be found, check the location and filenames of the kernel (vmlinuz and initrd (initrd.lz) used by the distribution. In the Ubuntu ISO these files are located in the casper and /ubuntu/casper folders.

Creating the GRUB 2 Menuentry

An easy way to create a GRUB menuentry is to add it to the /etc/grub.d/40_custom file. Add the menuentry below the existing lines in the file.

  1. Open the /etc/grub.d/40_custom file as root with a text editor.
    • gksu gedit /etc/grub.d/40_custom
  2. Add the menuentry.
  3. Save the file.
  4. Update the GRUB 2 menu.
    • sudo update-grub

The following is an example GRUB menuentry for Ubuntu 12.04's 64-bit ISO, located in the user's Downloads folder of sda5.

  • menuentry "Ubuntu 12.04 ISO" {

    set isofile="ubuntu-12.04-desktop-amd64.iso"

    loopback loop (hd0,5)/home/<username>/Downloads/$isofile

    linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject

    initrd (loop)/casper/initrd.lz

    }

The menuentry constructed above is built with the following considerations.

  1. menuentry
    • The menuentry title (between the quotations) is determined by the user. Any title can be used. The line must end with {

  2. set isofile
    • Designating an 'isofile' name simplifies the creation of multiple ISO menuentries. By using this convention, the user can copy an existing ISO menuentry and, if the ISO is located in the same folder, simply change the name of the ISO file on this line and the menuentry title. No other changes are necessary.
    • The set isofile line should reflect the exact name of the ISO file

  3. loopback
    • The loopback line must reflect the actual location of the ISO file. In the example, the ISO file is stored in the user's Downloads folder.

      • X is the drive number, starting with 0; Y is the partition number, starting with 1
        • sda5 would be designated as (hd0,5); sdb1 would be (hd1,1)
      • If stored in the system's normal /boot partition on sda5: (hd0,5)/boot/$isofile
      • If stored in a separate boot partition on sda6: (hd0,6)/$isofile

      • If stored in a separate home partition on sda7: (hd0,7)/username/Downloads/$isofile

      • If stored in the /iso folder of the sdb2 data partition: (hd1,2)/iso/$isofile

  4. linux
    • This line is specific to the Ubuntu family of ISOs. Other Linux distributions and system ISOs may use different filenames, folders and switches to boot their ISOs. Check the Grub2/ISOBoot/Examples page to see if an example exists. The user can also mount the ISO and explore its contents to ensure the menuentry contains the correct filenames and paths.

  5. initrd
    • See the linux line notes. Additionally, some other systems use initrd.gz rather than initrd.lz on their ISOs.

important.png If the ISO is stored on a partition formatted differently than your main operating system, it may be necessary to load the module for the specific format before GRUB can access it. In this case, add the following line immediately after the menuentry line for the desired format (ntfs, reiserfs, etc). It should not be necessary, but if GRUB cannot read the ISO the iso9660 module can also be loaded:

  • insmod ntfs

    insmod iso9660

For more information on creating a custom menuentry, please visit Grub2/CustomMenus.

Booting the ISO

Once the menuentry has been created and GRUB 2 updated, the ISO entry will appear on the GRUB menu during boot. If the entry was created in the /etc/grub.d/40_custom file, it will appear after the Ubuntu and other OS listings on the main GRUB menu.

To boot the ISO, highlight the entry and press ENTER or F10.

Booting without a GRUB Menuentry

Although GRUB 2 must be installed and working, it is not required to have a menuentry in order to boot the ISO. Booting can be accomplished from the GRUB prompt by manually typing in each command in the menuentry example (except the menuentry title line).

  1. To access the GRUB prompt, type 'c' while the GRUB menu is displayed.
  2. Manually type each line (except the menuentry line) and press ENTER.

    • If no messages are displayed after pressing ENTER the command ran successfully.
  3. After entering the final line, type boot and ENTER.

  4. You can return to the main menu at any time by pressing ESC.

Booting via this method is not persistent. The commands need to be entered on each subsequent boot until a menuentry is created in the GRUB menu.

Installing Ubuntu from an ISO File

Installation onto your hard drive is possible from a booted ISO file. A CD/DVD is not required. An Internet connection is recommended but not required. Without a connection packages installed from the ISO will not be updated and additional packages will not be downloaded.

To Install Ubuntu from an ISO Menuentry, use the procedures previously discussed to:

  1. Download the appropriate ISO.
  2. Move it to the desired location.
  3. Create the GRUB 2 menuentry and update the GRUB configuration file.
  4. Boot the ISO from the GRUB menu.

    Note: If you have a large amount of RAM you may be able to use the toram option. This will allow the system to boot into memory and permit automatic unmounting of the isodevice during the installation. If you would like to try this option:

    • Press 'e' to edit the menuentry and add toram to the end of the menuentry's linux line:

      • linux /casper/vmlinuz boot=casper iso-scan/filename=/<ISO-name.iso> noprompt noeject toram --

    • If /isodevice can be unmounted by the installer at the prompt, the installation will continue.
    • If you have insufficient memory and start the installation, the installer will be unable to unmount /isodevice, the install will fail and the system may freeze.
    • Since edits to the menuentry are not persistent, if the toram option fails, simply reboot and use the existing menuentry without editing it.

Once booted to the Ubuntu LiveCD desktop:

  • The /isodevice must be unmounted for a successful installation. If /isodevice cannot be unmounted by the installer, the installation will fail unless the user forces its unmounting.

    If the toram option was not used or was unsuccessful, unmount /isodevice:

    1. Open a terminal and run the following command:
      • sudo umount -l -r -f /isodevice
    2. Start the installation procedure by double-clicking the "Install Ubuntu" icon.

Example ISO Menuentries - Other OSs

GRUB 2 can boot the ISOs of many Linux operating systems and rescue CDs if they were built with this capability. The filenames, locations and kernel options vary widely and it can be difficult to determine the exact commands necessary to boot these ISOs.

The Examples page contains menuentries of many popular Linux ISOs and some of the major Linux utility ISOs.

If an example of a desired ISO is not listed, the user may be able to determine the proper menuentry commands by comparing the file structure of the ISO with the menuentry commands of ISOs laid out in a similar fashion. Mounting the ISO as detailed in the Exploring_the_ISO_Contents section of this guide may help determine the proper entries.

Additionally, the user can search the Internet for menuentry examples or seek advice in forums specializing in the specific OS or utility.

Links

External Links


CategoryBootAndPartition

drs305/Sandbox (last edited 2012-07-01 16:12:40 by drs305)