Page 1 of 5 123 ... LastLast
Results 1 to 10 of 45

Thread: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

  1. #1
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    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.

    Preconditions

    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)"



    Boot Procedure
    1. Download the ISO.


    2. 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


    3. Load the modules.
      Code:
      set prefix=(hdX,Y)/<path to 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.
      Examples:
      set prefix=(hd0,5)/boot/grub
      set prefix=(hd1,1)/usr/lib/grub/i386-pc

      Load modules:
      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.
      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.

    4. Locate the Ubuntu ISO file.
      Using the same combinations of ls commands, locate the Ubuntu ISO image.

      Code:
      ls (hdX,Y)/
      • 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.


    5. Create the loopback device.
      Code:
      loopback loop (hdX,Y)/<path to ISO>/<ISO-name.iso>
      Example:
      loopback loop (hd1,1)/ubuntu-10.04.1-desktop-i386.iso

    6. Load the Linux kernel and initrd image.
      Code:
      set root=(loop)
      linux /casper/vmlinuz boot=casper iso-scan/filename=/<ISO-name.iso> noprompt noeject
      initrd /casper/initrd.lz
      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".

      Note: If the ISO file is not in the / folder, include the path in the iso-scan/filename= entry. See second example.

      Examples:
      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

    7. Boot.
      That should be it. If the commands ran without any messages/errors, the commands were accepted as entered. It's now time to boot:
      Code:
      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.

    1. 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.


    2. Open a terminal: Applications, Accessories, Terminal

    3. Unmount /isodevice
      Code:
      sudo umount -l -r -f /isodevice
    4. Start the installation procedure by double-clicking the "Install Ubuntu" icon.

    5. The installation will proceed as would any installation of the same release, similar to the Alternate CD.

    6. 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.
    1. 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.


    2. 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
    3. 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
    Password Protection
    Purge and Reinstall Grub 2 from the Live CD
    Title Tweaks

    Grub 2 (help.ubuntu.com)
    Last edited by drs305; July 28th, 2011 at 07:35 PM. Reason: Oneiric daily note.
    Back to Xorg...

    Retired.

  2. #2
    Join Date
    Mar 2011
    Beans
    12

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    i tried the command 'insmod linux' but an error occured:

    grub rescue> insmod linux
    error: invalid object file.

    What causes the error? Additional details:
    grub rescue> ls
    (hd0) (hd0,msdos5) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)
    grub rescue> ls (hd0,2)/
    ./ ../ lost+found/ var/ etc/ media/ bin/ boot/ ...
    grub rescue> ls (hd0,2)/boot/grub/
    ...(many .mod files) ... grubenv core.img grub.cfg
    grub rescue> set prefix=(hd0,2)/boot/grub
    grub rescue> set
    prefix=(hd0,2)/boot/grub
    root=hd0,2
    grub rescue> insmod linux
    error: invalid object file
    grub rescue>

    I also tried setting the prefix to usr/lib/grub/i386-pc but the same error occured

  3. #3
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Quote Originally Posted by kamaru44ken View Post
    i tried the command 'insmod linux' but an error occured:
    I also tried setting the prefix to usr/lib/grub/i386-pc but the same error occured
    If you are still having problems, try to add the module by using the entire address:
    Code:
    insmod (hd0,2)/boot/grub/linux.mod
    For what you have posted, you can try this sequence to boot:

    Code:
    set prefix=(hd0,2)/boot/grub
    set root=(hd0,2)
    insmod (hd0,2)/boot/grub/linux.mod
    linux /vmlinuz root=/dev/sda2 ro
    initrd /initrd.img
    boot
    Back to Xorg...

    Retired.

  4. #4
    Join Date
    Apr 2011
    Beans
    1

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Quote Originally Posted by drs305 View Post
    If you are still having problems, try to add the module by using the entire address:
    Code:
    insmod (hd0,2)/boot/grub/linux.mod
    For what you have posted, you can try this sequence to boot:

    Code:
    set prefix=(hd0,2)/boot/grub
    set root=(hd0,2)
    insmod (hd0,2)/boot/grub/linux.mod
    linux /vmlinuz root=/dev/sda2 ro
    initrd /initrd.img
    boot
    I used bottom part worked great untill shut down. than the same thing happened and had to do all over again what should i do? also my computer usually asks if i want to boot win7 or ubuntu and it stoped what could be causing this?
    Last edited by jmrat; April 19th, 2011 at 01:40 AM. Reason: forgot info

  5. #5
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Quote Originally Posted by jmrat View Post
    I used bottom part worked great untill shut down. than the same thing happened and had to do all over again what should i do?
    Changes made at the grub prompt are non-persistent (as you found). Do the procedure again. Once booted into your normal installation, run:
    Code:
    sudo update-grub
    sudo blkid -c /dev/null
    Compare the UUID for your Ubuntu partition in /boot/grub/grub.cfg (in the default menuentry) with the results from the second command and make sure they are the same. The update-grub command should have corrected any mis-identified UUIDs, but check to be sure they are all correct.

    If you still have problems, you could try disabling the UUID entry in /etc/default/grub to see if that fixes things (Note it may be slightly different wording, depending on the version of Grub2 you are using). In any case, remove the # symbol.
    GRUB_DISABLE_LINUX_UUID="true"
    Last edited by drs305; April 19th, 2011 at 01:44 AM.
    Back to Xorg...

    Retired.

  6. #6
    Join Date
    Apr 2011
    Beans
    9

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    HI!
    i have problems booting my ubuntu as i always get this grub prompt
    so i try to boot it from here
    when i start looking for the ubuntu .iso file is most directories like ls (hd0,1)/home or most of other folders i get error: out of disk
    what should that mean?
    thank you

  7. #7
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Quote Originally Posted by egor123 View Post
    HI!
    i have problems booting my ubuntu as i always get this grub prompt
    so i try to boot it from here
    when i start looking for the ubuntu .iso file is most directories like ls (hd0,1)/home or most of other folders i get error: out of disk
    what should that mean?
    thank you
    egor123,

    'out of disk' can be caused by many things. Often it means the BIOS cannot read the drive. You should probably open up your BIOS setup during boot and check the reported drive size. If the BIOS does not report the full size of your drive, any files physically located beyond the limit seen by the BIOS will not be found.

    At the grub prompt, when investigating I usually start with "ls" to see what partitions Grub2 sees, then go deeper step by step. Next "ls (hd0,1)/", then "(hd0,1)/boot" and then "(hd0,1)/boot/grub" for instance.

    If Grub 2 can't find the file(s) with the 'ls' command, it won't be able to use them to boot.
    Back to Xorg...

    Retired.

  8. #8
    Join Date
    Jan 2011
    Beans
    45

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Hi DRS305, Thanks so much for all your time and effort, in writing the guide as well as answering questions!

    I've got a new Dell Vostro 3300. I posted something in the Dell subforum, but I'm not sure whether what I'm experiencing is specific to Dell.

    I followed the instructions in this thread, and it goes through all the way to the end. After typing "boot", some words and numbers fly by on the screen. Then the screen goes blank and it hangs there, indefinitely.

    I'm able to boot this machine using a USB key that I created using Unetbootin. I've been going in and editing grub.cfg and rebooting trying to find out what's the problem, until I came across this set of instructions. Now I can now enter line-by-line to see what's wrong. But at this time, all the commands go through, but it still hangs.

    Any thoughts?

    Thanks!

  9. #9
    Join Date
    Jan 2007
    Beans
    Hidden!
    Distro
    Ubuntu Development Release

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Quote Originally Posted by chah View Post
    Now I can now enter line-by-line to see what's wrong. But at this time, all the commands go through, but it still hangs.
    Any thoughts?
    chah,

    It sounds like a video problem more than a grub problem. Grub will either pass control to the kernel or if it can't boot will produce an error message or grub prompt. Since you have neither of those the chances are good that it's kernel related.

    If you have Maverick or earlier, and a blinking cursor on a blank screen, try editing the menu during boot (hold down the SHIFT key if you don't see the menu). Press 'e' to edit the top entry, then cursor to the 'linux' line. Remove quiet splash and add nomodeset. Then press CTRL-x to boot.

    If it boots to the Desktop, System, Administration, Additional Drivers and add a driver for your video card to see if that fixes things.

    If you have Natty, there have been some problems with the Grub/kernel interface. I'm going to give you a link, but it is major work wading through it all. For starters, you could try the above, but also remove vt.handoff=7 and add vga=771. Try that first, then try nomodeset if that doesn't work.

    Let us know if you have success with any of these methods.
    Back to Xorg...

    Retired.

  10. #10
    Join Date
    Jan 2011
    Beans
    45

    Re: HOWTO: Boot & Install Ubuntu from the Grub Rescue Prompt

    Hi DRS,

    Thanks for the tips. I also thought it might be a video problem when it happened. However, I listened for the ubuntu start-up sound and did not hear it. Incidentally, I'm using Natty.

    So just to update what happened, I finally did the regular install, instead of booting from the ISO with persistence. It was a bit strange, the regular install crashed twice when I tried to do it from my office (I turned on updates and third party drivers). However when i came home, the installation seemed to work. For some reason though, it told me that my laptop does not have the hardware to support Unity, even though Unity was working when I boot from the Unetbootin USB key. I tried digging through the boot/grub/*.cfg file on the Unetbootin thumbdrive in the past, but copying parameters from that file into my own boot grub.cfg file didn't seem to work either. I don't suppose you have any information about how Unetbootin is able to boot or how I can copy its GRUB2 parameters to my HDD boot partition? This is out of curiosity as I'm fine without Unity.

    I may come back to this at some point in the future. Thanks for your help.

Page 1 of 5 123 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •