Archive for June, 2010

GRUB - invoking the grub shell

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

Welcome to the tutorialg guide. The tutorial will proivded a user with guidance and instructions on invoking the grub shell.

A user should note that the grub shell is an emulator; it doesn’t run under the native environment, so it sometimes does something wrong. It is advised that not to trus grub shell too much. If there is anything wrong with it, a user shouldn’t hesitate to try the native GRUB environment, especially when it guesses a wrong map between BIOS drives and OS devices.

A user can use the command grub for installing GRUB under the operating systems and for a testbed when a user adds a new feature into GRUB or when fixing a bug. grub is almost the same as the Stage 2, and, in fact, it shares the source code with the Stage 2 and a user can use the same commands in grub. It is emulated by replacing BIOS calls with UNIX system calls and libc functions.
The command grub accepts the following options:
–help
Print a summary of the command-line options and exit.
–version
Print the version number of GRUB and exit.
–verbose
Print some verbose messages for debugging purpose.
–device-map=file
Use the device map file file.
–no-floppy
Do not probe any floppy drive. This option has no effect if the option –device-map is specified.
–probe-second-floppy
Probe the second floppy drive. If this option is not specified, the grub shell does not probe it, as that sometimes takes a long time. If a user specifies the device map file, the grub shell just ignores this option.
–config-file=file
Read the configuration file file instead of /boot/grub/menu.lst. The format is the same as the normal GRUB syntax.
–boot-drive=drive
This argument should be an integer (decimal, octal or hexadecimal).
–install-partition=par
Set the stage2 install_partition to par. This argument should be an integer (decimal, octal or hexadecimal).
–no-config-file
Do not use the configuration file even if it can be read.
–no-curses
Do not use the screen handling interface by the curses even if it is available.
–batch
This option has the same meaning as `–no-config-file –no-curses’.
–read-only
Disable writing to any disk.
–hold
Wait until a debugger will attach. This option is useful when a user wants to debug the startup code.
How to install GRUB via grub
The installation procedure is the same as under the native Stage 2. An installation procedure is shown below:
Installation
In order to install GRUB as the boot loader, a user will need to first install the GRUB system and utilities under the UNIX-like operating system. This can be done either from the source tarball, or as a package for the Operating System.
After that a user will need to install the boot loader on a drive (floppy or hard disk). There are two ways of doing that - either using the utility grub-install on a UNIX-like OS, or by running GRUB itself from a floppy.
A user should note that if GRUB is installed on a UNIX-like OS, then a user should ensure that they have an emergency boot disk ready, so that a user can rescue the computer if, by any chance, the hard drive becomes unusable (unbootable).
GRUB comes with boot images, which are normally put in the directory /usr/lib/grub/i386-pc. If a user does not use grub-install, then he/she needs to copy the files stage1, stage2, and *stage1_5 to the directory /boot/grub, and run the grub-set-default if a user intends to use `default saved’ in the configuration file.
Creating a GRUB boot floppy
To create a GRUB boot floppy, as user needs to take the files stage1 and stage2 from the image directory, and write them to the first and the second block of the floppy disk, respectively.
On a UNIX-like operating system, that is done with the following commands:
# cd /usr/lib/grub/i386-pc
# dd if=stage1 of=/dev/fd0 bs=512 count=1
1+0 records in
1+0 records out
# dd if=stage2 of=/dev/fd0 bs=512 seek=1
153+1 records in
153+1 records out
#
The device file name may be different. Consult the manual for your OS.
Installing GRUB natively
GRUB can currently boot GNU Mach, Linux, FreeBSD, NetBSD, and OpenBSD directly, so using it on a boot sector (the first sector of a partition) should be alright.
If a user decides to install GRUB in the native environment, which is definitely desirable, then he/she will need to create a GRUB boot disk, and reboot the computer with it.
GRUB will show the command-line interface. First, set the GRUB’s root device to the partition containing the boot directory, like this:
grub> root (hd0,0)
If a user is not sure which partition actually holds this directory, use the command find like this:
grub> find /boot/grub/stage1
This will search for the file name /boot/grub/stage1 and show the devices which contain the file.
Once a user has set the root device correctly, run the command setup:
grub> setup (hd0)
This command will install the GRUB boot loader on the Master Boot Record (MBR) of the first drive. If a user wants to put GRUB into the boot sector of a partition instead of putting it in the MBR, specify the partition into whidch a user wants to install GRUB:
grub> setup (hd0,0)
If a user installs GRUB into a partition or a drive other than the first one, a user must chain-load GRUB from another boot loader.
After using the setup command, a user will boot into GRUB without the GRUB floppy.
The command grub-specific information is described here.
What a user should be careful about is buffer cache. grub makes use of raw devices instead of filesystems that the operating systems serve, so there exists a potential problem that some cache inconsistency may corrupt the filesystems. It is recommended that:
• If a user can unmount drives to which GRUB may write any amount of data, unmount them before running grub.
• If a drive cannot be unmounted but can be mounted with the read-only flag, mount it in read-only mode. That should be secure.
• If a drive must be mounted with the read-write flag, make sure that no activity is being done on it while the command grub is running.
• Reboot the operating system as soon as possible. This is probably not required if a user follows the rules above, but reboot is the most secure way.
In addition, enter the command quit when a user finishes the installation. That is very important because quit makes the buffer cache consistent. Do not push .
If a user wants to install GRUB non-interactively, specify `–batch’ option in the command-line. Please view example as provided:
#!/bin/sh

# Use /usr/sbin/grub if you are on an older system.
/sbin/grub –batch </dev/null 2>/dev/null
root (hd0,0)
setup (hd0)
quit
EOT
The map between BIOS drives and OS devices
When a user specifies the option –device-map, the grub shell creates the device map file automatically unless it already exists. The file name /boot/grub/device.map is preferred.
If the device map file exists, the grub shell reads it to map BIOS drives to OS devices. This file consists of lines like this:
device file
device is a drive specified in the GRUB syntax, and file is an OS file, which is normally a device file.
The reason why the grub shell gives a user the device map file is that it cannot guess the map between BIOS drives and OS devices correctly in some environments. For example, if a user wants to exchange the boot sequence between IDE and SCSI in a users BIOS, it gets the order wrong.
Thus, edit the file if the grub shell makes a mistake. A user should put any comments in the file if needed, as the grub shell assumes that a line is just a comment if the first character is `#’.
Invoking grub-install
The program grub-install installs GRUB on a users drive using the grub shell. A user must specify the device name on which a user wants to install GRUB, like this:
grub-install install_device
The device name install_device is an OS device name or a GRUB device name.
grub-install accepts the following options:
–help
Print a summary of the command-line options and exit.
–version
Print the version number of GRUB and exit.
–force-lba
Force GRUB to use LBA mode even for a buggy BIOS. Use this option only if the BIOS doesn’t work properly in LBA mode even though it supports LBA mode.
–root-directory=dir
Install GRUB images under the directory dir instead of the root directory. This option is useful when a user wants to install GRUB into a separate partition or a removable disk. Here is an example in which a user has a separate boot partition which is mounted on /boot:
grub-install –root-directory=/boot hd0

–grub-shell=file
Use file as the grub shell. A user can append arbitrary options to file after the file name, like this:
grub-install –grub-shell=”grub –read-only” /dev/fd0

–recheck
Recheck the device map, even if /boot/grub/device.map already exists. A user should use this option whenever he/she wants to add/remove a disk into/from the computer.
Invoking grub-md5-crypt
The program grub-md5-crypt encrypts a password in MD5 format. This is just a frontend of the grub shell. Passwords encrypted by this program can be used with the command password.
grub-md5-crypt accepts the following options:
–help
Print a summary of the command-line options and exit.
–version
Print the version information and exit.
–grub-shell=file
Use file as the grub shell.
Invoking grub-terminfo
The program grub-terminfo generates a terminfo command from a terminfo name. The result can be used in the configuration file, to define escape sequences. Because GRUB assumes that the terminal is vt100-compatible by default, this would be useful only if a terminal is uncommon (such as vt52).
grub-terminfo accepts the following options:
–help
Print a summary of the command-line options and exit.
–version
Print the version information and exit.
A user must specify one argument to this command. For example:
grub-terminfo vt52

Invoking grub-set-default
The program grub-set-default sets the default boot entry for GRUB. This automatically creates a file named default under the GRUB directory (i.e. /boot/grub), if it is not present.
This file is used to determine the default boot entry when GRUB boots up the system when a user uses the `default saved’ in the configuration file, and to save next default boot entry when a user uses `savedefault’ in a boot entry.
grub-set-default accepts the following options:
–help
Print a summary of the command-line options and exit.
–version
Print the version information and exit.
–root-directory=dir
Use the directory dir instead of the root directory (i.e. /) to define the location of the default file. This is useful when a user mounts a disk which is used for another system.
A user must specify a single argument to grub-set-default. This argument is normally the number of a default boot entry. For example, if a user have this configuration file:
default saved
timeout 10

title GNU/Hurd
root (hd0,0)

title GNU/Linux
root (hd0,1)

and if a user wants to set the next default boot entry to GNU/Linux, a user may execute this command:
grub-set-default 1
Because the entry for GNU/Linux is `1′. Note that entries are counted from zero. So, if a user wants to specify GNU/Hurd here, then a user should specify `0′.
This feature is very useful if a user wants to test a new kernel or to make the system quite robust.

If a user follows this tutorial guide then he/she would have learnt about invoking the grub shell.

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

GRUB - Errors reported by the Stage 1

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

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions about errors reported by the Stage 1.

The general way that the Stage 1 handles errors is to print an error string and then halt. Pressing – will reboot.
The following is a comprehensive list of error messages for the Stage 1:
Hard Disk Error
The stage2 or stage1.5 is being read from a hard disk, and the attempt to determine the size and geometry of the hard disk failed.
Floppy Error
The stage2 or stage1.5 is being read from a floppy disk, and the attempt to determine the size and geometry of the floppy disk failed. It’s listed as a separate error since the probe sequence is different than for hard disks.
Read Error
A disk read error happened while trying to read the stage2 or stage1.5.
Geom Error
The location of the stage2 or stage1.5 is not in the portion of the disk supported directly by the BIOS read calls. This could occur because the BIOS translated geometry has been changed by the user or the disk is moved to another machine or controller after installation, or GRUB was not installed using itself (if it was, the Stage 2 version of this error would have been seen during that process and it would not have completed the install).
Errors reported by the Stage 1.5
The general way that the Stage 1.5 handles errors is to print an error number in the form Error num and then halt. Pressing – will reboot.
The error numbers correspond to the errors reported by Stage 2.

Errors reported by the Stage 2
The general way that the Stage 2 handles errors is to abort the operation in question, print an error string, then (if possible) either continue based on the fact that an error occurred or wait for the user to deal with the error.
The following is a comprehensive list of error messages for the Stage 2 (error numbers for the Stage 1.5 are listed before the colon in each description):
1 : Filename must be either an absolute filename or blocklist
This error is returned if a file name is requested which doesn’t fit the syntax/rules
2 : Bad file or directory type
This error is returned if a file requested is not a regular file, but something like a symbolic link, directory, or FIFO.
3 : Bad or corrupt data while decompressing file
This error is returned if the run-length decompression code gets an internal error. This is usually from a corrupt file.
4 : Bad or incompatible header in compressed file
This error is returned if the file header for a supposedly compressed file is bad.
5 : Partition table invalid or corrupt
This error is returned if the sanity checks on the integrity of the partition table fail. This is a bad sign.
6 : Mismatched or corrupt version of stage1/stage2
This error is returned if the install command points to incompatible or corrupt versions of the stage1 or stage2. It can’t detect corruption in general, but this is a sanity check on the version numbers, which should be correct.
7 : Loading below 1MB is not supported
This error is returned if the lowest address in a kernel is below the 1MB boundary. The Linux zImage format is a special case and can be handled since it has a fixed loading address and maximum size.
8 : Kernel must be loaded before booting
This error is returned if GRUB is told to execute the boot sequence without having a kernel to start.
9 : Unknown boot failure
This error is returned if the boot attempt did not succeed for reasons which are unknown.
10 : Unsupported Multiboot features requested
This error is returned when the Multiboot features word in the Multiboot header requires a feature that is not recognized. The point of this is that the kernel requires special handling which GRUB is probably unable to provide.
11 : Unrecognized device string
This error is returned if a device string was expected, and the string encountered didn’t fit the syntax/rules listed in the Filesystem.
12 : Invalid device requested
This error is returned if a device string is recognizable but does not fall under the other device errors.
13 : Invalid or unsupported executable format
This error is returned if the kernel image being loaded is not recognized as Multiboot or one of the supported native formats (Linux zImage or bzImage, FreeBSD, or NetBSD).
14 : Filesystem compatibility error, cannot read whole file
Some of the filesystem reading code in GRUB has limits on the length of the files it can read. This error is returned when the user runs into such a limit.
15 : File not found
This error is returned if the specified file name cannot be found, but everything else (like the disk/partition info) is OK.
16 : Inconsistent filesystem structure
This error is returned by the filesystem code to denote an internal error caused by the sanity checks of the filesystem structure on disk not matching what it expects. This is usually caused by a corrupt filesystem or bugs in the code handling it in GRUB.
17 : Cannot mount selected partition
This error is returned if the partition requested exists, but the filesystem type cannot be recognized by GRUB.
18 : Selected cylinder exceeds maximum supported by BIOS
This error is returned when a read is attempted at a linear block address beyond the end of the BIOS translated area. This generally happens if a users disk is larger than the BIOS can handle (512MB for (E)IDE disks on older machines or larger than 8GB in general).
19 : Linux kernel must be loaded before initrd
This error is returned if the initrd command is used before loading a Linux kernel.
20 : Multiboot kernel must be loaded before modules
This error is returned if the module load command is used before loading a Multiboot kernel. It only makes sense in this case anyway, as GRUB has no idea how to communicate the presence of such modules to a non-Multiboot-aware kernel.
21 : Selected disk does not exist
This error is returned if the device part of a device- or full file name refers to a disk or BIOS device that is not present or not recognized by the BIOS in the system.
22 : No such partition
This error is returned if a partition is requested in the device part of a device- or full file name which isn’t on the selected disk.
23 : Error while parsing number
This error is returned if GRUB was expecting to read a number and encountered bad data.
24 : Attempt to access block outside partition
This error is returned if a linear block address is outside of the disk partition. This generally happens because of a corrupt filesystem on the disk or a bug in the code handling it in GRUB (it’s a great debugging tool).
25 : Disk read error
This error is returned if there is a disk read error when trying to probe or read data from a particular disk.
26 : Too many symbolic links
This error is returned if the link count is beyond the maximum (currently 5), possibly the symbolic links are looped.
27 : Unrecognized command
This error is returned if an unrecognized command is entered on the command-line or in a boot sequence section of a configuration file and that entry is selected.
28 : Selected item cannot fit into memory
This error is returned if a kernel, module, or raw file load command is either trying to load its data such that it won’t fit into memory or it is simply too big.
29 : Disk write error
This error is returned if there is a disk write error when trying to write to a particular disk. This would generally only occur during an install of set active partition command.
30 : Invalid argument
This error is returned if an argument specified to a command is invalid.
31 : File is not sector aligned
This error may occur only when a user accesses a ReiserFS partition by block-lists (e.g. the command install). In this case, a user should mount the partition with the `-o notail’ option.
32 : Must be authenticated
This error is returned if a user tries to run a locked entry. A user should enter a correct password before running such an entry.
33 : Serial device not configured
This error is returned if a user tries to change the terminal to a serial one before initialising any serial device.
34 : No spare sectors on the disk
This error is returned if a disk doesn’t have enough spare space. This happens when a user tries to embed Stage 1.5 into the unused sectors after the MBR, but the first partition starts right after the MBR or they are used by EZ-BIOS.

If a user follows this tutorial guide then he/she would have learnt about errors.

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

GRUB - list of available commands

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 advise and guidance on list of avalilable commands.

A user will note that the commands belong to different groups. A few can only be used in the global section of the configuration file (or “menu”); most of them can be entered on the command-line and can be used either anywhere in the menu or specifically in the menu entries.

The list of commands for the menu only
The semantics used in parsing the configuration file are the following:
• The menu-specific commands have to be used before any others.
• The files must be in plain-text format.
• `#’ at the beginning of a line in a configuration file means it is only a comment.
• Options are separated by spaces.
• All numbers can be either decimal or hexadecimal. A hexadecimal number must be preceded by `0x’, and is case-insensitive.
• Extra options or text at the end of the line are ignored unless otherwise specified.
• Unrecognized commands are added to the current entry, except before entries start, where they are ignored.
These commands can only be used in the menu:
• default: Set the default entry
• fallback: Set the fallback entry
• hiddenmenu: Hide the menu interface
• timeout: Set the timeout
• title: Start a menu entry
default
— Command: default num
Set the default entry to the entry number num. Numbering starts from 0, and the entry number 0 is the default if the command is not used.
A user can specify `saved’ instead of a number. In this case, the default entry is the entry saved with the command savedefault.
fallback
— Command: fallback num…
Go into unattended boot mode: if the default boot entry has any errors, instead of waiting for the user to do something, immediately start over using the num entry (same numbering as the default command. This obviously won’t help if the machine was rebooted by a kernel that GRUB loaded. A user can specify multiple fallback entry numbers.
hiddenmenu
— Command: hiddenmenu
Don’t display the menu. If the command is used, no menu will be displayed on the control terminal, and the default entry will be booted after the timeout expired. The user can still request the menu to be displayed by pressing before the timeout expires.
timeout
— Command: timeout sec
Set a timeout, in sec seconds, before automatically booting the default entry (normally the first entry defined).
title
— Command: title name …
Start a new boot entry, and set its name to the contents of the rest of the line, starting with the first non-space character.
The list of general commands
Commands usable anywhere in the menu and in the command-line.
• bootp: Initialize a network device via BOOTP
• color: Color the menu interface
• device: Specify a file as a drive
• dhcp: Initialize a network device via DHCP
• hide: Hide a partition
• ifconfig: Configure a network device manually
• pager: Change the state of the internal pager
• partnew: Make a primary partition
• parttype: Change the type of a partition
• password: Set a password for the menu interface
• rarp: Initialize a network device via RARP
• serial: Set up a serial device
• setkey: Configure the key map
• terminal: Choose a terminal
• terminfo: Define escape sequences for a terminal
• tftpserver: Specify a TFTP server
• unhide: Unhide a partition
bootp
— Command: bootp [–with-configfile]
Initialize a network device via the BOOTP protocol. This command is only available if GRUB is compiled with netboot support.
If a user can specify –with-configfile to this command, GRUB will fetch and load a configuration file specified by the BOOTP server with the vendor tag `150′.
color
— Command: color normal [highlight]
Change the menu colors. The color normal is used for most lines in the menu, and the color highlight is used to highlight the line where the cursor points. If a user can omit highlight, then the inverted color of normal is used for the highlighted line. The format of a color is foreground/background. foreground and background are symbolic color names. A symbolic color name must be one of these:
• black
• blue
• green
• cyan
• red
• magenta
• brown
• light-gray
These below can be specified only for the foreground.
• dark-gray
• light-blue
• light-green
• light-cyan
• light-red
• light-magenta
• yellow
• white
But only the first eight names can be used for background. A user can prefix blink- to foreground if a user wants a blinking foreground color.
This command can be used in the configuration file and on the command line, so a user can write something like this in the configuration file:
# Set default colors.
color light-gray/blue black/light-gray

# Change the colors.
title OS-BS like
color magenta/blue black/magenta

device
— Command: device drive file
In the grub shell, specify the file file as the actual drive for a BIOS drive drive. A user can use this command to create a disk image, and/or to fix the drives guessed by GRUB when GRUB fails to determine them correctly, like this:
grub> device (fd0) /floppy-image
grub> device (hd0) /dev/sd0

This command can be used only in the grub shell

dhcp
— Command: dhcp [–with-configfile]
Initialize a network device via the DHCP protocol. Currently, this command is just an alias for bootp, since the two protocols are very similar. This command is only available if GRUB is compiled with netboot support.
If a user can specify –with-configfile to this command, GRUB will fetch and load a configuration file specified by the DHCP server with the vendor tag `150′.
hide
— Command: hide partition
Hide the partition partition by setting the hidden bit in its partition type code. This is useful only when booting DOS or Windows and multiple primary FAT partitions exist in one disk.
ifconfig
— Command: ifconfig [–server=server] [–gateway=gateway] [–mask=mask] [–address=address]
Configure the IP address, the netmask, the gateway, and the server address of a network device manually. The values must be in dotted decimal format, like `192.168.11.178′. The order of the options is not important. This command shows current network configuration, if no option is specified.

pager
— Command: pager [flag]
Toggle or set the state of the internal pager. If flag is `on’, the internal pager is enabled. If flag is `off’, it is disabled. If no argument is given, the state is toggled.
partnew
— Command: partnew part type from len
Create a new primary partition. part is a partition specification in GRUB syntax; type is the partition type and must be a number in the range 0-0xff; from is the starting address and len is the length, both in sector units.
parttype
— Command: parttype part type
Change the type of an existing partition. part is a partition specification in GRUB syntax; type is the new partition type and must be a number in the range 0-0xff.
password
— Command: password [–md5] passwd [new-config-file]
If used in the first section of a menu file, disable all interactive editing control (menu entry editor and command-line) and entries protected by the command lock. If the password passwd is entered, it loads the new-config-file as a new config file and restarts the GRUB Stage 2, if new-config-file is specified. Otherwise, GRUB will just unlock the privileged instructions. A user can also use this command in the script section, in which case it will ask for the password, before continuing. The option –md5 tells GRUB that passwd is encrypted with md5crypt.
13.2.11 rarp
— Command: rarp
Initialize a network device via the RARP protocol. This command is only available if GRUB is compiled with netboot support.

serial
— Command: serial [–unit=unit] [–port=port] [–speed=speed] [–word=word] [–parity=parity] [–stop=stop] [–device=dev]
Initialize a serial device. unit is a number in the range 0-3 specifying which serial port to use; default is 0, which corresponds to the port often called COM1. port is the I/O port where the UART is to be found; if specified it takes precedence over unit. speed is the transmission speed; default is 9600. word and stop are the number of data bits and stop bits. Data bits must be in the range 5-8 and stop bits must be 1 or 2. Default is 8 data bits and one stop bit. parity is one of `no’, `odd’, `even’ and defaults to `no’. The option –device can only be used in the grub shell and is used to specify the tty device to be used in the host operating system.
The serial port is not used as a communication channel unless the terminal command is used.
This command is only available if GRUB is compiled with serial support.
setkey
— Command: setkey [to_key from_key]
Change the keyboard map. The key from_key is mapped to the key to_key. If no argument is specified, reset key mappings. Note that this command does not exchange the keys. If a user wants to exchange the keys, run this command again with the arguments exchanged, like this:
grub> setkey capslock control
grub> setkey control capslock

A key must be an alphabet letter, a digit, or one of these symbols: `escape’, `exclam’, `at’, `numbersign’, `dollar’, `percent’, `caret’, `ampersand’, `asterisk’, `parenleft’, `parenright’, `minus’, `underscore’, `equal’, `plus’, `backspace’, `tab’, `bracketleft’, `braceleft’, `bracketright’, `braceright’, `enter’, `control’, `semicolon’, `colon’, `quote’, `doublequote’, `backquote’, `tilde’, `shift’, `backslash’, `bar’, `comma’, `less’, `period’, `greater’, `slash’, `question’, `alt’, `space’, `capslock’, `FX’ (`X’ is a digit), and `delete’. This table describes to which character each of the symbols corresponds:
`exclam’
`!’
`at’
`@’
`numbersign’
`#’
`dollar’
`$’
`percent’
`%’
`caret’
`^’
`ampersand’
`&’
`asterisk’
`*’
`parenleft’
`(’
`parenright’
`)’
`minus’
`-’
`underscore’
`_’
`equal’
`=’
`plus’
`+’
`bracketleft’
`[’
`braceleft’
`{’
`bracketright’
`]’
`braceright’
`}’
`semicolon’
`;’
`colon’
`:’
`quote’
`”
`doublequote’
`”‘
`backquote’
“’
`tilde’
`~’
`backslash’
`\’
`bar’
`|’
`comma’
`,’
`less’
`’
`slash’
`/’
`question’
`?’
`space’
` ‘
terminal
— Command: terminal [–dumb] [–no-echo] [–no-edit] [–timeout=secs] [–lines=lines] [–silent] [console] [serial] [hercules]
Select a terminal for user interaction. The terminal is assumed to be VT100-compatible unless –dumb is specified. If both console and serial are specified, then GRUB will use the one where a key is entered first or the first when the timeout expires. If neither are specified, the current setting is reported. This command is only available if GRUB is compiled with serial support.
This may not make sense for most users, but GRUB supports Hercules console as well. Hercules console is usable like the ordinary console, and the usage is quite similar to that for serial terminals: specify hercules as the argument.
The option –lines defines the number of lines in the terminal, and it is used for the internal pager function. If a user don’t specify this option, the number is assumed as 24.
The option –silent suppresses the message to prompt the user to hit any key. This might be useful if the system has no terminal device.
The option –no-echo has GRUB not to echo back input characters. This implies the option –no-edit.
The option –no-edit disables the BASH-like editing feature.
terminfo
— Command: terminfo –name=name –cursor-address=seq [–clear-screen=seq] [–enter-standout-mode=seq] [–exit-standout-mode=seq]
Define the capabilities of the terminal. Use this command to define escape sequences, if it is not vt100-compatible. A user can use `\e’ for and `^X’ for a control character.
A user can use the utility grub-terminfo to generate appropriate arguments to this command.
If no option is specified, the current settings are printed.
tftpserver
— Command: tftpserver ipaddr
Please note that this command exists only for backward compatibility. A user can use ifconfig instead.
Override a TFTP server address returned by a BOOTP/DHCP/RARP server. The argument ipaddr must be in dotted decimal format, like `192.168.0.15′. This command is only available if GRUB is compiled with netboot support. See also

13.2.17 unhide
— Command: unhide partition
Unhide the partition partition by clearing the hidden bit in its partition type code. This is useful only when booting DOS or Windows and multiple primary partitions exist on one disk.
The list of command-line and menu entry commands
These commands are usable in the command-line and in menu entries. If a user forgets a command, a user can run the command help.
• blocklist: Get the block list notation of a file
• boot: Start up your operating system
• cat: Show the contents of a file
• chainloader: Chain-load another boot loader
• cmp: Compare two files
• configfile: Load a configuration file
• debug: Toggle the debug flag
• displayapm: Display APM information
• displaymem: Display memory configuration
• embed: Embed Stage 1.5
• find: Find a file
• fstest: Test a filesystem
• geometry: Manipulate the geometry of a drive
• halt: Shut down your computer
• help: Show help messages
• impsprobe: Probe SMP
• initrd: Load an initrd
• install: Install GRUB
• ioprobe: Probe I/O ports used for a drive
• kernel: Load a kernel
• lock: Lock a menu entry
• makeactive: Make a partition active
• map: Map a drive to another
• md5crypt: Encrypt a password in MD5 format
• module: Load a module
• modulenounzip: Load a module without decompression
• pause: Wait for a key press
• quit: Exit from the grub shell
• reboot: Reboot your computer
• read: Read data from memory
• root: Set GRUB’s root device
• rootnoverify: Set GRUB’s root device without mounting
• savedefault: Save current entry as the default entry
• setup: Set up GRUB’s installation automatically
• testload: Load a file for testing a filesystem
• testvbe: Test VESA BIOS EXTENSION
• uppermem: Set the upper memory size
• vbeprobe: Probe VESA BIOS EXTENSION

blocklist
— Command: blocklist file
Print the block list notation of the file file.
boot
— Command: boot
Boot the OS or chain-loader which has been loaded. Only necessary if running the fully interactive command-line (it is implicit at the end of a menu entry).
cat
— Command: cat file
Display the contents of the file file. This command may be useful to remind a user of the OS’s root partition:
grub> cat /etc/fstab
chainloader
— Command: chainloader [–force] file
Load file as a chain-loader. Like any other file loaded by the filesystem code, it can use the blocklist notation to grab the first sector of the current partition with `+1′. If a user can specify the option –force, then load file forcibly, whether it has a correct signature or not. This is required when a user wants to load a defective boot loader, such as SCO UnixWare 7.1
cmp
— Command: cmp file1 file2
Compare the file file1 with the file file2. If they differ in size, print the sizes like this:
Differ in size: 0×1234 [foo], 0×4321 [bar]

If the sizes are equal but the bytes at an offset differ, then print the bytes like this:
Differ at the offset 777: 0xbe [foo], 0xef [bar]

If they are completely identical, nothing will be printed.
configfile
— Command: configfile file
Load file as a configuration file.
debug
— Command: debug
Toggle debug mode (by default it is off). When debug mode is on, some extra messages are printed to show disk activity. This global debug flag is mainly useful for GRUB developers when testing new code.
displayapm
— Command: displayapm
Display APM BIOS information.
displaymem
— Command: displaymem
Display what GRUB thinks the system address space map of the machine is, including all regions of physical RAM installed. GRUB’s upper/lower memory display uses the standard BIOS interface for the available memory in the first megabyte, or lower memory, and a synthesized number from various BIOS interfaces of the memory starting at 1MB and going up to the first chipset hole for upper memory (the standard PC upper memory interface is limited to reporting a maximum of 64MB).
embed
— Command: embed stage1_5 device
Embed the Stage 1.5 stage1_5 in the sectors after the MBR if device is a drive, or in the boot loader area if device is a FFS partition or a ReiserFS partition.9 Print the number of sectors which stage1_5 occupies, if successful.
Usually, a user doesn’t need to run this command directly.

find
— Command: find filename
Search for the file name filename in all mountable partitions and print the list of the devices which contain the file. The file name filename should be an absolute file name like /boot/grub/stage1.
fstest
— Command: fstest
Toggle filesystem test mode. Filesystem test mode, when turned on, prints out data corresponding to all the device reads and what values are being sent to the low-level routines. The format is `’ for high-level reads inside a partition, and `[disk-offset-sector]’ for low-level sector requests from the disk. Filesystem test mode is turned off by any use of the install (see install) or testload (see testload) commands.
geometry
— Command: geometry drive [cylinder head sector [total_sector]]
Print the information for the drive drive. In the grub shell, a user can set the geometry of the drive arbitrarily. The number of cylinders, the number of heads, the number of sectors and the number of total sectors are set to CYLINDER, HEAD, SECTOR and TOTAL_SECTOR, respectively. If a user omits TOTAL_SECTOR, then it will be calculated based on the C/H/S values automatically.

halt
— Command: halt –no-apm
The command halts the computer. If the –no-apm option is specified, no APM BIOS call is performed. Otherwise, the computer is shut down using APM.
help
— Command: help –all [pattern …]
Display helpful information about builtin commands. If a user does not specify pattern, this command shows short descriptions of most of available commands. If a user specifies the option –all to this command, short descriptions of rarely used commands are displayed as well.
If a user specifies any patterns, it displays longer information about each of the commands which match those patterns.

impsprobe
— Command: impsprobe
Probe the Intel Multiprocessor Specification 1.1 or 1.4 configuration table and boot the various CPUs which are found into a tight loop. This command can be used only in the Stage 2, but not in the grub shell.
initrd
— Command: initrd file …
Load an initial ramdisk for a Linux format boot image and set the appropriate parameters in the Linux setup area in memory.

install
— Command: install [–force-lba] [–stage2=os_stage2_file] stage1_file [d] dest_dev stage2_file [addr] [p] [config_file] [real_config_file]
This command is fairly complex, and a user should not use this command unless a user is familiar with GRUB. Use setup instead.
In short, it will perform a full install presuming the Stage 2 or Stage 1.5 is in its final install location.
In slightly more detail, it will load stage1_file, validate that it is a GRUB Stage 1 of the right version number, install in it a blocklist for loading stage2_file as a Stage 2. If the option d is present, the Stage 1 will always look for the actual disk stage2_file was installed on, rather than using the booting drive. The Stage 2 will be loaded at address addr, which must be `0×8000′ for a true Stage 2, and `0×2000′ for a Stage 1.5. If addr is not present, GRUB will determine the address automatically. It then writes the completed Stage 1 to the first block of the device dest_dev. If the options p or config_file are present, then it reads the first block of stage2, modifies it with the values of the partition stage2_file was found on (for p) or places the string config_file into the area telling the stage2 where to look for a configuration file at boot time. Likewise, if real_config_file is present and stage2_file is a Stage 1.5, then the Stage 2 config_file is patched with the configuration file name real_config_file. This command preserves the DOS BPB (and for hard disks, the partition table) of the sector the Stage 1 is to be installed into.
ioprobe
— Command: ioprobe drive
Probe I/O ports used for the drive drive. This command will list the I/O ports on the screen. For technical information.
kernel
— Command: kernel [–type=type] [–no-mem-option] file …
Attempt to load the primary boot image (Multiboot a.out or ELF, Linux zImage or bzImage, FreeBSD a.out, NetBSD a.out, etc.) from file. The rest of the line is passed verbatim as the kernel command-line. Any modules must be reloaded after using this command.
This command also accepts the option –type so that a user can specify the kernel type of file explicitly. The argument type must be one of these: `netbsd’, `freebsd’, `openbsd’, `linux’, `biglinux’, and `multiboot’. However, a user needs to specify it only if a user wants to load a NetBSD ELF kernel, because GRUB can automatically determine a kernel type in the other cases, quite safely.
The option –no-mem-option is effective only for Linux. If the option is specified, GRUB doesn’t pass the option mem= to the kernel. This option is implied for Linux kernels 2.4.18 and newer.
lock
— Command: lock
Prevent normal users from executing arbitrary menu entries. A user must use the command password if a user really wants this command to be useful.
This command is used in a menu, as shown in this example:
title This entry is too dangerous to be executed by normal users
lock
root (hd0,a)
kernel /no-security-os

makeactive
— Command: makeactive
Set the active partition on the root disk to GRUB’s root device. This command is limited to primary PC partitions on a hard disk.
map
— Command: map to_drive from_drive
Map the drive from_drive to the drive to_drive. This is necessary when a user chain-load some operating systems, such as DOS, if such an OS resides at a non-first drive. Here is an example:
grub> map (hd0) (hd1)
grub> map (hd1) (hd0)

md5crypt
— Command: md5crypt
Prompt to enter a password, and encrypt it in MD5 format. The encrypted password can be used with the command password

module
— Command: module file …
Load a boot module file for a Multiboot format boot image (no interpretation of the file contents are made, so the user of this command must know what the kernel in question expects). The rest of the line is passed as the module command-line, like the kernel command. A user must load a Multiboot kernel image before loading any module.
modulenounzip
— Command: modulenounzip file …

pause
— Command: pause message …
Print the message, then wait until a key is pressed. Note that placing (ASCII code 7) in the message will cause the speaker to emit the standard beep sound, which is useful when prompting the user to change floppies.
quit
— Command: quit
Exit from the grub shell grub. This command can be used only in the grub shell.
reboot
— Command: reboot
Reboot the computer.
read
— Command: read addr
Read a 32-bit value from memory at address addr and display it in hex format.
root
— Command: root device [hdbias]
Set the current root device to the device device, then attempt to mount it to get the partition size (for passing the partition descriptor in ES:ESI, used by some chain-loaded boot loaders), the BSD drive-type (for booting BSD kernels using their native boot format), and correctly determine the PC partition where a BSD sub-partition is located. The optional hdbias parameter is a number to tell a BSD kernel how many BIOS drive numbers are on controllers before the current one. For example, if there is an IDE disk and a SCSI disk, and a users FreeBSD root partition is on the SCSI disk, then use a `1′ for hdbias.
rootnoverify
— Command: rootnoverify device [hdbias]
Similar to root, but don’t attempt to mount the partition. This is useful for when an OS is outside of the area of the disk that GRUB can read, but setting the correct root device is still desired. Note that the items mentioned in root above which derived from attempting the mount will not work correctly.
savedefault
— Command: savedefault num
Save the current menu entry or num if specified as a default entry. Here is an example:
default saved
timeout 10

title GNU/Linux
root (hd0,0)
kernel /boot/vmlinuz root=/dev/sda1 vga=ext
initrd /boot/initrd
savedefault

title FreeBSD
root (hd0,a)
kernel /boot/loader
savedefault

With this configuration, GRUB will choose the entry booted previously as the default entry.
A user can specify `fallback’ instead of a number. Then, next fallback entry is saved. Next fallback entry is chosen from fallback entries. Normally, this will be the first entry in fallback ones.
setup
— Command: setup [–force-lba] [–stage2=os_stage2_file] [–prefix=dir] install_device [image_device]
Set up the installation of GRUB automatically. This command uses the more flexible command install in the backend and installs GRUB into the device install_device. If image_device is specified, then find the GRUB images in the device image_device, otherwise use the current root device, which can be set by the command root. If install_device is a hard disk, then embed a Stage 1.5 in the disk if possible.
The option –prefix specifies the directory under which GRUB images are put. If it is not specified, GRUB automatically searches them in /boot/grub and /grub.
The options –force-lba and –stage2 are just passed to install if specified.
testload
— Command: testload file
Read the entire contents of file in several different ways and compare them, to test the filesystem code. The output is somewhat cryptic, but if no errors are reported and the final `i=X, filepos=Y’ reading has X and Y equal, then it is definitely consistent, and very likely works correctly subject to a consistent offset error. If this test succeeds, then a good next step is to try loading a kernel.
testvbe
— Command: testvbe mode
Test the VESA BIOS EXTENSION mode mode. This command will switch user video card to the graphics mode, and show an endless animation. Hit any key to return.
uppermem
— Command: uppermem kbytes
Force GRUB to assume that only kbytes kilobytes of upper memory are installed. Any system address range maps are discarded.
Caution: This should be used with great caution, and should only be necessary on some old machines. GRUB’s BIOS probe can pick up all RAM on all new machines the author has ever heard of. It can also be used for debugging purposes to lie to an OS.
vbeprobe
— Command: vbeprobe [mode]
Probe VESA BIOS EXTENSION information. If the mode mode is specified, show only the information about mode. Otherwise, this command lists up available VBE modes on the screen.

If user followed the tutorial guide then he/she would have learnt about list of available commands.

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

GRUB’s user interface

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

Welcome to the tutorial guide. The guide will proivde a user with guidance and instructions on users interface.

A user will note that GRUB has both a simple menu interface for choosing preset entries from a configuration file, and a highly flexible command-line for performing any desired combination of boot commands. GRUB looks for its configuration file as soon as it is loaded. If one is found, then the full menu interface is activated using whatever entries were found in the file. If a user chooses the command-line menu option, or if the configuration file was not found, then GRUB drops to the command-line interface.

The flexible command-line interface
The command-line interface provides a prompt and after it an editable text area much like a command-line in Unix or DOS. Each command is immediately executed after it is entered. A user will note that the commands are a subset of those available in the configuration file, used with exactly the same syntax.

Cursor movement and editing of the text on the line can be done via a subset of the functions available in the Bash shell:

Move forward one character.

Move back one character.

Move to the start of the line.

Move the the end of the line.


Delete the character underneath the cursor.

Delete the character to the left of the cursor.

Kill the text from the current cursor position to the end of the line.

Kill backward from the cursor to the beginning of the line.

Yank the killed text back into the buffer at the cursor.

Move up through the history list.

Move down through the history list.
When typing commands interactively, if the cursor is within or before the first word in the command-line, pressing the key (or ) will display a listing of the available commands, and if the cursor is after the first word, the will provide a completion listing of disks, partitions, and file names depending on the context. Note that to obtain a list of drives, one must open a parenthesis, as root (.
Please note that a user cannot use the completion functionality in the TFTP filesystem. This is because TFTP doesn’t support file name listing for the security.

The simple menu interface
The menu interface is quite easy to use. Its commands are both reasonably intuitive.
Basically, the menu interface provides a list of boot entries to the user to choose from. Use the arrow keys to select the entry of choice, then press to run it. An optional timeout is available to boot the default entry (the first one if not set), which is aborted by pressing any key.
Commands are available to enter a bare command-line by pressing (which operates exactly like the non-config-file version of GRUB, but allows one to return to the menu if desired by pressing ) or to edit any of the boot entries by pressing .
If a user wants to protect the menu interface with a password, all a user can do is choose an entry by pressing , or press

to enter the password.
Editing a menu entry
The menu entry editor looks much like the main menu interface, but the lines in the menu are individual commands in the selected entry instead of entry names.
If an is pressed in the editor, it aborts all the changes made to the configuration entry and returns to the main menu interface.
When a particular line is selected, the editor places the user in a special version of the GRUB command-line to edit that line. When the user hits , GRUB replaces the line in question in the boot entry with the changes (unless it was aborted via , in which case the changes are thrown away).
If a user wants to add a new line to the menu entry, press if adding a line after the current line or press if before the current line.
To delete a line, hit the key . Although GRUB unfortunately does not support undo, a user can do almost the same thing by just returning to the main menu.
The hidden menu interface
When the terminal is dumb or a user has requested GRUB to hide the menu interface explicitly with the command hiddenmenu, GRUB doesn’t show the menu interface and automatically boots the default entry, unless interrupted by pressing .
When a user interrupts the timeout and the terminal is dumb, GRUB falls back to the command-line interface.

If a user followed the tutorial guide then he/she would have learnt about GRUB’s user interface.

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

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

GRUB image files

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

Welcome to the tutorial guide. The tutorial will provide a user with advise and guidance on GRUB image files. Please note that it consists of several images: two essential stages, optional stages called Stage 1.5, one image for bootable CD-ROM, and two network boot images.

stage1
This is an essential image used for booting up GRUB. Usually, this is embedded in an MBR or the boot sector of a partition. Because a PC boot sector is 512 bytes, the size of this image is exactly 512 bytes.
All stage1 must do is to load Stage 2 or Stage 1.5 from a local disk. Because of the size restriction, stage1 encodes the location of Stage 2 (or Stage 1.5) in a block list format, so it never understand any filesystem structure.

stage2
This is the core image of GRUB. It does everything but booting up itself. Usually, this is put in a filesystem, but that is not required.
e2fs_stage1_5
fat_stage1_5
ffs_stage1_5
jfs_stage1_5
minix_stage1_5
reiserfs_stage1_5
vstafs_stage1_5
xfs_stage1_5

These are called Stage 1.5, because they serve as a bridge between stage1 and stage2, that is to say, Stage 1.5 is loaded by Stage 1 and Stage 1.5 loads Stage 2. The difference between stage1 and *_stage1_5 is that the former doesn’t understand any filesystem while the latter understands one filesystem (e.g. e2fs_stage1_5 understands ext2fs). A user can now move the Stage 2 image to another location safely, even after GRUB has been installed.
As the stage 2 cannot generally be embedded in a fixed area as the size is so large, so Stage 1.5 can be installed into the area right after an MBR, or the boot loader area of a ReiserFS or a FFS.
stage2_eltorito

This is a boot image for CD-ROMs using the no emulation mode in El Torito specification. This is identical to Stage 2, except that this boots up without Stage 1 and sets up a special drive `(cd)’.

nbgrub
This is a network boot image for the Network Image Proposal used by some network boot loaders, such as Etherboot. This is mostly the same as Stage 2, but it also sets up a network and loads a configuration file from the network.

pxegrub
This is another network boot image for the Preboot Execution Environment used by several Netboot ROMs. This is identical to nbgrub, except for the format.

If a user followed this tutorial guide then he/she will learn about GRUB image files.

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

GRUB – improving security of GRUB

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

Welcome to the tutorial guide. The tutorial will provide a user with guidance and instructions on how to improve security of GRUB.

As a user has got an opportunity provided by GRUB to modify its configuration and run arbitrary commands at run-time. An example will explaint this. If a user can read /etc/passwd in the command-line interface by the command cat, then it is necessary to disable all the interactive operations.
GRUB provides a password feature, so that only administrators can start the interactive operations. Please note that interactive operations include editing menu entries and entering the command-line interface. If a user wants to use this feature then he/she will need to run the command password in his/her configuration file. This is as displayed below:
password –md5 PASSWORD
If this is specified, GRUB will disallow interactive control, until a user presses the key

and enter a correct password. The option –md5 tells GRUB that `PASSWORD’ is in MD5 format. If it is omitted, GRUB assumes the `PASSWORD’ is in clear text.
A user can encrypt his/her password with the command md5crypt. For example, a user can run the grub shell and enter his/her password:
grub> md5crypt
Password: ***
Encrypted: $1$U$JK7xFegdxWH6VuppCUSIb.
After that a user can then cut and paste the encrypted password to the configuration file.
A user can also specify an optional argument to password. An example is profvied below:
password PASSWORD /boot/grub/menu-admin.lst
A user should now see that GRUB will load /boot/grub/menu-admin.lst as a configuration file when a user enters the valid password.

There is another issue which should be taken into account. If any user can choose any menu entry and wants to permit only administrators to run some of the menu entries, such as an entry for booting an insecure OS like DOS.

GRUB provides the command lock. This command always fails until as user enters the valid password. A user can use it as provided below:
title Boot DOS
lock
rootnoverify (hd0,1)
makeactive
chainload +1

A user should insert lock right after title, because any user can execute commands in an entry until GRUB encounters lock.

A user can also use the command password instead of lock. As the boot process will ask for the password and stop if it was entered incorrectly. Since the password takes its own PASSWORD argument this is useful if a user wants different passwords for different entries.
If you followed this tutorial guide then he/she would have learnt about how to improve security of GRUB.

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

GRUB - embedding a configuration file into GRUB

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

