Introduction
Ubuntu ISOs are designed to allow booting directly from the hard drive using GRUB 2 and eliminates the need for burning a CD/DVD. This feature permits the user to boot and use the "Try Ubuntu" 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.
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 remain on the system partition (/) if desired.
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
There are several methods the user can employ to examine the contents of the ISO file. Viewing the folders and files contained in an ISO can help determine menuentry path designations and the names assigned to system folders and files. The two most important files contained on the ISO, for building the menuentry, are the kernel and the initrd image. These files reside in the casper folder on a standard Ubuntu ISO. The kernel link is vmlinuz and the image file is initrd.img.
On other bootable Linux ISOs and utility CDs, these files may be located in other folders and may be named differently (vmlinuz0, initramfs, etc). Note that some non-Ubuntu ISOs contain an initrd image with a .gz extension rather than the .lz extension now used by Ubuntu.
Archive Manager
Archive Manager/File Roller is a GUI application which can inspect the contents of an ISO file. Archive Manager can be started in the following ways:
- In Nautilus, right click the ISO and select "Open with Archive Manager".
- Via the DASH Home button (top left of screen). Type "Archive Manager" and press ENTER.
Via terminal using file-roller or gksu file-roller
Command Line
The user can mount the ISO image via a terminal and then inspect the contents via commands or opening a file browser. To mount the ISO via the terminal:
- Boot into your normal Linux operating system.
- Create a specific mount point, if desired. An existing mount point may also be used.
- Mount the ISO
Example: sudo mount -o loop /home/username/Downloads/ubuntu-desktop-amd64.iso /mnt/iso/
- 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.
GRUB Terminal
GRUB 2's terminal operations permit exploring the contents of partitions and ISO images. The following GRUB commands may be helpful if an error message is generated after attempting to boot an ISO menuentry:
ls
Display partitions known to GRUB.
ls (hdX,Y)/
Display the contents of the / folder on /dev/sdXY
To mount an ISO via the GRUB terminal, determine the location/path of the ISO file, then:
loopback loop (hdX,Y)/<path>/<filename.iso>
Example: loopback loop (hd0,5)/my_isos/ubuntu-12.04-desktop-amd64.iso
Once mounted via the above command, the ISO can be inspected using the ls command. The ISO will be mounted on "(loop)".
ls (loop)/
ls (loop)/casper
On an Ubuntu ISO, this should display vmlinuz and initrd.img, among other files.
Creating the GRUB 2 Menuentry
There are several methods to create a GRUB 2 menuentry which will boot an Ubuntu ISO. Two options are provided below - using the grml-rescueboot package to automatically create the menuentry, or manually editing the GRUB 2 configuration scripts/files.
There is also a method to create USB [multi]boot pendrives (almost) automatically, grub-n-iso_multiboot.
grml-rescueboot
A very simple way of creating a GRUB menuentry for a bootable ISO file is to use grml-rescueboot.
The package does the following:
- Creates a /boot/grml folder.
Automatically adds menuentries to the GRUB menu for any ISO files located in the /boot/grml folder. This is accomplished whenever the update-grub command is executed.
- The created menuentry, when selected, provides submenu options on how to boot the ISO, including the "Try Ubuntu" and "Install" options.
To use the grml-rescueboot option:
Install grml-rescueboot
sudo apt-get install grml-rescueboot
Place bootable ISO files in the /boot/grml folder.
- Since this is a system folder, the operation must be conducted as "root". For example, if the ISO is located in the user's Downloads folder, the command would be:
sudo mv ~/Downloads/<filename.iso> /boot/grml/
- Since this is a system folder, the operation must be conducted as "root". For example, if the ISO is located in the user's Downloads folder, the command would be:
- Update GRUB
sudo update-grub
grub-n-iso_multiboot
A simple way to create a USB [multi]boot drive including the grub bootloader and the GRUB menuentries for Ubuntu ISO files is to use grub-n-iso_multiboot with the shell-script file mk-grub-n-iso. It does the main part of the work automatically with the help of a couple of files for the configuration of the booting system.
The shell-script is made to be easy to use, but it helps if you have some experience with terminal windows and command lines.
Make a USB pendrive that can boot (almost) all PCs
It is possible to create the pendrive in either UEFI mode or BIOS mode, and the two grub installations are simply done with two different command lines.
$ grep grub-install mk-grub-n-iso grub-install --force --removable --no-floppy --boot-directory=/mnt/target/boot --efi-directory=/mnt/target/EFI/BOOT "$2" grub-install --force --removable --no-floppy --boot-directory=/mnt/target/boot "$2"
This tool works in an Ubuntu family operating system of version 14.04 LTS or newer. (It is possible to use Ubuntu 12.04 LTS too, but it has an older version of grub, and this method works only for BIOS mode.)
64-bit versions work only in 64-bit computers. 32-bit versions work in 32-bit and 64-bit computer with BIOS, and now also with UEFI. It is possible to create 'grub-n-iso' pendrives that boot most PCs with Intel and AMD processors according to the following links,
How to Create a EFI/UEFI GRUB2 Multiboot USB drive to boot ISO images
Build your own single boot or multiboot pendrive for all PC (Intel/AMD) computers
The pendrive 'behind' the following grub menu was created with the command line
sudo ./mk-grub-n-iso multiboot /dev/sdx
using links in the directory 'grub-n-iso_multiboot' to the target iso files. The only manual tasks were to answer a few questions (one-character replies), and the use gparted to edit partitions according to guidelines by the script itself (partition sizes, file system types: fat32 and ext2).
Separate boot drive using ISO boot alias grub-n-iso from template
It is rather easy to create a separate (USB) boot drive using ISO boot alias grub-n-iso from a template. This can be used
- directly with or without persistence 'basic method', but also
- to create a multiboot drive for example as a demo drive with all Ubuntu family flavours, or
- to create an installed system, that can boot both in UEFI and BIOS mode (alias CSM alias legacy mode).
The 'basic method' is described at the following link, ../../Installation/iso2usb/isoboot
Manually editing the GRUB files
Another 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.
- Open the /etc/grub.d/40_custom file as root with a text editor.
sudo nano /etc/grub.d/40_custom
- Add the menuentry.
- Save the file.
Update the GRUB 2 menu (the file /boot/grub/grub.cfg) with update-grub
sudo update-grub
Menuentry Example
The following is an example GRUB menuentry for Ubuntu 12.04's 64-bit ISO, located in the user's Downloads folder of sda5.
Updated releases of Ubuntu 12.04 and later may designate the 64-bit kernel as vmlinuz.efi. This file is still located in the /casper folder. When creating the menuentry, use vmlinuz.efi rather than vmlinuz in the linux line for the 64-bit version.
menuentry "Ubuntu 12.04 ISO" { set isofile="/home/<username>/Downloads/ubuntu-12.04-desktop-i386.iso" # or set isofile="/<username>/Downloads/ubuntu-12.04-desktop-i386.iso" # if you use a single partition for your $HOME loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject initrd (loop)/casper/initrd.lz }
For the 64-bit version of Ubuntu 12.04 (update 2):
menuentry "Ubuntu 12.04.2 ISO" { set isofile="/home/<username>/Downloads/ubuntu-12.04.2-desktop-amd64.iso" # or set isofile="/<username>/Downloads/ubuntu-12.04.2-desktop-amd64.iso" # if you use a single partition for your $HOME loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz.efi boot=casper iso-scan/filename=$isofile noprompt noeject initrd (loop)/casper/initrd.lz }
For Ubuntu 20.04 LTS and booting with grub 2.04
Generally, when booting with '''grub 2.04''' in UEFI mode you need an extra command to remove tpm.
menuentry "Ubuntu 20.04 ISO" { set isofile="/home/<username>/Downloads/ubuntu-20.04-desktop-amd64.iso" # or set isofile="/<username>/Downloads/ubuntu-20.04-desktop-amd64.iso" # if you use a single partition for your $HOME rmmod tpm loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz boot=casper iso-scan/filename=$isofile noprompt noeject initrd (loop)/casper/initrd }
For Ubuntu 23.04 desktop ISO with the new installer (only this particular ISO file) you need a modified linux-line (cmdline): |
menuentry "Ubuntu 23.04 desktop ISO" { set isofile="/home/<username>/Downloads/ubuntu-23.04-desktop-amd64.iso" # or set isofile="/<username>/Downloads/ubuntu-23.04-desktop-amd64.iso" # if you use a single partition for your $HOME rmmod tpm loopback loop (hd0,5)$isofile linux (loop)/casper/vmlinuz boot=casper layerfs-path=minimal.standard.live.squashfs iso-scan/filename=$isofile initrd (loop)/casper/initrd }
Please notice that the old menuentries should be used for ubuntu-23.04-desktop-legacy-amd64.iso and for the Ubuntu family flavours 23.04 (Kubuntu, Lubuntu ... Xubuntu) with the old installers Ubiquity and Calamares.
Menuentry Details
The menuentry constructed above is built with the following considerations.
- menuentry
The menuentry title (between the quotations) is determined by the user. Any title can be used. The line must end with {
- set isofile
- Designating an 'isofile' variable is not required but simplifies the creation of multiple Ubuntu 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 menuentry title and the name of the ISO file on this line. No other changes are necessary.
The set isofile line should reflect the exact name of the ISO file
- 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)
(hd0,5)/boot/$isofile
Located in the system's normal /boot partition on sda5
(hd0,6)/$isofile
Located in a separate boot partition on sda6
(hd0,7)/username/Downloads/$isofile
Located in a separate home partition on sda7
(hd1,2)/iso/$isofile
Located in the /iso folder of the sdb2 data partition
- X is the drive number, starting with 0; Y is the partition number, starting with 1
- 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.
- initrd
See the linux line notes. Additionally, some other systems use initrd.gz rather than initrd.lz on their ISOs.
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.
If the menuentry was created using grml-rescueboot, once the ISO is selected from the menuentry additional options such as "Try Me" or "Install" will be presented before booting.
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).
- To access the GRUB prompt, type 'c' while the GRUB menu is displayed.
Manually type each line (except the menuentry line) and press ENTER.
- If no messages are displayed after pressing ENTER the command ran successfully.
After entering the final line, type boot and ENTER.
- 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.
Menuentry Troubleshooting
There are a variety of reasons why a menuentry may fail to boot the ISO. Since the Ubuntu ISOs are standardized, the most likely reason is an incorrect path in one of the menuentry lines. Another likely problem is mistyping the ISO filename - for instance using a - rather than a _ or using the wrong version number.
The following steps may help identify the problem:
- Verify the filename is typed correctly.
- Ensure the proper path is used.
- At the Grub prompt, the user can explore both the partitions and the ISO file itself.
Type "ls (hdX,Y)/" or "ls (hdX,Y)/<path>" to inspect the contents of a partition or folder.
- Mount the ISO using the "loopback loop" entry and then explore the contents using "ls (loop)/".
Alternatively, you can explore the ISO contents from a running system via the methods detailed in the Exploring_the_ISO_Contents section of this guide.
- At the Grub prompt, the user can explore both the partitions and the ISO file itself.
- Do not use 'curly quotes' or leave extra spaces in the entries.
Try typing the menuentry (except the title line) manually at the Grub prompt and watch for error messages which may help pinpoint the problem.
If the ISO begins to boot but crashes or halts midway through the boot, the initrd image may not be found or one of the linux line kernel options may be incorrect.
For non-Ubuntu entries the switches on the linux line can be quite complicated. If there is no available example, search forums or the application's web site for working examples.
Installing Ubuntu from a Menuentry Boot
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 which may be necessary, such as video drivers, can not be downloaded. An Internet connection should be available after booting the ISO file from the GRUB menu.
To Install Ubuntu from an ISO Menuentry, use the procedures previously discussed to:
- Download the appropriate ISO.
- Move it to the desired location.
- Create the GRUB 2 menuentry and update the GRUB configuration file.
- 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:
- Open a terminal and run the following command:
sudo umount -l -r -f /isodevice
- Start the installation procedure by double-clicking the "Install Ubuntu" icon.
- Open a terminal and run the following command:
Example ISO Menuentries
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.
An Examples page has been created to allow Ubuntu contributors to provide known, working menuentries for the ISOs of popular Linux and utility discs.
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.
Alternatives to ISO Booting
In addition to booting directly from an ISO menuentry or a bootable CD/DVD, there are also applications which can install the contents of an ISO onto the user's hard drive. These utilities copy the necessary system files into a folder on the partition designated by the user and can create a menuentry to access these files.
One such utility compatible with Ubuntu is UNetbootin. UNetbootin is available via the Ubuntu repositories and Launchpad. Once UNetbootin extracts/installs the ISO files of an operating system or utility it generates a new item in the GRUB 2 menu.
Links
Grub 2 (Ubuntu Wiki)