Wednesday, July 6, 2016

Boot Linux from GRUB2 Command Line Interface (CLI)

To boot your linux system from the grub command line, you only need 3 commands. It's simple.



Step 1: Set the 'root' variable


If your linux system is on the first partition of your first hard drive, you would type,

set root=(hd0,1)

If your linux system is on the second partition of your first hard drive, you would type,

set root=(hd0,2)

If your linux system is on the first partition of your second hard drive, you would type,

set root=(hd1,1)

and so on.



Step 2: Set the linux kernel path

Type the following command,

linux /boot/your_vmlinuz_file root=/dev/sda1

You can press the tab key, the grub CLI will autocomplete everything for you.

Remember, here you also have to specify the root filesystem. If your linux is installed on the,

first partition of your first hard drive, root=/dev/sda1

second partition of your first hard drive, root=/dev/sda2

first partition of your second hard drive, root=/dev/sdb1


and so one



Step 3: Set the initrd file path

Type the following command,

initrd /boot/initrd_file_path

Step 4: Boot

Now type the following command and enjoy. :-)

boot

On my system(Debian 8 Jessie), I executed the following commands to boot from the grub CLI.

set root=(hd0,1)
linux /boot/vmlinuz-3.16.0-4-amd64 root=/dev/sda1
initrd /boot/initrd.img-3.16.0-4-amd64
boot


Thanks for the visit and Happy Linuxing :-)