![]() |
GRUB CLI Mode |
| GRUB's Command Line Interface (CLI) is one of GRUB's most useful and powerful features. GRUB is actually a miniature operating system in its own right and it can take a rich variety of commands and provide useful feedback to the user. GRUB's CLI Mode is one thing that sets GRUB head and shoulders above all other boot loaders or boot managers. |
| GNU GRUB is a work in progress and the information in this website is incomplete and may be wrong and/or out of date. Please consult the official GNU GRUB 1.98-r2692 manual. |
Your computer should automatically boot into GRUB's Menu mode if you had another operating system in the computer before you installed Ubuntu. The /boot/grub/grub.cfg is the configuration file for the GRUB Menu. It contains the settings which determine the GRUB Menu's appearance and behaviour. You need to have a grub.cfg to have a GRUB Menu. If there is no grub.cfg or if GRUB can't find it, you will be given a CLI mode GRUB prompt instead of a Menu. How to enter 'CLI Mode'. Simply press your 'c' key from your GRUB Menu to switch into 'CLI Mode'. CLI Mode
Keyboard Shortcuts
915resolution Usage: 915resolution Intel VBE editor
You probably need to insert the 915resolution module before you can use 915resolution, see insmod. acpi Useage: acpi [-1 | -2] [ --exclude=table1,table2|--load-only=table1,table2] filename1 [filename2] [...] Load host acpi tables and tables specified by arguements
ACPI is an acronym for 'Advanced Configuration and Power Interface', ACPI - Wikipedia link background_image - Load a background image for the active terminal in one of the following formats : [gfxterm]
For some types of image files we may need to insert a module to enable GRUB to use a particular file format before loading the file. For example, we need to load the jpeg module before loading a .jpg image. See the insmod command. For image files larger than the default 648x480 we would also probably want to check what screen resolutions we can use first with vbeinfo and set the screen resolution with the set command. GRUB might only display the top right-hand corner of the image if the image file is too large for the display settings. It's possible to look at images located anywhere in the file system. To get rid of a background image and have an empty background so you can see your text properly, just type the background_image command without any arguments,
For more on background images, see: Splashimages for GRUB2 blocklist blocklist FILE - find a file's physical location on a disk (sectors) example
A blocklist is useful for describing the physical location of code or data on a disk, especially when this code may be located in 'raw' areas of the disk, not addressed by any file system. A simple example of a blocklist would be: (hd0)0+1 , that would indicate the beginning of sector 0 (zero), and the space following it for 1 (one) sector. Very often that's shortened to '(hd0)+1', and the zero in implied. However, when you want to specify a number of sectors that doesn't begin at the start of a device or partition, you need to tell GRUB what sector to start looking at, and the number of sectors following it that you want to refer to. Blocklist format is already explained pretty well in the GNU GRUB (Legacy) Manual, 13.3.1 blocklist - GNU GRUB Manual 0.97. badram Usage: badram ADDR1,MASK1[ADDR2,MASK2[,...]] declare memory regions as bad ram boot - Actually boot the specified operating system (You should specify the kernel and module first, then issue the boot command last). This command is implicit (implied) at the end of grub.cfg menu entries. bsd - Load an openbsd kernel. cat cat FILE - Show the contents of a file. FILE can be an absolute filename or a blocklist example 1
(This one is a stupid example because it just makes a lot of text scroll up the screen, too fast to read, but it demonstrates one way to use the blocklist command. I'll think of a better example later). example 2
example 3
It would be faster to use the 'search' command if you know your file system LABELS. TIP: If you want to use the cat command to read large files, try using the set command and set pager=1 so you can control the text and stop it from scrolling too fast. chainloader chainloader FILE - chainload a device - syntax: chainloader (hd0) Prepare to boot another boot loader. [chain] -f, --force : force chainloading, ignoring invalid partition signature (!= 0xaa55). example:
Remember, FILE can be an absolute filename or a blocklist. This command may not won't work if you specify an empty sector or file, or if the code in that file is corrupted or somehow incompatible. There needs to be some boot loader code in the file or device (sector) you specify. If it doesn't work, try a different file or sector or try loading the kernel and initrd.img directly. Here's an example of a chainloader command in action,
clear When your screen is filled up with text and it's looking rather messy, you can use the clear command to quickly empty it and return you to a fresh, clean blank screen with your grub> _ prompt at the top. cmp cmp FILE1 FILE2 ........................................ - compares file1 with file2 FILE can be an absolute path and filename or a blocklist. example 1
configfile configfile FILE ...... - load a grub.cfg file - make convenient use of the commands and information already typed into the file - You would likely need to use the search command to find a /boot/grub/grub.cfg first. If successful, GRUB will present the boot menu from the grub.cfg and you can utilize the commands already there to boot any operating system listed. This will only work if the other operating system's configuration file is compatible with GRUB2. If not, you should try the chainloader command, or a direct boot approach instead.
cpuid cpuid ............................................................. - Check for CPU features. Running 'cpuid -h' will list the available CPUID tests. Currently the only available test is -l (long-mode) - check for long mode flag. example use,
crc Usage: crc FILE Calculate the crc32 checksum of a file You probably need to insert the crc module before you can use crc, see insmod. date Usage: date [[year-] month-day] [hour:minute[:second]] Command to display/set current datetime This commands tells you the current date and time according to the motherboard's BIOS clock. example,
drivemap Usage: drivemap -l | -r | [-s] grubdev osdisk Manage the BIOS drive mappings
dump Usage: dump ADDR - dump memory You probably need to insert the dump module before you can use dump, see insmod. echo Usage: echo [-e] [-n] STRING - Display a line of text
exit The exit command can be used to exit from CLI Mode and return your to the normal GRUB Menu. To use it, type the command and then press your enter key twice. export export [ENVVAR] - export an environmental variable font font FILE - Specify one or more font files to display. You need to use fonts which have been made in pff or pf2 file format and compatible with GRUB2 using the grub-mkfont command, or get them already made from somewhere, such as a website or repository. This didn't seem to work yet, at least not for me the last time I tried. I get 'error: Invalid font magic'. Link to more info: gfxterm - GRUB Wiki Here's an interesting link: GRUB Graphical Menu Development Journal - grub.gibibit.com freebsd freebsd FILE [OPTS] [ARGS...] - Load a freebsd kernel. freebsd_loadenv freebsd_loadenv FILE - Load freebsd env. freedsb_module freebsd_module [FILE [type=module_type] [ARGS...]] gptsync Usage: gptsync DEVICE [PARTITION[+/-[TYPE]]] ... Fill hybrid MBR of GPT drive DEVICE, specified partitions will be a part of hybrid mbr. Up to 3 partitions are allowed. TYPE is am MBR type, + means that partition is active. Only one partition can be active. You probably need to insert the gptsync module before you can use gptsync, see insmod. halt - shuts down the computer immediately, if possible using APM
What is 'APM'? - Advanced Power Management - Wikipedia, the free encyclopedia handler [class [handler]] List or select a class handler hdparm Usage: hdparm [OPTIONS] DISK Get/set ATA disk parameters
You probably need to insert the hdparm module before you can use hdparm, see insmod. example,
hello - prints 'Hello World' example,
help help [PATTERN] If you just type 'help' by itself, it will just show you a list of available commands. If you want to find out about one of those commands, type 'help <name-of-command>'. For example, 'help echo', will give you more information about the 'echo' command. If you type 'help help', you can get more information about the 'help' command. The 'help' command is useful for reminding us what each command is used for, the proper syntax for using the command with options, and what options are available. TIP: The 'help' command is the most important command in this whole page because if you can use the help command it will help you find out how to use all the rest of them. example,
hexdump hexdump [options] file or device - hexdump [ -s offset ] [-n length] { FILE | (mem) } * Dump the contents of a file or memory.
Example: Print the MBR on screen,
initrd initrd FILE - Load an initrd.img Example,
We normally load the kernel with the linux command first before we use the initrd command to load the initrd.img which matches the kernel. Please read this link: initrd - Wikipedia, the free encyclopedia initrd16 The name implies it's probably related to another command: linux16, see linux16 . insmod insmod MODULE - Insert a module. The various instructions for GRUB2 are either built-in, or implemented as external modules, which have to be loaded before use.
(Read the (7)grub_modules page). keystatus Usage: keystatus [--shift] [--ctrl] [--alt] Check key modifier status
You probably need to insert the keystatus module before you can use keystatus, see insmod linux linux FILE [ARGS...] - Load a Linux kernel - Load a linux kernel. [_linux] example,
linux16 For loading special kinds of kernels that the regular linux command, (above) doesn't cater for, such as 16-bit (b)zImage images like memtest86+. One example of the use of the linux16 command is here: Run From GRUB2 - (PLOP Boot Manager). For a second example, here is how to boot a floppy disk image from GRUB2. For the full context see HOWTO: Flash BIOS, The Ubuntu Way - ciscosurfer - Ubuntu Web Forums,
There is also a multiboot compliant kernel game, http://erikyyy.de/invaders/ loadfont First you might need to use the ls command (below), to find a font file in your hard disk drive. See also, How to Change the GRUB Menu Font . example,
You may use the lsfonts command (further below), to see if it worked. The lsfonts command will give you a list of the fonts currently loaded. I tried using the set command to see if I would be able to actually change the font that appears in the CLI Mode GRUB or in the GRUB Menu, but so far I have not been successful. Probably it's my own fault. I hope to have an update for this sometime soon. ls ls [-1| -h|-a] [FILE] List devices and files
The ls command is one of the first commands to try if you want to use GRUB to take a look around inside a computer. When you know what's there you can decide what you want to try to boot. If given no options, ls lists all the devices currently known to the BIOS in the computer,
When given the path and name of a partition, ls can display information about the file system,
When given the path and name of a directory, ls can list the contents,
As you can see from the information listed above, we have found a Linux operating system. lsfonts List the loaded fonts lspci - List all PCI devices. [lspci] The output looks like "00:00.0 8086:27a0.0 Device Class". example output,
loopback loopback [-d| -p] DEVICENAME FILE - Make a device from a file - Loopback allows mounting a file as if it were a disk (i.e turn a disk image in a virtual device). check the loopback command implemented by this module, in (5)grub.cfg) Here's a web page about how to use the loopback command to boot an .iso file containing a bootable Linux CD image when the bootable .iso is located in a hard drive, Boot an ISO via Grub2 - Mika's Blog See also, MultiBoot USB with Grub2 (boot directly from iso files) - panticz - thanks pxwpxw for the link. I tried following the example in Mika's Blog and I was able to get that to work. I used a parted magic live cd instead of grml though. I copied my parted magic live cd .iso file into my /boot partition first, to make the file path simpler. (I'm using a separate /boot because I have a LUKS encrypted LVM / file system). Then I rebooted and entered CLI Mode GRUB and ...
TIP: For the special kernel boot options, mount the .iso beforehand and take a look around for the Live CD's boot loader. Look for a folder called 'grub' or 'isolinux', most CDs use isolinux, but a few use GRUB. Look for a menu.lst or grub.cfg file or a file called isolinux.cfg, you will find boot entries in those files which use all kinds of special boot options. You can note down the options you like and use the same options now.
This booted the .iso file from my hard disk drive and now the entire Parted Magic is running in RAM! Success is sweet! I did it, can you? lsmod lsmod - List modules - The various instructions for GRUB2 are either built-in, or implemented as external modules, which have to be loaded before use. (Read the (7)grub_modules page). example,
module module FILE [ARGS...] (Read the (7)grub_modules page). GRUB2 has a modular design, so we can add new modules or upgrade old modules to add more functionality. Each module is designed to perform some function. There are modules for each command, modules for the video diplay, understanding file systems, providing the fonts, and so on. These modules can be 'inserted' when needed. If you're trying to do something in GRUB and you get an error 'not loaded', try using the insmod command to insert the module amd then try the command again, see insmod multiboot - Load a multiboot kernel - Load a Multiboot kernel. [_multiboot] netbsd netbsd FILE [OPTS] openbsd openbsd FILE [OPTS] parser.sh Set active handler parser.rescue Set active handler play play FILE - Play a sound - you need to specify some kind of a sound file which you may have stored in your computer somewhere, (in a file system). - I don't know if it plays .ogg music or mp3 or some other sound format ? - so far I can get it to make beeps from the motherboard speaker - maybe for newer computer with better motherboard speakers ? read read [ENVVAR] - read an environmental variable reboot - reboot rescue - Enter rescue mode - Go into the rescue mode. rmmod rmmod - Remove a module - Remove (unload) a module. (Read the (7)grub_modules page). search search [-f | -l | -s] NAME - Search devices
serial serial [-f|-l|-s] NAME - Configure a serial port.
Here's a link for those who aren't sure what a serial port is, Serial Port - wikipedia set set [ENVAR=VALUE] When no options are specified, this command lists the environmental variables you have presently in place. example:
If an option is specified, this command can set a variable - var=value ...... - Set a variable An 'environmental variable' is something like the normal foreground/background colors for your menu and the highlight foreground/background colors. If you're displaying a splashimage, you can use only use black for your background (second) color, especially for the 'normal' two colors, because black means transparent. Colors will hide the splashimage. eg color_normal anycolor/black anycolor/anycolor Where: 'anycolor' means any color from the list of available colors. Colors we can choose from include, black (meaning transparent), blue, green, cyan, red, magenta, brown, light-gray, dark-gray, light-blue, light-green, light-cyan, light-red, light-magenta, yellow, white.
example,
Another environmental variable we can set is 'pager=1',
The opposite of set is unset. sleep sleep NUMBER_OF_SECONDS - sleep [-v] [-i] NUMBER_OF_SECONDS * Wait for a specified number of seconds. [sleep]
example output,
type 'sleep 10', and nothing appears on the screen for 10 seconds type 'sleep -v 10', and you will see the number of seconds displayed counting down from 10 to 0. type 'sleep -i -v10', and you can press your 'Esc' key at any time to return to your main boot menu. I imagine the sleep function should be useful for setting your computer to wait for some amount of time before booting up, or having GRUB run some other command(s). source source FILE - Load another config file without changing context. terminal terminal [TERM...] Prints what terminals are available and which one you're using right now. example output,
terminfo terminfo [TERM] -Set terminfo type test test EXPRESSION - evaluate an expression unset unset [VAR] - Unset an environmental variable Another way to unset an environmental variable when in Command Line Mode is to chainload the same GRUB by it's own MBR or boot sector. See the chainloader command. usb - Test USB support vbeinfo List compatible VESA BIOS extension video modes. [vbeinfo @i386] This command is the recommended command for finding out what will be the maximum resolution we can set for our display, and and therefore determines the size of our splashimages. TIP: This command, (and a few of the other commands), will cause about three pages of text to go scrolling up the monitor screen faster than most humans can read. You may use your 'pause' key to pause the scrolling and take your time to read the text. When ready, just press 'enter' for the next page of text to scroll up. Another idea is to use the set command, set pager=1 vbetest Test VESA BIOS Extension 2.0+ support. [vbetest @i386] The mode to test is specified in variable $vbe_mode, which defaults to 0x101 (640x480 8bpp) jpeg file format restriction : unknown (8-bit precision only ?). videotest Test video subsystem. [videotest] To set the screen resolution, you should set the variable $vbe_mode before loading vbe and/or gfxmterm (default mode is 0x101 i.e. 640x480 8bpp) Test your graphics - I entered the command by itself - nothing happened (black screen) until I pressed 'enter', then some colored squares appear. Any key cancels. - have to 'Ctrl'+'Alt'+'Del' to reboot. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| variable | = | value |
| 0 | = | ? |
| color_highlight | = | yellow/blue |
| color_normal | = | red/green |
| gfxmode | = | 640x480 |
| prefix | = | (hd0,2)/boot/grub |
| root | = | (hd0,2) |
| default | = | 0 |
| pager | = | 1 |
| white | blue | magenta | cyan |
| light-gray | yellow | red | light-magenta |
| dark-gray | green | light-blue | light-red |
| black | light-cyan | light-green | brown |
| 915resolution.mod | |||||
| acpi.mod | affs.mod | afs_be.mod | afs.mod | aout.mod | ata.mod |
| ata_pthru.mod | at_keyboard.mod | ||||
| befs_be.mod |
befs.mod | biosdisk.mod | bitmap.mod | blocklist.mod | boot.mod |
| bsd.mod | bufio.mod | ||||
| cat.mod | cpuid.mod | crc.mod | cmp.mod | configfile.mod | cpio.mod |
| chain.mod | |||||
| datehook.mod | date.mod | datetime.mod | dm_nv.mod | drivemap.mod | |
| echo.mod | efiemu.mod | elf.mod | ext2.mod | extcmd.mod | |
| fat.mod | font.mod | fs_file.mod | fshelp.mod | fs_uuid.mod | |
| gfxterm.mod | gptsync.mod | gzio.mod | |||
| handler.mod | halt.mod | hdparm.mod | hello.mod | help.mod | hexdump.mod |
| hfs.mod | hfsplus.mod | ||||
| iso9660.mod | |||||
| jfs.mod | jpeg.mod | ||||
| keystatus.mod | |||||
| loopback.mod | lsmmap.mod | ls.mod | lspci.mod | lvm.mod | linux16.mod |
| linux.mod | loadenv.mod | ||||
| memdisk.mod | mdraid.mod | memrw.mod | minicmd.mod | minix.mod | mmap.mod |
| msdospart.mod | multiboot.mod | ||||
| ntfscomp.mod | normal.mod | ntfs.mod | |||
| ohci.mod | |||||
| part_msdos.mod | part_apple.mod | part_gpt.mod | part_sun.mod | part_amiga.mod | parttool.mod |
| password.mod | pci.mod | play.mod | png.mod | probe.mod | part_acorn.mod |
| pxecmd.mod |
pxe.mod | ||||
| raid5rec.mod | raid6rec.mod | raid.mod | read.mod | reboot.mod | reiserfs.mod |
| serial.mod | search.mod | setjmp.mod | sfs.mod | sh.mod | sleep.mod |
| scsi.mod | |||||
| tar.mod | terminfo.mod | test.mod | tga.mod | true.mod | |
| udf.mod |
ufs1.mod | ufs2.mod | uhci.mod | usb_keyboard.mod | usb.mod |
| usbms.mod | usbtest.mod | ||||
| vbeinfo.mod | vbe.mod | vbetest.mod | vga.mod | vga_text.mod | video_fb.mod |
| video.mod | videotest.mod | ||||
| xfs.mod | xnu.mod | xnu_uuid.mod | |||
| zfs.mod | zfsinfo.mod |
|
|
|