GRUB - filesystem syntax and semantics

Posted in How To's by Shafkat Shahzad, M.Sc - Senior Technical Content Manager on June 20th, 2010

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on file system syntax and semantics. As GRUB uses a special syntax for specifying disk drives which can be accessed by BIOS. Because of BIOS limitations, GRUB cannot distinguish between IDE, ESDI, SCSI, or others.
A user should know which BIOS device is equivalent to which OS device. Normally, that will be clear if a user sees the files in a device or use the command find

- How to specify devices
The device syntax is like this:
(device[,part-num][,bsd-subpart-letter])
`[]’ means the parameter is optional. device should be either `fd’ or `hd’ followed by a digit, like `fd0′. But if a user can also set device to a hexadecimal or a decimal number which is a BIOS drive number, so the following are equivalent:
(hd0)
(0×80)
(128)
part-num represents the partition number of device, starting from zero for primary partitions and from four for extended partitions, and bsd-subpart-letter represents the BSD disklabel subpartition, such as `a’ or `e’.
A shortcut for specifying BSD subpartitions is (device,bsd-subpart-letter), in this case, GRUB searches for the first PC partition containing a BSD disklabel, then finds the subpartition bsd-subpart-letter. Here is an example:
(hd0,a)
The syntax `(hd0)’ represents using the entire disk (or the MBR when installing GRUB), while the syntax `(hd0,0)’ represents using the first partition of the disk (or the boot sector of the partition when installing GRUB).
If a user has enabled the network support, the special drive, `(nd)’, is also available. Before using the network drive, a user must initialise the network. See Network, for more information.
If a user boots GRUB from a CD-ROM, `(cd)’ is available.

- How to specify files
There are two ways to specify files, by absolute file name and by block list.
An absolute file name resembles a Unix absolute file name, using `/’ for the directory separator (not `\’ as in DOS). One example is `(hd0,0)/boot/grub/menu.lst’. This means the file /boot/grub/menu.lst in the first partition of the first hard disk. If a user omits the device name in an absolute file name, GRUB uses GRUB’s root device implicitly. So if a user sets the root device to, say, `(hd1,0)’ by the command root (see root), then /boot/kernel is the same as (hd1,0)/boot/kernel.

- How to specify block lists
A block list is used for specifying a file that doesn’t appear in the filesystem, like a chainloader. The syntax is [offset]+length[,[offset]+length]…. Here is an example:
0+100,200+1,300+300
This represents that GRUB should read blocks 0 through 99, block 200, and blocks 300 through 599. If a user omits an offset, then GRUB assumes the offset is zero.
Like the file name syntax, if a blocklist does not contain a device name, then GRUB uses GRUB’s root device. So (hd0,1)+1 is the same as +1 when the root device is `(hd0,1)’.

If you followed the tutorial guide then you would have learnt about filesystem syntax and semantics.

Bookmark Us
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • MisterWong
  • Netvouz
  • Reddit
  • Slashdot
  • Spurl
  • StumbleUpon
  • Technorati
  • Wists

Leave a Comment