HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt
This guide will detail how to boot an Ubuntu Live CD ISO from the "grub rescue>" prompt. The procedure will also work from the "grub>" prompt for Grub 2 users. I started this thread to help netbook users who are unable to mount the Live CD to resolve Grub problems on a previously-working installation. No CD is required. While writing the guide, I realized there might be others who could also use the instructions so I removed references to "Netbook" from the title.
This procedure will work for:
- Ubuntu family releases using Grub 2
- Malformed Grub 2 menu (grub.cfg)
- Missing Linux kernels & initramfs images
- Corrupted system folders (not including the module folder)
In order for this procedure to work, you must:
- Have an Ubuntu family Live CD ISO image on a partition accessible from the Grub rescue prompt.
- Grub modules from a previous installation must be found and properly loaded.
The procedure will not work for:
- Missing Grub 2 modules (normally in /boot/grub or /usr/lib/grub/i386-pc )
- Corrupted Ubuntu ISO images
- Corrupted partition structure - "ls" returns only "(hd0)"
- Download the ISO.
- Download an Ubuntu ISO from: http://www.ubuntu.com/desktop/get-ubuntu/download
- Download an Ubuntu Netbook ISO from: http://www.ubuntu.com/netbook/get-ubuntu/download
- Locate the Ubuntu partition and the folder containing the Grub modules.
The Grub folder containing the modules must be located so the correct modules can be loaded. This folder would have been created during the initial installation of Ubuntu and should be located in the Ubuntu partition. This folder would normally be located at either (hdX,Y)/boot/grub or (hdX,Y)/usr/lib/grub/i386-pc
Find your existing Ubuntu partition and the module folder.
Code:ls # List the known drives (hdX) and partitions (hdX,Y) ls (hdX,Y)/ # List the contents of the partition's root ls (hdX,Y)/boot/grub # Normal location of the Grub 2 modules. ls (hdX,Y)/usr/lib/grub/i386-pc # Alternate location of the Grub 2 modules.
- ls - should return all known drives (hdX) and partitions (hdX,Y)
- ls (hdX,Y)/ - should show the contents of the root directory of the partition.
- If you get an "error: unknown filesystem" this is not your Ubuntu partition; more on that later.
- If this is the Ubuntu partition, you will see the Ubuntu folders, including lost+found/, home/, boot/ and vmlinuz and initrd.img. Use this address as the first part of the next command.
- ls (hdX,Y)/boot/grub - should display several dozen *.mod files. This is the folder you are looking for.
- If you don't find the modules, try the alternate location: ls (hdX,Y)/usr/lib/grub/i386-pc
- Load the modules.
This command must correctly point to the folder containing the Grub modules. The address should be the one in the previous section which displayed the modules.Code:set prefix=(hdX,Y)/<path to modules>
A "file not found" error means that the path in the prefix is incorrect or the specific module does not exist. The prefix setting may be reviewed with the set command. Rerun the "set prefix=" command with the proper path.Code:insmod linux insmod loopback insmod iso9660 insmod fat # If ISO is located on fat16 or fat32 formatted partition. insmod ntfs # If ISO is located on an NTFS formatted partition. insmod nftscomp # If NTFS compression is used on the partition. Load if you aren't sure.
- Locate the Ubuntu ISO file.
Using the same combinations of ls commands, locate the Ubuntu ISO image.
- You are looking for contents including the ISO, such as ubuntu-10.04.1-desktop-i386.iso
- Expand the path if the ISO image is not located in the / folder.
- If you receive an error: unknown filesystem you may need to load the filesystem module (such as ntfs or fat. Return to the previous section for guidance.
- Create the loopback device.
Example:Code:loopback loop (hdX,Y)/<path to ISO>/<ISO-name.iso>
loopback loop (hd1,1)/ubuntu-10.04.1-desktop-i386.iso
- Load the Linux kernel and initrd image.
If the path to the ISO or filename is not correct, the boot will halt at the BusyBox screen and produce a message stating "can't open /dev/sr0: No medium found".Code:set root=(loop) linux /casper/vmlinuz boot=casper iso-scan/filename=/<ISO-name.iso> noprompt noeject initrd /casper/initrd.lz
Note: If the ISO file is not in the / folder, include the path in the iso-scan/filename= entry. See second example.
linux /casper/vmlinuz boot=casper iso-scan/filename=/ubuntu-10.04.1-desktop-i386.iso
linux /casper/vmlinuz boot=casper iso-scan/filename=/my-iso/ubuntu-10.04.1-desktop-i386.iso
That should be it. If the commands ran without any messages/errors, the commands were accepted as entered. It's now time to boot:
Install Ubuntu - From Live CD ISO
Note on Oneiric Daily ISO Installs: The current daily build of Oneiric Ocelot requires login to get to the Desktop. Choosing the default user will not allow use of 'sudo' as no password exists for the user. Select 'Other', then username 'Ubuntu' and leave the password field blank. This will allow the use of 'sudo' to unmount the /isodevice during the installation process.
Installation onto your hard drive is possible from a booted ISO file. A CD 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.
- Boot to the Live CD Desktop using the above ISO boot procedure.
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 isodevice1 during the installation. /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. This forced unmounting is included in the procedure detailed later in this section.
- If you would like to try the toram option, replace the linux line in the above and use this one instead:
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 (it failed on my system with 3GB) and start the installation, the installer will be unable to unmount /isodevice, the install will fail and the system may freeze. Reboot and complete all the steps in the "Boot Procedure" section. Do not repeat this subsection and continue below.
- Open a terminal: Applications, Accessories, Terminal
- Unmount /isodevice
Code:sudo umount -l -r -f /isodevice
- Start the installation procedure by double-clicking the "Install Ubuntu" icon.
- The installation will proceed as would any installation of the same release, similar to the Alternate CD.
- During the latter stages of the installation (Step 8 in Ubuntu 10.04), you may see an "Advanced" button. If so, this is how you access the Grub installation options.
Install Ubuntu - Network Install
This procedure can be used on low-memory systems or by users who otherwise wish to download the installation files from the Internet. The process uses the free services of "netboot.me". The installer will attempt to connect to the Internet and download the installation files. Once the initial files are downloaded, the installation is similar to that of the Alternate CD installation.
- Download the netbootme.iso from the link under the "Booting from CD" section of this page.
- You can download the ISO via any means available: Windows, terminal with wget, etc.
- Note where the netbootme.iso is located on your drive. You will need to know the (hdX,Y) partition and path (if not stored in the root directory).
- While this guide focuses on ISO booting, netboot.me offers other installation options, such as USB booting, which the user may wish to consider.
- From the "grub rescue>" or "rescue" prompt, run the following commands. For detailed guidance, refer to the previous sections.
- Code:set prefix=(hdX,Y)/boot/grub insmod loopback insmod iso9660 insmod fat # If ISO is located on fat16 or fat32 formatted partition. insmod ntfs # If ISO is located on an NTFS formatted partition. insmod nftscomp # If NTFS compression is used on the partition. Load if you aren't sure. loopback loop (hdX,Y)/<path if not in root directory of hdX,Y>/netbootme.iso # Example: loopback loop (hd1,1)/myiso/netbootme.iso linux16 (loop)/GPXE.KRN boot
- Installer Notes
- Once the netboot.me installation begins, select the installation you desire. For the standard Ubuntu installation, make the following selections:
- Installers > Linux > Ubuntu > Version (Look in the status bar for the 32-bit/i386 or 64-bit/amd64, as the links are named the same).
- Other operating systems are also available for installation from the main menu display.
- During the latter stages of the download and installation, download options are presented. Normally the user will want to include the "Ubuntu Desktop".
Other drs305 Grub 2 Links:
5 Common Tasks
ISO Booting with Grub 2 Menu Entries
Purge and Reinstall Grub 2 from the Live CD
Grub 2 (help.ubuntu.com)