Skip to content

Instantly share code, notes, and snippets.

@riturajborpujari
Last active January 22, 2021 10:06
Show Gist options
  • Save riturajborpujari/646ca8a6a35d124828363712ccca593d to your computer and use it in GitHub Desktop.
Save riturajborpujari/646ca8a6a35d124828363712ccca593d to your computer and use it in GitHub Desktop.
Booting from Grub CLI

GRUB CLI usage for boot

Boot into recovery mode using Grub cli

Entering Grub cli

After the initial BIOS splash screen, press Shift to open GRUB menu. Then press c to enter CLI mode.

You will see a terminal like following

grub> 

List disks and partitions

grub> ls

(hd0) (hd0,msdos2) (hd0,msdos1)

hd0 is the disk name. And (hd0, msdos1), (hd0,msdos2) are the partitions at /dev/sda1, /dev/sda2 respectively.

What’s all this msdos stuff? That means this system has the old-style MS-DOS partition table(MBR), rather than the shiny new Globally Unique Identifiers partition table (GPT)

List files

To list files in dev/sda2 run the following

grub> ls (hd0,msdos2)/

lost+found/ bin/ boot/ cdrom/ dev/ etc/ home/  lib/
lib64/ media/ mnt/ opt/ proc/ root/ run/ sbin/ 
srv/ sys/ tmp/ usr/ var/

Booting from GRUB

To boot into the linux image present in dev/sda2 do the following

  1. grub> set root=(hd0,msdos2)
  2. grub> linux /boot/vmlinuz-5.4.0-58-generic root=/dev/sda2
  3. grub> initrd /boot/vmlinuz-5.4.0-58-generic
  4. grub> boot

For Recovery mode

For booting into recovery mode replace Step 2 of the above process with

grub> linux /boot/vmlinuz-5.4.0-58-generic root=/dev/sda2 recovery

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment