3

I'd like to edit the Grub menu that comes up, to move one line and remove others.

I have an Inspiron 1420 that came with Ubuntu 7.10. When it needed a new drive, I installed Windows 7, the original OS, and then it seemed that 10.04 wanted its own partition. I probably should have checked exactly what I was doing first (famous last words).

What I'd like to do is remove the 7.10 lines entirely, so I can blow away everything in that partition and use it as /home for 10.04. I'd also like to move the Windows 7 line up to second from the top, so booting in Windows would be a quick two keystrokes rather than following the line all the way down. Hitting the Grub edit key came up with unclear instructions, and since this is the boot loader I'd kind of rather not screw it up too bad.

So, what's the best way to do this?

1
  • 1
    can you check if you are using Grub Legacy or Grub 2? If you have a file named /boot/grub/menu.lst then it's Grub Legacy, else if you have a file named /boot/grub/grub.cfg then it's Grub 2.
    – phunehehe
    Sep 4, 2010 at 17:24

3 Answers 3

6

Short answer: Delete the 7.10 partition, edit the files in /etc/grub.d/ as needed, then run sudo update-grub

Long answer: The edit mode in the boot menu is meant for temporary edits, for recovery or testing purposes usually. To change the options permanently you need to boot into the OS that installed Grub to the boot block and change the Grub configuration there.

Ubuntu 10.04 uses Grub2 by default, which eliminates menu.lst and autogenerates grub.cfg each time update-grub is run. I wouldn't edit that file manually as your changes will likely get blown away (update-grub is automatically run after various updates, especially those dealing with the kernel).

The first thing I'd do is make sure you're using Grub from your 10.04 partition, and not your 7.10. I believe booting into 10.04 and running sudo update-grub should be sufficient. If it runs fine, you're using the correct Grub. If it doesn't, it should provide an error message you can use to figure out what needs to be done.

To remove the 7.10 entries, it might be as simple as just wiping that partition and then running sudo update-grub. Most of the Grub2 entries are autodetected, so if it no longer detects the bootable kernel it won't list it. If that doesn't clear it, the files to edit live in /etc/grub.d/, look for a file or section specific to 7.10 and delete it (making sure to back up any file you edit/delete first), then rerun sudo update-grub. If you screw something up, you can fix it by putting your backed up files back and rerunning sudo update-grub, although you may need to boot off your recovery disc if you manage to blow away your 10.04 entry somehow.

Reordering is trickier, they come from the order of the files in /etc/grub.d/ and the order within those scripts. The Windows entry comes from 30_os-prober, so you could rename it 11_os-prober to put it after the entries from 10_linux but that wouldn't make it the second entry and I'm not sure if that would break with updates.

If you don't mind having the Windows entry first and Linux second (but default) what I did instead was to copy 40_custom to 01_custom and then copied the Windows menuentry section from /boot/grub/grub.cfg verbatim. That put Windows as the first entry, and you can then edit /etc/default/grub and put GRUB_DEFAULT=1 to make the second entry (it counts from 0) the default (assuming that's 10.04). Note that this will duplicate the Windows entry in your boot menu, which you can eliminate the duplicate by removing the execute bit from 30_os-prober, but I suggest leaving it in case you need the autoprobed entries from os-prober later.

4
  1. Tell the Ubuntu 10.04 to impose its own Grub2 (grub-pc package) for booting, if you haven't done so already (the installation program may have reused the existing Grub from 7.04). It may be as simple as

    sudo update-grub
    sudo grub-install /dev/sda
    

    but check https://help.ubuntu.com/community/Grub2 if you have trouble. Don't worry if you see something about 7.04: it's expected and harmless.

  2. Remove the 7.04 installation.

  3. Run update-grub again on the 10.04 system. This time it should only offer to boot Ubuntu 10.04 and Windows.

  4. I can't think of an easy way of having the Windows entry between the normal Linux entry and the rescue Linux entry. But I think in your situation the Windows entry will be last, so you can boot it with End Enter.

0

You should probably refer to the Ubuntu documentation

An example of menu.lst (for Grub Legacy) can be found by googling "grub menu.lst". Here is the second result (the first is about Grub2).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .