PDA

View Full Version : booting Fedora from grub2 command line



gordon64
8th May 2017, 02:02 PM
Longer title
You have some kind of error and instead of a grub menu you arrive that a grub prompt
OR
your selection fails to boot

---for non-UEFI (no windows users)

this howto if it fails for you, would also suggest you have some kind of backup

I use a live cd/usb stick with fsarchiver but there a lots of other backups you can do it too.

One day your grub menu drops to a prompt and you don't know what to do next?

step one (Personal opinion)
Get rid of LVM/RAID and have ext4 partition for / and only optional for /boot

reason: Keep it Simple Stupid (KISS)

step two
use gparted or e2label to label your partitions with easy to remember names.

for my internal names I use p1 p2 p4.....p3 is my swap so I don't need to boot it

for other drives including USB bootable drives you must not use the same names but have some easy to remember system.
If you have too many bootable sticks then mark them or label them

eg pur1 pur2 means purple usb stick partition 1 2 respectively

You do not need to remember what your label for any separate boot partition is,
but you need to remember what partition number it is.

You need to remember what your label for / is.

Hint, keep it simple boot is a sub-folder for me.

remember grub2 counts hard drives from zero and partitions from one.

step 3
Read your current /boot/grub/grub.cfg

but bits can be ignored. Where you see linux16 it means the same as linux.

step 4
write notes on the essential comands you can glean from that grub.cfg more below

Pay attention to various video chipsets that might need nomodest, noapic and other strange things

step 5
Be aware that grub2 at command line normally allows autocompletion by pressing the TAB key
and
if there are a range of options for something1 something2 something3......
typing so (and pressing TAB key will offer those options to you)

Depending on what words it finds depends on what options are offered.
If its a unique name like vmlinuz then typing "vm" and pressing TAB key will suffice

image is for initrd but kernel line is same thing
http://oi65.tinypic.com/x5xllg.jpg

Lets try it

after bios I see a grub menu
press the C key (lower case c will work) to get to command mode

I now type the following commands, shorter than your list,


set root=hd0,3
linux /boot/vm (and press the TAB key to see a range of options)
normally you will not choose the rescue kernel but the latest kernel.

so pretend you type 4.10.13 (press the TAB key to auto complete the full kernel name)

Now we need to tell the kernel where is / and here is why LABEL kills UUID users

I type after autocompleting the kernel


root=LABEL=p3

For those people still using UUID I will drink one beer for your cheerful disposition ;)

I don't worry about extras like ro, nomodeset etc unless you know you need it. I have intel card

next line
#######


initrd /boot/initramfs- (and press the TAB key)
options will include rescue initramfs but I will type
4.10.13 (and press TAB key) to auto complet the same kernel number I chose in the linux (kernel) line

If you can not remember that the initrd name is initramfs you must remember the 2 lines are

linux
initrd

and on the initrd and typing initrd /boot/ just press the TAB key to see what options are

next line
########

boot


and cross your fingers it works

image shows no use of TAB key. I made one typo and by pressing the UP key I was able to repeat the command and fix the typo.

http://oi63.tinypic.com/2v2i4xe.jpg

Errors

If auto completion is not working it may be because a module has failed to load.

run

lsmod

minimum needed as below

If lsmod does not show ext2, gzio, part_msdos as loaded then you will need to load them like this

http://oi64.tinypic.com/6tl5ld.jpg


insmod ext2, gzio, part_msdos