GRUB from command line

From MEPIS Documentation Wiki

Jump to: navigation, search

Automatically locating installed kernels with GRUB

From a command line run:

update-grub

-this will search for installed kernels in your partitions, then will append generic menu.lst entries to the end of the file - these should be able to boot your installs - but may need tweaking to suit the specifics of your system.

More info:

man update-grub

Manually locating partitions with Linux installed

When multi booting - it can be tricky to work out where to point GRUB to - to boot from the partitions you have OS's installed in. A good way to find out is to use GRUB from the command line to find out what is where. With the info gained you can then manually edit the GRUB 'boot strap' stanza (the line of code visible at the bottom of the GRUB boot screen) 'on the fly' or to edit your GRUB menu (in other words edit the /boot/grub/menu.lst file from live CD/other OS partition - to correct any errors.

Even if you can't boot your PC from the GRUB screen - you can drop to a command line shell by hitting the <Escape> key, then hit <e> to get to a command prompt. This will also work from any command line running OS or live CD session. Open a terminal window and type as root:

grub

this should take you to a prompt:

grub>

To see all your partitions type:

root (hd  -then hit the <Tab> key to auto-complete. 

GRUB will offer you available boot devices it can see:

grub> root (hd

Possible disks are: hd0 hd1 etc.

Type your disk choice number then hit <Tab> again to list available partitions:

grub> root (hd0,
 Possible partitions are:
  Partition num: 0,  Filesystem type is fat, partition type 0xb
  Partition num: 1,  Filesystem type is ext2fs, partition type 0x83
  Partition num: 2,  Filesystem type is ext2fs, partition type 0x83
  Partition num: 3,  Filesystem type unknown, partition type 0x82

On a computer with 4 partitions - 1 FAT, 2 EXT3 and a Swap partition - it would look like the above.

You can now see the GRUB numbering for the partitions on hd0. Complete the line to hd0,1 - if that's where your OS is installed, hit return - you should get something like:

grub> root (hd0,1)
 Filesystem type is ext2fs, partition type 0x83

Now search for the kernel by typing:

 grub> kernel /boot/vmlinuz- -and hit the Tab key:

This will produce a result similar to this:

vmlinuz-2.6.27-1-mepis-smp 

So in that case the second partition:(hd0,1) has a kernel on it. The 3rd partition doesn't have a kernel on it, so let's see what this would look like:

grub> root (hd0,2)
 Filesystem type is ext2fs, partition type 0x83
grub> kernel /boot/vmlinuz
 Error 15: File not found

From the above examples you should be able to figure out what to look for, so look at each of your Linux partitions. Once you find the kernel, you can edit the "menu.lst" that is associated (i.e. - the menu.lst from the partition you installed GRUB to - regardless whether you installed it to the mbr or /root/) with GRUB to partition hd(x,x) -depends which OS's boot loader you use, to reflect the correct partition, then reboot.

Personal tools
In other languages