How to edit /boot/grub/menu.lst

Asked by gary

Dear team,

I'm a newbie at Linux. Installed Ubuntu 7.04 on two of my machines yet failed to utilize the grub boot loader. Instead I used a 3rd party boot loader called BootIt NG. I'm now trying again to setup my kids computer to dual boot using grub. I loaded Ubuntu on a clean drive and got it up and working. Then I connected another drive that had a Windows XP partition on it, and copied it onto the drive with Ubuntu. Used my BootIt NG partition disk to set up the MBR entry for it and modified the boot.ini file to reflect the relative position of the WinXP partition.

On bootup, I hit the esc key to go to the grub boot menu list. Then I edited the last item, the memory test, to use it to boot the WinXP partition and it works!

Now here's the easy part for you Linux guys to help me out. I need to edit the /boot/grub/menu.lst file to have a permanent entry in the boot up list.

Do I use the grub-install to do this? or boot from a grub boot disk and run the root and setup commands?

These are the lines that boot my WinXP partition on the fly:

root (hd0,3)
savedefault
makeactive
chainloader +1

then I hit boot and it boots. But how can I modify the menu.lst file. If I use a text editor from the Ubuntu desktop, It doesn't allow me to save the file. This is how I would prefer to do it since my experience with the grub setup commands in the past have not gone too well.

Thanks for any help!
Gary

Question information

Language:
English Edit question
Status:
Solved
For:
Ubuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Hanusz leszek
Solved:
Last query:
Last reply:
Revision history for this message
Best Hanusz leszek (leszek-skynet) said :
#1

Hello,

Open a terminal and type this:
gksudo gedit /boot/grub/menu.lst

Revision history for this message
gary (garylduncan) said :
#2

Thanks Hanusz.

That was just the info I needed. I edited the file and now it dual boots like it's supposed to.

I have seen a lot of posts here of people trying to setup dual booting with grub, and they always seem to get into trouble getting things configured right. When you have multiple boot partitions, grub just guesses things and it doesn't go right. What I did was this:

Back up your Windows partition to another hard drive, or use a new drive to install Ubuntu.

Load Ubuntu on a clean drive and set up the ext3 root partition on the first partition of the drive, (hd0,0)
Allow grub to install itself to the default location which is in the MBR (hd0)

After Ubuntu is all set up, then copy your Win XP or other OS to the drive in unallocated space after the root partition and swap partition.
Modify the boot.ini file in the Windows partition to the relative position, which is 2, (the swap file doesn't seen to count.)
The way to edit this position is when you open the boot.ini file, you'll see like this:

default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)WINDOWS="Microsoft Windows XP Professional" /fastdetect /NoExecute=Optln

Modify the two relative partition numbers, in this case 1, which would be the case where Windows is the first bootable partition on the drive. However, in my case the number was 2 since Ubuntu was the first.

Once this file is edited and saved on the Windows partition, you need to edit the grub menu.lst file to show the menu option on bootup using the editor as you showed above. Add an entry as follows:

title Microsoft Windows XP Professional
root (hd0,2)
savedefault
makeactive
chainloader +1

If you got the numbers right, this will boot Windows as well as Ubuntu. When you edit the /boot/grub/menu.lst file, you can also specify which boot item is default and the timeout seconds before the default goes automatically to the specified partition. Otherwise you can hit esc to get the menu and select a non-defaut boot item.

Thanks for all your help!

Gary