Advertisement

There's no such thing as a stupid question, but they're the easiest to answer.
Login
Search

Advertisement

Linux and Unix Linux and Unix
Search Search
Search for:
Tech Support Guy > > >

Solved: Ubuntu deleted from Grub bootloader


(!)

ZacSixChip's Avatar
ZacSixChip ZacSixChip is offline
Member with 30 posts.
THREAD STARTER
 
Join Date: Sep 2010
05-Jul-2011, 02:35 PM #1
Solved: Ubuntu deleted from Grub bootloader
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.
TerryNet's Avatar
Computer Specs
Moderator with 66,536 posts.
 
Join Date: Mar 2005
Location: Ottawa, IL
05-Jul-2011, 04:08 PM #2
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?
ZacSixChip's Avatar
ZacSixChip ZacSixChip is offline
Member with 30 posts.
THREAD STARTER
 
Join Date: Sep 2010
05-Jul-2011, 08:26 PM #3
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...-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?
TerryNet's Avatar
Computer Specs
Moderator with 66,536 posts.
 
Join Date: Mar 2005
Location: Ottawa, IL
05-Jul-2011, 10:54 PM #4
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.
__________________
Microsoft MVP - Windows Expert - Consumer (since July 2010)
saikee's Avatar
Member with 3,750 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
06-Jul-2011, 03:39 AM #5
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/vimlinuzXXXXXXX ro root=/dev/sda2
initrd /boot/initrd.imgXXXXXXX
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
initrd.img-2.6.32-22-generic-pae  vmlinuz-2.6.32-22-generic-pae
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/vmlinuz-2.6.32-22-generic-pae ro root=/dev/sda2
initrd /boot/initrd.img-2.6.32-22-generic-pae
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='(hd0,2)'
	linux /boot/vmlinuz-2.6.32-21-generic-pae root=/dev/sda2 ro 
	initrd /boot/initrd.img-2.6.32-21-generic-pae
}
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.

Last edited by saikee; 06-Jul-2011 at 03:54 AM..
ZacSixChip's Avatar
ZacSixChip ZacSixChip is offline
Member with 30 posts.
THREAD STARTER
 
Join Date: Sep 2010
12-Jul-2011, 02:27 PM #6
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...
saikee's Avatar
Member with 3,750 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
12-Jul-2011, 08:19 PM #7
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:
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
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" {
root (hd0,5)
linux /boot/vmlinuz-2.6.32-30-generic ro root=/dev/sda5
initrd /boot/initrd.img-2.6.32-30-generic
}
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!

Last edited by saikee; 12-Jul-2011 at 08:43 PM..
ZacSixChip's Avatar
ZacSixChip ZacSixChip is offline
Member with 30 posts.
THREAD STARTER
 
Join Date: Sep 2010
13-Jul-2011, 01:22 PM #8
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!
saikee's Avatar
Member with 3,750 posts.
 
Join Date: Jun 2004
Location: Newcastle
Experience: A Linux user gone nuts on multi-boot
13-Jul-2011, 06:15 PM #9
Glad you got it sorted.
As Seen On

BBC, Reader's Digest, PC Magazine, Today Show, Money Magazine
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.


Tags
bootloader, ubuntu

(clock)
THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.

Search Tech Support Guy

Find the solution to your
computer problem!




Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


WELCOME
You Are Using: Server ID
Trusted Website Back to the Top ↑