1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Ubuntu deleted from Grub bootloader

Discussion in 'Linux and Unix' started by ZacSixChip, Jul 5, 2011.

Thread Status:
Not open for further replies.
Advertisement
  1. ZacSixChip

    ZacSixChip Thread Starter

    Joined:
    Sep 22, 2010
    Messages:
    30
    I dual boot Win7 and Ubuntu on a netbook and recently I accidentally removed the "boot into Ubuntu" option while cleaning up the grub2 bootloader so now Win7 is my only boot option - can somebody please help me re-edit the bootloader so I can restore the "boot to Ubuntu" option... I don't want to have to wipe the drive, reinstall Windows 7 , and then reinstall Ubuntu again.

    I've already tried booting into an Ubuntu Live CD to find and edit the boot loader and I think I found the right file, but it would not let me save the changes I made.

    Any ideas would be very helpful.

    The version of Ubuntu installed on the netbook was probably 10.x and have all the live cd's from 8.x - current.
     
  2. TerryNet

    TerryNet Terry Moderator

    Joined:
    Mar 23, 2005
    Messages:
    69,555
    Do you mean the /boot/grub/grub.cfg file? I realize that file is read-only, but how did you "clean" it w/o being able to edit it now?
     
  3. ZacSixChip

    ZacSixChip Thread Starter

    Joined:
    Sep 22, 2010
    Messages:
    30
    Let me clarify: back when I could boot into Ubuntu, I was editing whatever-it-is that determines the options that I see when the PC first boots - it used to have two options, Ubuntu and Win7 - because I wanted to clean it up a bit. This is what I was using to edit: http://www.howtogeek.com/howto/43471/how-to-configure-the-linux-grub2-boot-menu-the-easy-way/

    I must have unchecked to many things because now Ubuntu isn't an option when the boot menu comes up, only Win7.

    Can I edit this file in Windows? I don't think that it recognizes the partition because of the file format that Ubuntu uses. Any ideas?
     
  4. TerryNet

    TerryNet Terry Moderator

    Joined:
    Mar 23, 2005
    Messages:
    69,555
    To answer the easy part first--you are right that Microsoft refuses to recognize formats other than FAT and NTFS. However, I think that there are utilities you can use in Windows to read Linux-type formatted partitions (sample article).

    I've never used that boot Customizer that you used. My guess is that when you try to use it with the Live CD it is accessing the CD, not the hard drive partition. Am I wrong? Is there a way to tell it where to find the file?

    When I've edited the file I've done it the down and dirty way that shouldn't be done--just edit the file like any other text file.
     
  5. saikee

    saikee

    Joined:
    Jun 11, 2004
    Messages:
    3,768
    This is a funny post!

    The OP used a Grub customiser program in Ubuntu to configure the operating system. The OP then decided to delete the booting option of Ubuntu but now wants it back. However to use Grub customiser the OP must rub Ubuntu first as the program is inside it.

    Cure:

    One can use Grub2 to boot any system manually. To do this before selecting a system to boot press the "c" key first and drop into a Grub prompt. To view what is in the disk issue the command
    Code:
    ls -l
    and Grub will display the partitions.

    The OP needs to know which partition holds the Ubuntu in order to boot it. Say this is the second partition of the 1st disk then in Grub convention it is (hd0,2) as Grub2, current Ubuntu bootloader, count disk from zero and partition from one.

    The commands to boot a Linux in say (hd0,2) are
    Code:
    setup root=(hd0,2)
    Linux /boot/vimlinuz[COLOR="Red"]XXXXXXX[/COLOR] ro root=/dev/sda2
    initrd /boot/initrd.img[COLOR="Red"]XXXXXXX[/COLOR]
    boot

    The
    XXXXXXX is the rest of kernel and initrd file names that can be find by command
    Code:
    ls -l /boot
    Any matching pair will do but the latest pair should be the current one. For example my Ubuntu /boot shows
    Code:
    initrd.img-2.6.32-21-generic-pae  vmlinuz-2.6.32-21-generic-pae
    [COLOR="Red"]initrd.img-2.6.32-22-generic-pae  vmlinuz-2.6.32-22-generic-pae[/COLOR]
    initrd.img-2.6.32-24-generic-pae  vmlinuz-2.6.32-24-generic-pae
    initrd.img-2.6.32-25-generic-pae  vmlinuz-2.6.32-25-generic-pae
    initrd.img-2.6.32-27-generic-pae  vmlinuz-2.6.32-27-generic-pae
    initrd.img-2.6.32-28-generic-pae  vmlinuz-2.6.32-28-generic-pae
    initrd.img-2.6.32-29-generic-pae  vmlinuz-2.6.32-29-generic-pae
    initrd.img-2.6.32-30-generic-pae  vmlinuz-2.6.32-30-generic-pae
    initrd.img-2.6.32-31-generic-pae  vmlinuz-2.6.32-31-generic-pae
    initrd.img-2.6.32-32-generic-pae  vmlinuz-2.6.32-32-generic-pae
    and I can fire it up manually by commands
    Code:
    setup root=(hd0,2)
    Linux /boot/[COLOR="Red"]vmlinuz-2.6.32-22-generic-pae[/COLOR] ro root=/dev/sda2
    initrd /boot/[COLOR="Red"]initrd.img-2.6.32-22-generic-pae[/COLOR]
    boot
    Once Ubuntu fires up use the Grub customeriser program to add Ubuntu entry or add these lines to Ubuntu's /boot/grub/grub.cfg
    Code:
    menuentry "Ubuntu,restored according Tech Support Forum" {
    	insmod ext2
    	set root='[COLOR="Blue"](hd0,2)[/COLOR]'
    	linux /boot/vmlinuz[COLOR="Blue"]-2.6.32-21-generic-pae[/COLOR] root=/dev/[COLOR="Blue"]sda2[/COLOR] ro 
    	initrd /boot/initrd.img[COLOR="Blue"]-2.6.32-21-generic-pae[/COLOR]
    }
    to make the arrangement permanent
    The above assumes Ubuntu is in sda2 (2nd partition of 1st disk in Linux convention and (hd0,2) in Grub2 convention) and the kernel and inird files name version -2.6.32-21-generic-pae. Adjust those to suit your situation.

    Remember there is no installed operating system Grub cannot boot. I would rather learn to tell Grub what to do than using a middleman like a customeriser program. Grub2 is very Linux like and should be a joy to use.

    Extra explanation: In manual booting you can use the same commands as /boot/grub/grub.cfg except omitting the "menuentry" statement and add the "boot" statement at the end. You see Grub has already told you how to boot every system manually, including the MS Windows if you just look at its configuration file /boot/grub/grub.cfg.

    If you know how to boot an operating system manually with Grub you can kiss all your booting problem good bye.
     
  6. ZacSixChip

    ZacSixChip Thread Starter

    Joined:
    Sep 22, 2010
    Messages:
    30
    Thank you saikee for your help - I am such a novice when it comes to Linux I hardly know what to do with all the info you gave me.

    Take a look at these 3 screenshots:

    http://www.twitpic.com/5p5so0
    http://www.twitpic.com/5p5u8j
    http://www.twitpic.com/5p5ug3

    I think the partition I want to add to the menu (or even boot manually from time to time is (hd0,5) - does that look right?

    Is there a command I can use to manually boot into Ubuntu from here? Even that would greatly help at the moment...
     
  7. saikee

    saikee

    Joined:
    Jun 11, 2004
    Messages:
    3,768
    ZacSixChip,

    You are almost there.

    Yes you have only one partition with ext2 filing system and that is (hd0,5). Ubuntu should be inside.

    Your three screen shots are obtained by communicating with Grub2. The version 1.98 at the top indicates your Grub is version 2.

    You can boot up your Ubuntu manually by these commands
    Code:
    [COLOR="Purple"]root (hd0,5)
    linux /boot/vmlinuz-2.6.32-30-generic ro root=/dev/sda5
    initrd /boot/initrd.img-2.6.32-30-generic
    boot[/COLOR]
    Let us know If Ubuntu boots successfully and we can make the arrangement permanently by following commands below. Post the content of /boot/grub/grub.cfg in your replay by Linux terminal command if you still have a problem
    Code:
    sudo cat /boot/grub/grub.cfg
    You should be able to edit this file by command
    Code:
    sudo gedit /boot/grub/grub.cfg
    by including these lines at the end
    Code:
    menuentry "Ubuntu restored according a dude's suggestion in Tech Support Forum" {
    [COLOR="Purple"]root (hd0,5)
    linux /boot/vmlinuz-2.6.32-30-generic ro root=/dev/sda5
    initrd /boot/initrd.img-2.6.32-30-generic[/COLOR]
    }
    Save the file and you should see Ubuntu reappear on a reboot.

    Basically the commands you use for manual booting is same as in the configuration file /boot/grub.grub.cfg except you don't need the "menuentry" statement (which serves to tell you what the OS is) but at the end add the "boot" statement (serves as a green light to tell Grub go ahead to boot up the OS).

    If you manage to boot up Ubuntu manually you can boot up Win7 manually too by commands
    Code:
    root (hd0,2)
    chainloader +1
    boot
    You will feel the power of Grub and kiss majority of your booting problems good bye. Grub2 indicates (hd0,1) a reserved partition likely to be one used by the manufacturer to store the drivers leaving (hd0,2) the only logical choice for your Win7 as it has ntfs filing system inside. You can actually ask Grub to display the content inside by
    Code:
    ls -l (hd0,2)
    Inside you should find /boot, /Documents, /Users and settings, /Windows folders etc.

    Believe me if you use Linux you are in real control of the computer!
     
  8. ZacSixChip

    ZacSixChip Thread Starter

    Joined:
    Sep 22, 2010
    Messages:
    30
    Saikee, I can't thank you enough. Your suggestion worked and I was able to boot Ubuntu and open the Grub Customizer and re-add Ubuntu 10.10. Thank you!
     
  9. saikee

    saikee

    Joined:
    Jun 11, 2004
    Messages:
    3,768
    Glad you got it sorted.
     
  10. Sponsor

As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Loading...
Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/1005817