The GRUB Root Command

The GRUB Root Command thumbnail
Linux's GRUB lets you manually start your computer.

The Grand Unified Bootloader, or GRUB, is software that loads and starts when you turn your computer on. UNIX, Linux and related operating systems use GRUB in the early phases of computer startup. Normally, GRUB automatically starts the computer according to its default settings, though it has a manual mode that accepts typed commands. One of these commands, “root,” selects the drive used as the operating system starts.

  1. GRUB

    • When you start a Linux or Unix computer, GRUB is the first program you see after the power-on self test. A tiny program in the computer’s BIOS ROM loads part of GRUB from the hard drive’s master boot record, or MBR. As the MBR contains only 512 bytes of information, this small piece loads the rest of GRUB from another area of the hard drive. After it has started, GRUB displays a list of operating systems present on the disk, letting you choose the one you want. GRUB uses a file called /boot/grub/menu.lst to store its menu list and related commands. Another file, /etc/grub.conf, contains statements, including root, specifying hard drives and files used to start the operating system.

    Kernel and Initrd

    • If a computer is running a Linux operating system, GRUB needs the location of its kernel, the master file containing Linux’s operating components. The menu.lst file will include a kernel command specifying the hard drive and directory where the kernel resides. The kernel command has a root option that indicates the device for the root partition, though this is different from the root command. Typically, the kernel includes the drivers, or low-level disk-access programs, needed to access the kernel’s root directory. If the disk is of an unusual type, GRUB uses an additional command, initrd, to load the drivers it needs.

    Root

    • The grub.conf file contains the GRUB root command, which configures and mounts the root partition. The command specifies the device on which the root partition is located, taking the form “root (<devicetype><devicenumber>,<partition>),” where "<devicetype>" is a drive device type, such as sd, hd or fd, for SCSI disk, hard disk or floppy disk. The "<devicenumber>" parameter is the logical number of the drive, such as 0, 1 or 2, and " <partition>" points to the partition number you wish to mount. The following command illustrates the use of root:

      root (sd0,0)

      Because these parameters vary from computer to computer, you can get a helpful hint of the correct ones by entering GRUB’s command line and typing the following command:

      find /boot/grub/stage1

    Manual Start

    • When GRUB displays its menu, it usually gives you three seconds to select an operating system; with no input from you, it will start the default selection. Instead of selecting an item from the menu, you can press “c” to enter GRUB’s command line interface. From it, you can start an operating system manually by typing a root command followed by a kernel command.

Related Searches:

References

  • Photo Credit Stockbyte/Stockbyte/Getty Images

Comments

Related Ads

Featured