This tutorial is about the grub2 boot loader - i.e. the grub> prompt that you see when you boot from a device which has grub2 installed.
Do not confuse grub2 the bootloader/boot manager with legacy grub, grub4dos or GRUB or GRUB2 (which are linux scripts which can be configured to make various grub2 menus).
I have not found any decent guide on grub2 (a very incomplete official manual is here), so this is an attempt to help others and serve as a reminder to me (with useful links)!
As this site is mainly interested in USB booting, I will assume you want to boot from a USB drive to a grub2 menu.
If you are a Windows user, you can install grub2 to the MBR and following sectors of a USB drive using:
RMPrepUSB - BootLoaders - Install grub2 to MBR
If you then try to boot from the USB drive (e.g. using RMPrepUSB - F11), it will boot to the grub rescue> prompt because it will not be able to find the /boot/grub/grub.cfg file or any files under /boot/grub.
For linux users:
Open a terminal and type sudosu
Type fdisk -l (and note which device is your USB)
Type mkdir /mnt/USB && mount /dev/sdx1 /mnt/USB (replacing x with your actual usb device)
Type grub-install --force --removable --boot-directory=/mnt/USB/boot /dev/sdx (replacing x with your actual USB device)
grub2 uses environment variables. For instance, the current root is changed just by a set root=xxx command (you can also use root=xxx).
grub2 normally continues by loading some 'modules' from the $prefix/boot/grub/<arch>/ directory by default.
A typical Ubuntu OS will have one or more of these module directories
/boot/grub/i386-pc - for MBR-mode x86 modules
/boot/grub/i386-efi - for 32-bit EFI-mode
/boot/grub/x86_64.efi - for 64-bit EFI-mode
To boot to the grub rescue prompt, rename these three folders so they cannot be found.
Find these directories from a Ubuntu ISO and copy them to your USB drive (note: will be case-sensitive if ext filesystem).
e.g. If you are MBR-booting (e.g. using QEMU) it will need the /boot/grub/i386-pc module folder.
Now boot to grub2 again. This time you should see a grub> prompt as it boots to the grub command shell.
This is because it has found and loaded the normal.mod module and probably several other modules so that it can access different file systems.
Type lsmod to see what modules have been loaded.
Tip: If a broken system boots to the grub rescue prompt, ensure the prefix variable is correct and type insmod normal to load the normal module and then type normal to get it to load the full grub2 shell.
With the full 'normal' shell, we have many more commands available, because of the modules that have been loaded.
Hit the <TAB> key to see most of the possible commands (but not all!) now available or l<TAB> to see what commands beginning with l are available.
The pager variable controls screen paging. Type set pager=1 and then help to see what page mode does and then unsetpager to turn it off.
The debug variable determines the debug level (try set debug=all).
You can use a help command such as help chainloader to get more information about a command (though often it is inaccurate and incomplete!).
You may find some more useful information about grub2 here.
Modules can be considered as 'plug-ins'. They add functionality.