Welcome to the tutorial guide. The tutorial will provide a user wigh guidance and instructions on embedding a configuraiton file into GRUB. Please note that GRUB supports a preset menu which is always loaded before starting. The preset menu feature is useful. An example will help. When a users computer has no console but a serial cable, in this case, it is critical to set up the serial terminal as soon as possible. This is because a user cannot see any message until the serial terminal begins to work. It is a good idea if a user runs the commands serial and terminal before anything else at the start-up time.

Let’s see how the preset menu works:
1. GRUB checks if the preset menu feature is used, and loads the preset menu, if available. This includes running commands and reading boot entries, like an ordinary configuration file.
2. GRUB checks if the configuration file is available. A user should note that this check is performed regardless of the existence of the preset menu. The configuration file is loaded even if the preset menu was loaded.
3. If the preset menu includes any boot entries, they are cleared when the configuration file is loaded. It doesn’t matter whether the configuration file has any entries or no entry. The boot entries in the preset menu are used only when GRUB fails in loading the configuration file.
In order to enable the preset menu feature, a user must rebuild GRUB specifying a file to the configure script with the option –enable-preset-menu. The file has the same semantics as normal configuration files.
There is another thing that a user should be aware of is that the diskless support diverts the preset menu. Diskless images embed a preset menu to execute the command bootp automatically, unless a user specifies his/her own preset menu to the configure script. A user must put commands to initialise a network in the preset menu, because diskless images don’t set it up implicitly, when a user would use the preset menu explicitly.

Therefore, a typical preset menu used with diskless support would be like this:
# Set up the serial terminal, first of all.
serial –unit=0 –speed=19200
terminal –timeout=0 serial

# Initialize the network.
Dhcp

If a user followed this tutorial guide then he/she would have learnt about embedding a configuration file into GRUB.

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

GRUB - using GRUB via a serial line

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

Welcome to the tutorial guide. The tutorial will provide a user with guidance and insturctions on using GRUB thorugh a serial line.

If a user has many computers or computers with no display/keyboard, it could be very useful to control the computers through serial communications. If a user wants to connect one computer with another via a serial line, then he/she will need to prepare a null-modem (cross) serial cable. A user may also need to have multiport serial boards, if his/her computer doesn’t have extra serial ports. In addition, a terminal emulator is also required, such as minicom.

As for GRUB, the instruction to set up a serial terminal is quite simple. A user should ensure that he/she has not specified the option –disable-serial to the configure script when he/she has built his/her GRUB images. If a user will get them in binary form, probably he/she will have serial terminal support already.

Now a user can initialise his.her serial terminal after GRUB starts up. An example will explain this:
grub> serial –unit=0 –speed=9600
grub> terminal serial

The command serial initialises the serial unit 0 with the speed 9600bps. The serial unit 0 is usually called `COM1′, so, if a user wants to use COM2, then he/she must specify `–unit=1′ instead. This command accepts many other options.

Please note that the command terminal chooses which type of terminal that a user wants to use. In the case above, the terminal will be a serial terminal, but a user can also pass console to the command, as `terminal serial console’. In this case, a terminal in which a user will press any key will be selected as a GRUB terminal.

A user should note that GRUB assumes that a users terminal emulator is compatible with VT100 by default. This is true for most terminal emulators, but a user should pass the option –dumb to the command if his/her terminal emulator is not VT100-compatible or implements few VT100 escape sequences. If a user specifies this option then GRUB will provide a user with an alternative menu interface, because the normal menu requires several fancy features of the terminal.
If a user followed this tutorial guide then he/she would have learnt about using GRUB via a serial line.

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

GRUB - downloading OS images from a network

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

Welcome to the tutorial guide. The guide will provide a user with guidance and instructions on how to download OS images from a network.

As GRUB is a disk-based boot loader, so it provides a network support. In order to use the network support, a user will need to enable at least one network driver in the GRUB build process.

How to set up the network
As a user will note that GRUB requires a file server and optionally a server that will assign an IP address to the machine on which GRUB is running. Please note that for for the former, only TFTP is supported at the moment. The latter is either BOOTP, DHCP or a RARP server. A user will note that it is not necessary to run both the servers on a single computer.

If a user wants to use a server to assign an IP address, and set up the server and run bootp, dhcp or rarp for BOOTP, DHCP or RARP. Each command will show an assigned IP address, a netmask, an IP address for the TFTP server and a gateway. If any of the addresses is wrong or it causes an error, then a user will note that the configuration of servers isn’t set up properly.

A user can run ifconfig, like this:
grub> ifconfig –address=192.168.110.23 –server=192.168.110.14
A user can also use ifconfig in conjuction with bootp, dhcp or rarp. Finally, a user can download the OS images from the network. The network can be accessed using the network drive `(nd)’. An example is provided below:
grub> bootp
Probing… [NE*000]
NE2000 base …
Address: 192.168.110.23 Netmask: 255.255.255.0
Server: 192.168.110.14 Gateway: 192.168.110.1

grub> root (nd)
grub> kernel /tftproot/gnumach.gz root=sd0s1
grub> module /tftproot/serverboot.gz
grub> boot

Booting from a network
It is sometimes very useful to boot from a network, especially when a user will use a machine which has no local disk. Please note that a user will need to obtain a kind of Net Boot ROM, such as a PXE ROM or a free software package like Etherboot. A user will note that such a Boot ROM first boots the machine, sets up the network card installed into the machine, and downloads a second stage boot image from the network. Then, the second image will try to boot an operating system actually from the network.

GRUB provides two second stage images, nbgrub and pxegrub and these images are the same as the normal Stage 2, except that they set up a network automatically, and try to load a configuration file from the network, if specified. The usage is very simple: If the machine has a PXE ROM, use pxegrub. If the machine has an NBI loader such as Etherboot, use nbgrub. There is no difference between them except their formats. Since the way to load a second stage image a user will want to use should be described in the manual on the Net Boot ROM.

It is good that a user knows how to specify a configuration file in a BOOTP/DHCP server. For now, GRUB uses the tag `150′, to get the name of a configuration file. The following is an example with a BOOTP configuration:
.allhost:hd=/tmp:bf=null:\
:ds=145.71.35.1 145.71.32.1:\
:sm=255.255.254.0:\
:gw=145.71.35.1:\
:sa=145.71.35.5:

foo:ht=1:ha=63655d0334a7:ip=145.71.35.127:\
:bf=/nbgrub:\
:tc=.allhost:\
:T150=”(nd)/tftpboot/menu.lst.foo”:

A user should specify the drive name (nd) in the name of the configuration file. This is because a user would might change the root drive before downloading the configuration from the TFTP server when the preset menu feature is used.

If a user followed this tutorial guide then he/she would have learnt about downloading OS images from a network.

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

« Previous entries