Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Thursday, March 24, 2016 at 22:20

This is a recovery tutorial about using GRUB prompt to boot an operating system inside a hard disk drive. GRUB prompt is a program appearing at screen with black and white color, while a normal GRUB bootloader failed to be installed. GRUB prompt is similar to bash command line, usually in Terminal, but it has special commands because it is actually also the bootloader. By using GRUB prompt you can boot an operating system manually inside internal or external hard disk drive in any partition. Later, by successfully boot a GNU/Linux operating system with GRUB prompt, you may install the GRUB bootloader from the operating system.

System Summary

 

  • ASUS X44C
  • Internal hard disk drive 320 GB with 3 primary partitions.
  • External hard disk drive 320 GB with 3 primary partitions, 1 extended partition, and 6 logical partitions.
  • External hard disk drive has no GRUB bootloader (selecting bootloader), but has only GRUB prompt.

1. See Normal Prompt


GRUB prompt aways looks like this:
grub > _
It means it waits the user to enter a command.

2. See All The Hard Disk Drives


Type ls command like this:
ls
so if you have only 1 hard disk drive with 3 partitions, you will have output like this:
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1)
or if you have 2 hard disk drives with each 3 partitions, you will have output like this:
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) (hd1) (hd1,msdos3)
(hd1,msdos2) (hd1,msdos1)

or we can write the output in two lines:
(hd0) (hd0,msdos3) (hd0,msdos2) (hd0,msdos1) 
(hd1) (hd1,msdos3) (hd1,msdos2) (hd1,msdos1)

Hard disk drive: GRUB names every hard disk drive with the name format (hdd_position) then names every partition (partition_position, partition_type[partition_number]). Then (hd0) means your first hard disk drive detected by GRUB, and hd1 is your second. In GNU/Linux, we usually call them /dev/sda and /dev/sdb respectively. If your have more hard disk drives attached, you will have hd2, hd3, and afterwards.

Partition: (hd0,msdos1) is the first partition in the first hard disk. In some systems, this will be the /dev/sda1. Pay attention into the name /dev/sda for the hard disk and /dev/sda1 for the partition inside the hard disk. Notice the number following the name. Then (hd0,msdos2) and (hd0,msdos3) are /dev/sda2 and /dev/sda3 partitions inside the same hard disk respectively.
If you have more than one hard disk, then (hd1,msdos1) usually means /dev/sdb1 partition. (hd1,msdos2) and (hd1,msdos3) usually mean /dev/sdb2 and /dev/sdb3 partitions inside the same hard disk.

Msdos: The name msdos in every partition name showing that the partition is using Master Boot Record (MBR) partition table scheme. It is an old partition table from the MSDOS era so it is called simply msdos.

3. See Your OS Partition


You should remember where is your OS partition, whether it is in the first hard disk or in the second hard disk. Then after you are sure, you should be sure in what partition it is.

In our example, we want to boot the operating system inside (hd0,msdos3) or in our system in the second hard disk drive, in the /dev/sdb3 (not /dev/sda3) partition, with the operating system name Kubuntu 15.10 Wily Werewolf.

4. The First Command

 

The first command to perform is to enter the hard disk drive. We want to enter (hd0,msdos3) so we type this command:
set root=(hd0,3)
If you want to enter the first partition of hd0, the command should be:
set root=(hd0,1)
If you want to enter the second partition of hd0, the command should be:
set root=(hd0,2)

5. The Second Command

 

The second command is to call the operating system kernel to live. Because we have entered the (hd0,3) or /dev/sdb3 in our external hard disk drive, we type the command:
linux /boot/vmlinuz-4.2.0-16-generic root=/dev/sdb3
TAB: press tab button after writing /boot/vmli and GRUB will automatically complete the long name for you. It is very similar with bash shell. You don't have to type vmlinuz-4.2.0-16-generic long name manually.

PARAMETER: the second argument (root=/dev/sdb3) is a clue for the kernel to find the root operating system. You must give it correctly, otherwise you will find a kernel panic error. We've mentioned that our (hd0,msdos3) is /dev/sdb3, so we give here parameter root=/dev/sdb3.

Explanation: the format of this command is <kernel_name> <kernel_file_name> <kernel_parameter>. Because we want to boot a GNU/Linux operating system, then we use the linux as <kernel_name>, /boot/vmlinuz-4.2.0-16-generic as <kernel_file_name>, and root=dev/sdb3 as <kernel_parameter>.

6. The Third Command


The third command is to call initrd (initial ram disk) to help kernel to boot. The command is very similar:
initrd /boot/initrd.img-4.2.0-16-generic

TAB: press tab button after writing /boot/init and GRUB will automatically complete the long name for you. It is very similar with bash shell. You don't have to type long name initrd.img-4.2.0-16-generic manually same as when you type the kernel name.

7. The Fourth Command


The fourth command is to execute all three commands have typed. In another word, to boot the OS. The command is simply:
boot

8. Commands Summary


We need four simple commands to boot a GNU/Linux operating system:
set root=(hd0,3)
linux /boot/vmlinuz-4.2.0-16-generic root=/dev/sdb3
initrd /boot/initrd.img-4.2.0-16-generic
boot

9. The Result


You will see your monitor shows many line of texts output as usually you see from a normal bootloader. At the final steps, you will see your operating system is booted and ready to use.