The main task of the boot loader Grub 2 is to start the Linux kernel from the hard disk. Grub can also pass the command to other bootloaders, such as Windows, and boot systems from ISO files. This is useful, for example, for diagnostic tools or repair systems. For the investigation of the boot environment, Grub offers its own shell, via which the system can also be started manually. Operation is not very intuitive, but the Grub shell can be of great help in the event of start-up problems.
Grub usually works even if something is configured incorrectly and Linux does not start because of this. The grub shell is used to analyze the grub or boot environment. In the event of errors, you usually end up in the shell automatically. If not, hold down the Shift key after turning on the PC. You will then see the Grub menu and use the C key to access the shell.
The operation of the Grub Shell is similar to that in a terminal window of the Bash Shell under Linux. Let yourself be told what commands there are
display, followed by the Enter key. Grub uses the US keyboard layout. The table "Keyboard layout in the Grub Shell" shows where you can find the characters on a German keyboard. "Pager = 1" provides for the long list for the output of one screen page at a time, with the space bar you scroll through.
You only need a few commands to start a Linux system. With
view the partitions. Tap in
and press the Tab key. Grub then outputs "hd0 hd1" as possible devices. Suppose Linux is installed on the first partition of the first hard disk with MBR partition style. If you
type in and then press the Tab key, Grub automatically adds "ls (hd0, msdos1)" if there is only one partition. Otherwise you see information about the possible partitions, which you then have to add yourself. Add a "/" to the end of the line, then you can use the Tab key to display folders and files. You can determine the content of a folder with followed
by the tab key. This is where the Linux kernel and the associated ramdisk are located. A Linux system can be started with the following four lines:
linux /boot/vmlinuz-4.15.0-29- generic root=/dev/sd[XY] ro
initrd /boot/initrd.img-4.15.0-29 generic
Adjust the names of the files for your system, replace "/dev/sd[XY]" with the device path of the Linux installation. For "hd0, msdos1" this is "/dev/sda1", for "hd1, msdos1" use "/dev/sdb1" and so on. If the system is installed in Uefi mode, the name of the partition is, for example, "hd0, gpt2", which corresponds to "/dev/sda2" in the file system.
If Linux has been started successfully, Grub can be reinstalled in the terminal using these two command lines:
Replace "/dev/sd[X]" with the drive path of the hard disk on which the system is installed. With a Uefi system, "update-grub" is sufficient.