Linux Commands for GRUB2

This web-page is part of a larger site giving examples of how to install Windows+Ubuntu Linux operating systems 'dual boot' in a computer.  Illustrated Dual Boot HomePage

Edited Tuesday, January 05 2010 Document made with KompoZer

WARNING: GRUB2 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 2 Manual.


Page Index
By commands

grub-install - Install, refresh and repair GRUB2, runs other commands

update-grub - make a new grub.cfg file - for Jaunty Jackalope and earlier

grub -mkconfig  - make a new grub.cfg file - Karmic Koala and later

grub-set-default - tell GRUB which OS title you want to be highlighted by default

grub-mkrescue - makes a bootable rescue CD or floppy disk image

grub-setup  - install the boot.img to a disk or partition

grub-mkfont - converts fonts for use by GRUB  - Karmic Koala and later

grub-mkdevicemap  - makes a new device.map file 

grub-mkimage  - makes a boot image -used by grub-install and grub-mkrescue

grub-probe  - a program to probe for device information, run by scripts


By How-To

How To Check Installed GRUB Version Number - with grub-install

How to install, update and repair GRUB - with grub-install

How to make a Dedicated GRUB Partition - with grub-install

How to make a GRUB USB - with grub-install

How To Re-install GRUB from Live CD - with grub-setup

How to make a bootable GRUB2 CD-ROM - with grub-mkrescue

How to make a bootable GRUB2 Floppy Disc - with grub-mkrescue

How to Update the GRUB Menu - by running update-grub

How to Update the GRUB Menu - by running grub-mkconfig

How To Set The Default Boot Entry for GRUB - with grub-set-default

How To Install GRUB to a Partition Boot Sector - with grub-setup






grub-install - usr/sbin/grub-install - a script to install GRUB on a device

grub-install installs Grub bootloader on the specified INSTALL_DEVICE drive (which can be a GRUB device name or a system device filename).

grub-install copies GRUB images into the DIR/boot directory specified by --root-directory (default is "/"), and uses grub-setup to install grub into the boot sector.

--modules=MODULES  - Pre-load specified modules MODULES

--root-directory=DIR - Install GRUB images under the directory DIR instead of the root directory

--grub-setup=FILE - Use FILE as grub-setup

--grub-mkimage=FILE - Use FILE as grub-mkimage

--grub-mkdevicemap=FILE - Use FILE as grub-mkdevicemap

--grub-probe=FILE - Use FILE as grub-probe

--no-floppy - Do not probe any floppy drive.

--recheck - Probe a device map even if it already exists 

(8)grub-install


This command is probably the most important command on this page, it runs four of the other commands. This command should be able to automatically fix most problems with GRUB 2.
 
This command creates a /boot/grub directory if there isn't already one in the root partition.
Then it copies GRUB *.mod,  *.lst and  *.img files files from /usr/lib/grub/i386-pc/ into the /boot/grub/ directory.
It runs grub-probe to scan the computer and gather disc and partition information.
It makes a new device.map with grub-mkdevicemap.
It runs grub-mkimage which builds a new core.img, and calls grub_setup to install the grub boot.img and the core.img to the device (disk or partition).

NOTE: You need to have the operating system booted to run this command because it will only work from inside the running operating system.
If you can't get your operating system to boot the regular way, but you can get at least get GRUB, then you should be able to get it to boot by using GRUB2 CLI Mode Commands.
If you still can't get the operating system to boot up at all  you probably need to boot a Live CD and chroot into your operating system to run this command. Recover Grub 2 via LiveCD - Ubuntu Wiki

EXAMPLES BELOW

How To Check Installed GRUB Version Number


grub-install -v



How to install, update and repair GRUB

This should fix almost any ordinary GRUB 2 problem and will be the most often used command for GRUB 2. For most ordinary people it will be about the only command they'll need to use.

sudo grub-install /dev/sda
Where: /dev/sda is the disk you wish to install GRUB to, (boot.img to first hard disk MBR), otherwise use '/dev/sdb' for second hard disk or '/dev/sdc' for third hard disk.
If you're not sure which hard disk's MBR you want to install GRUB2 to, it's possibly best to install GRUB to all of your disks, just to make sure.

If you want to install GRUB2 to the boot sector of a partition, you may use something like /dev/sda1 or /dev/sda2 for installing GRUB's boot.img to a partition boot sector.
The practice of installing GRUB2 to partition boot sectors is not encouraged, it is better to install GRUB2 to a MBR.
If you insist on installing GRUB to a partition boot sector, please be careful and make sure you only install GRUB to a Linux partition! Don't blame GRUB if you are silly enough to make a mistake and install to the wrong partition boot sector!

Good things about the grub-install command are that this command runs several other commands at the same time, including grub-probe, grub-mkdevice.map, grub-mkimage, grub which saves the user some work.
Also, grub-install  refreshes all your important GRUB files in /boot/grub as well.
Run grub-install may be run as often as you like and especially when trying to fix a GRUB2 problem.

Non-good things about the grub-install command are you need to have the operating system booted first, before you can use the command.
If the operating system you're trying to fix won't boot you need to chroot into it from another operating system such as a Live CD operating system before you can run grub-install. In that situation it might be easier to use grub-setup instead, please refer to How To Re-install GRUB from Live CD - with grub-setup.
The grub-install command doesn't run grub-mkconfig (or update-grub), so the user still needs to run one of those commands if a new grub.cfg is wanted. See grub -mkconfig  - make a new grub.cfg file - Karmic Koala and later.









How to make a Dedicated GRUB Partition

Why would anyone want a 'Dedicated GRUB 2 Partition?

When GRUB 2 is in its own dedicated partition it is 'operating system independant', so we can add or remove one or two operating systems without the inconvenience of losing the boot of the remaining operating systems.
Those of us who are multi-booting with more that two operating systems in their computer like to be able to set their own user friendly names for their operating systems.
It's okay to edit the grub.cfg directly when GRUB 2 isn't part of an operating system, making it easier to do what we like with GRUB and have fun with it and learn more GRUB commands and tricks.
  1. Choose an existing partition or create a new one and format it with a file system, you will need at least about 60 MiB of space in the partition for grub 2 files, but a little more room than that might be advisable.
  2. Format the partition with a file system and optionally give the file system a FILE SYSTEM LABEL.
  3. Mount the partition - Usually 'Places'-->'Removable Media'-->'FS_LABEL',
  4. Run a grub-install command similar to the one shown below, 
    sudo grub-install --root-directory=/media/grub2 /dev/sda
Where: '/media/grub2' is the mount point for the file system I want to have GRUB files created in
Where:  I want to make a new /boot/grub directory and fill it with GRUB files.
Where: '/dev/sda' is the hard disk in which I want to write the stage1 code to MBR in

That command creates a new /boot and /boot/grub/ directory if one doesn't already exist, and creates or refreshes GRUB files in /boot/grub, all except for grub.cfg.
If you don't make a grub.cfg then  there will be no GRUN Menu and your computer will boot to a GRUB Command Line Interface,  see GRUB2 How To Boot From CLI Mode

If you want a GRUB Menu you need to make a grub.cfg file and copy it to /boot/grub.
You can make your own grub.cfg file and customize it in any way you like.
The proper way to do it would be to use the grub-mkconfig command, and alter the file path to make it point to the 'Dedicated'  /boot/grub/'. See How to Update the GRUB Menu .
Another way would be to make your own grub.cfg, if you need an example to help you get started, look here, grub.cfg - Grub Wiki.
Or, copy and paste this one, grub.cfg, to a blank text file, name it grub.cfg, edit it to your needs and paste it in your Dedicated /boot/grub.
Later, you can also make and add other files such as background images.

I had trouble getting my 'Dedicated GRUB 2' to display any background image at first.
I was getting 'error: No video mode activated', after trying the background_image command in CLI Mode.
I needed make a fonts folder in my 'Dedicated GRUB 2 Partition and copy the fonts from /usr/share/grub/unicode.pff and /usr/share/grub/ascii.pff into it. Then I had to correct the fonts path in my grub.cfg header area,
### BEGIN /etc/grub.d/00_header ###
set default=0
set timeout=5
set root=(hd0,2)
if font (hd0,2)/fonts/unicode.pff ; then
  set gfxmode=640x480
  insmod gfxterm
  insmod vbe
  terminal gfxterm
fi
### END /etc/grub.d/00_header ###

After that I was able to display my splashimage in my 'Dedicated GRUB 2 Partition'.

to do (Herman) ... revise and this how-to more user freindly.





How to make a GRUB_II USB


GRUB 2 could be very handy in a USB. You can use it for an emergency boot disk.
You can play with it and use it for  doing interesting experiments with to learn more about GRUB without compromising your real GRUB. It's okay to edit the grub.cfg directly when GRUB 2 isn't part of an operating system.

1. Choose an USB drive with at least about 60 MiB of space in the partition for grub 2 files, but a little more room than that might be advisable. It can be formated with any file system, it doesn't mattter if there are already some files in it.

2. Plug in your USB drive  while Ubuntu is running, it should be automatically mounted in a few seconds and an icon should appear for it on your desktop.

3.  Find out what is the real mount point name, (if you don't already know), this step is important because the actual mount point in /media can have another name than the name you see for the icon on your Desktop.
Code:
ls /media/

example output
cdrom  cdrom0  Verbatim
The resulting feedback shows that my USB drive's file system is mounted as /media/Verbatim, because it has 'Verbatim' set as the freindly file system label.
If yours comes up as a file system UUID number, I recommend you set your own user freindly file system label to make things easier for yourself now and in the future. How To Set File System Labels With GParted.

5. Find out what is the /dev/number for the file system (or partition),
sudo blkid

example output
sudo blkid
/dev/sda1: LABEL="ACER" UUID="320D-180E" TYPE="vfat"
/dev/sda2: LABEL="ACERDATA" UUID="04A6-B8C3" TYPE="vfat"
/dev/sda5: LABEL="KARMIC" UUID="53640b23-7f97-46a7-b939-b5aedd5097c1" TYPE="ext4"
/dev/sda6: UUID="88115692-4578-47b5-89ae-dcc3720d95e4" TYPE="swap"
/dev/sdb1: LABEL="Verbatim" UUID="1fdc26cf-43ad-40b9-95fa-6d64196513f2" TYPE="reiserfs"
Here you can see that the target file system in my USB disk is called 'Verbatim' and it is listed as /dev/sdb1.

6. Run grub-install ,
sudo grub-install --root-directory=/media/verbatim /dev/sdb
Where: the mount point is /media/verbatim
Where: The MBR to install GRUB to is /dev/sdb (the USB drive).
NOTE: I didn't install GRUB to /dev/sdb1, because that's the partition boot sector. I need GRUB in the USB disk's MBR, which is called /dev/sdb in this case, since the partition is /dev/sdb1.

Watch the thumb drive's LED blink for a few seconds.

Now you have a bootable GRUB 2 USB Rescue disk.

But it has no grub.cfg

7. Run grub-mkconfig
sudo grub-mkconfig -o /media/Verbatim/boot/grub/grub.cfg

8. Relax the file permissions to make it easily editable from GUI mode, (user freindly).
Let's make it editable so we can play with it.
sudo chmod 777 -R /media/verbatim /boot

Now we can open it in GUI mode even if we want and edit the grub.cfg file to our heart's content.


Links:
Use cases - Ubuntu 8.10 on USB device - GRUB Wiki

How to add GRUB to your USB thumb drive - (GRUB Legacy)





update-grub - /usr/sbin/update-grub - script - generates a new  /boot/grub/grub.cfg file

This script runs other scripts and programs such as grub-mkdevice.map and grub-probe and then generates a new grub.cfg file.

update-grub - automatically generate a new /boot/grub.grub.cfg file

 NAME
       update-grub - manual page for update-grub (GNU GRUB )

SYNOPSIS
       update-grub [OPTION]

DESCRIPTION
       Generate /boot/grub/grub.cfg

       -h, --help
              print this message and exit

       -v, --version
              print the version information and exit

       -y     ignored for compatibility

(8)update-grub, (8)update-grub2

Example,
sudo update-grub
In Ubuntu, you must use the word 'sudo' before the command.

The output can be expected to look something like this,
herman@lec-intrepid:~$ sudo update-grub
[sudo] password for herman:
Updating /boot/grub/grub.cfg ...
Found Debian background: Windbuchencom.tga
Found linux image: /boot/vmlinuz-2.6.28-11-generic
Found initrd image: /boot/initrd.img-2.6.28-11-generic
Found linux image: /boot/vmlinuz-2.6.28-8-generic
Found initrd image: /boot/initrd.img-2.6.28-8-generic
Found linux image: /boot/vmlinuz-2.6.28-6-generic
Found initrd image: /boot/initrd.img-2.6.28-6-generic
Found linux image: /boot/vmlinuz-2.6.28-4-generic
Found initrd image: /boot/initrd.img-2.6.28-4-generic
Found linux image: /boot/vmlinuz-2.6.28-3-generic
Found initrd image: /boot/initrd.img-2.6.28-3-generic
Found linux image: /boot/vmlinuz-2.6.27-7-generic
Found initrd image: /boot/initrd.img-2.6.27-7-generic
Found memtest86+ image: /boot/memtest86+.bin
Found Ubuntu karmic (development branch) (9.10) on /dev/sda10
Found Windows XP Professional on /dev/sda3
Found Ubuntu 8.10 (8.10) on /dev/sda5
Found Ubuntu 8.04.2 (8.04) on /dev/sda8
Found Linux Mint 6 Felicia - Main Edition (6) on /dev/sda9
done
Tested and works for me.
The update-grub script should be run whenever /boot/grub/grub.cfg needs to be updated in Ubuntu.
  • when an operating system has been added or deleted
  • after changes have been made to the scripts in /etc/grub.d or /etc/default/grub.






grub-mkconfig - /usr/sbin/grub-mkconfig - a script for making a new  /boot/grub/grub.cfg file.

As far as I know this command is supposed to be used in preference to update-grub in Karmic Koala and later versions of Ubuntu. Earlier version of Ubuntu didn't seem to contain this script.
This command is more versatile than update-grub because we can use the -o option to have the results printed to a any filename and file path we like. That's a useful feature.

This script also runs other scripts and programs such as grub-mkdevice.map and grub-probe and then generates a new grub.cfg file.

NAME
grub-mkconfig - manual page for grub-mkconfig (GNU GRUB ) 
SYNOPSIS
grub-mkconfig [OPTION] 
DESCRIPTION
Generate a grub config file

-o, --output=FILE
    output generated config to FILE [default=stdout]
-h, --help
    print this message and exit
-v, --version
    print the version information and exit

examples,
sudo grub-mkconfig 
The grub-config command by itself doesn't do anything much. It displays the results in the terminal screen, and you can see what it would have wrtten to a file if you had used grub-mkconfig with the -o option.
The output that appears in the terminal looks the same as the output for the ' update-grub' command,

You need to use the -o option and specify a filepath and file for grub-mkconfig to write to if you want grub-mkconfig to do something useful,
sudo grub-mkconfig -o /boot/grub/grub.cfg
When you you use the -o option, you can write the changes to a file.
You can make up any file path and file name here, but most of the time people will probably want to write to their /boot/grub/grub.cfg if they are serious about actually updating the file.

We could use the -o option to direct the output of grub-mkconfig to some other file if we want to do something special or tricky with GRUB. We could have more grub.cfg files by making new ones with names other than 'grub.cfg'.

For example, we could have /boot/grub/grub.cfg and /boot/grub/grub.cfg2 and /boot/grub/grub.cfg3 and so on if we wanted to.
We might want to do that and use the 'configfile' command to change from one GRUB menu to another at boot time. The configfile commands can be added as a custom command in 40_custom, or any other script we like.

For another example, we might want to direct our /boot/grub/grub.cfg to some other mounted partition, such as a 'Dedicated GRUB Partition', or GRUB in a USB drive. We can do that just by changing the file path after the -o option.




grub-set-default
- /usr/sbin/grub-set-default - Script to set a default boot entry for GRUB.

grub-set-default sets a boot entry in the menu.lst to be booted by default if no keys are pressed and the timer is allowed to run out.
It does that by writing to a file called /boot/grub/default

This is the same file that the grub.cfg command 'savedefault' writes to.

sudo grub-set-default 1
Sets the number 1 at the top of the file.  Tested and works for me.

No manual entry for grub-set-default
See 'man 7 undocumented' for help when manual pages are not available.

(8)grub-set-default



grub-mkrescue - usr/bin/grub-mkrescue  - a script to make a bootable floppy disc image or run genisoimage to make an .iso file for burning to disc to make a bootable rescue CD.

By default, the image will contains all the modules available in the current grub distribution, thus the name rescue.
Bootable cdrom images use cdboot.img loader, which are capable of accessing the ISO9990 cdrom to load extra modules (see the (8) genisoimage -b option).

NAME
       grub-mkrescue - manual page for grub-mkrescue (GNU GRUB 1.96)

SYNOPSIS
       grub-mkrescue [OPTION] output_image

DESCRIPTION
       Make GRUB rescue image.

       -h, --help
              print this message and exit

       -v, --version
              print the version information and exit

       --modules=MODULES
              pre-load specified modules MODULES

       --overlay=DIR
              overlay directory DIR in the memdisk image
             The content of the directory DIR will be added (overlaid) to the rescue image content.
             This is especially useful if you want to include your grub.cfg, and any additional files 
             such as splashimages and themes and so on.
             DIR is the root folder, which will be known as (memdisk)/ at boot time.  
             It will contain /boot/grub.

       --pkglibdir=DIR
              use images from directory DIR instead of /usr/lib/grub/i386-pc

       --grub-mkimage=FILE
              use FILE as grub-mkimage

       --image-type=TYPE
              select floppy or cdrom (default)

       --emulation=TYPE
              select El Torito boot emulation type floppy or none (default) (cdrom only)

       grub-mkimage generates a bootable rescue image of the specified type.

(8)grub-mkrescue


How To Make Your Own GRUB2RESCUE CD-ROM
1st example for grub-mkrescue,
grub-mkrescue --overlay=/boot/grub GRUB2RESCUE.iso
Where: I want to include files such as my own personalised grub.cfg from /boot/grub
Where: I want the program to name the file 'GRUB2CD.iso'
  • if you're making a CD, you don't have to specify the 'type', because CD is the default
  • --overlay=DIR would be an important option if you want a menu based GRUB2 CD. You can make an .iso file with your own familiar GRUB Menu in it. If you don't want to do that you might instead want to make up a special grub.cfg for some special purpose or experiment you want to try. If you don't use this option you'll still have a bootable GRUB2 CD, but it will only have the Command Line Interface, see GRUB2 CLI Mode Commands.
Expected Results -
  1. The grub-mkrescue program should make an .iso file in your /home/username directory with your own operating system's GRUB files inside it.
  2. You need to burn the .iso file to a blank CD as an .iso file, not as data, so it will be bootable.
  3. Your GRUB2RESCUE CD should boot to a GNU GRUB Command Line, see GRUB2 How To Boot From CLI Mode -  NEW!  Rescue your System  
  4. To see your own personalised GRUB Menu, just run the command: configfile /grub.cfg
Also see How To Boot From CLI Mode - Rescue your Operating System.



How To Make Your Own GRUB2 Floppy Disc
The grub-mkrescue command for making a floppy disc is the same as the command for making the .iso file but you need to add the option: --image-type=floppy.
Probably it would be best to use a different filename extension too.
grub-mkrescue --overlay=/boot/grub --image-type=floppy grub_two.dsk
This should make you a new floppy disc image file.

dd if=grub_two.dsk of=/dev/fd0 bs=512 count=2880
This is how to copy your floppy disk file to your floppy disk.

example thread: Installing grub2 bootloader in fd0

The old fashioned way to make a GRUB CD was to copy GRUB files to a folder and then run the genisoimage command on your folder to create and .iso image. After that you can burn the .iso image to disc.
Link:
How to make your own personalized GRUB CD-RW - (GRUB Legacy)

Link:
How to make your own personalized GRUB Floppy Disk.- (GRUB Legacy)

We can still probably use the old method with GRUB 2 if we want to, but the grub-mkrescue command does it a lot easier and faster and with far fewer commands than the old way of doing things.
The grub-mkimage command gets the thumbs up from me.

GRUB2 How To Boot From CLI Mode -  NEW!  Rescue your System 




grub-setup
- usr/sbin/grub-setup.exe  (writes images to device, used by grub-install)

grub-setup [device]  

Either install the boot.img file to a MBR plus the core.img install just   to the sectors after the MBR, or the boot.img file to a  partition boot sector.

NAME
       grub-setup - manual page for grub-setup (GRUB) 1.96

SYNOPSIS
       grub-setup [OPTION]... DEVICE

DESCRIPTION
       Set up images to boot from DEVICE.  DEVICE must be a GRUB device (e.g. ‘‘(hd0,1)’’).

       -b, --boot-image=FILE
              use FILE as the boot image [default=boot.img]

       -c, --core-image=FILE
              use FILE as the core image [default=core.img]

       -d, --directory=DIR
              use GRUB files in the directory DIR [default=/boot/grub]

       -m, --device-map=FILE
              use FILE as the device map [default=/boot/grub/device.map]

       -r, --root-device=DEV
              use DEV as the root device [default=guessed]

       -h, --help
              display this message and exit

       -V, --version
              print version information and exit

       -v, --verbose
              print verbose messages

(8)grub-setup

Examples,


How To Re-install GRUB

The following two commands will work from withing a running Ubuntu operating system
grub-setup /dev/sdb
- this example installs the IPL for GRUB to the second hard disk's MBR  


How To Install GRUB to a Partition Boot Sector
grub-setup --force /dev/sda2
- this example installs /boot/grub/boot.img  to the boot sector of /dev/sda2
(The GRUB from the operating system you're working in will be installed to /dev/sda2).
NOTE: GRUB 1.96 didn't seem to like having it's IPL installed to a partition boot sector, it complained and required the use of --force to get it to work.

TIP: If you can't boot Ubuntu in the normal way you can  use your GRUB2RESCUE CD and see the following link,  GRUB2 How To Boot From CLI Mode -  NEW!  Rescue your System.
Alternatively, you could  use your Ubuntu Live CD and mount the operating system concerned and chroot into it to run these commands.



How To Re-install GRUB 2 From A Live CD without the need to chroot.

1) Boot your Ubuntu Karmic Koala or later 'Desktop' Live CD, or another Karmic installation such as an operating system in a USB device or whatever you have to use as a as a rescue disk.

Tip: It will make your Ubuntu life a lot easier if you take a few minutes to set a nice user-freindly file system label in your linux file systems, How To Set File System Labels With GParted.

2) The operating system you want to fix needs to be mounted.
Just go 'Places'-->'Removable Media' or just 'Places' and look under 'Computer' for the disk or partition you want to mount and click on it. - also see Click-Icon Mounting.
You should see an icon for it on your desktop, but what you may not see is the 'mount point', which will normally be located in your /media directory. We will need to know the file path and name of the mount point.

3) Find the name of the mount point,
ls /media
The file path that is returned from the above command will be needed for making up the next command. The name of the mount point might be a file system LABEL or UUID number. For my example I'll just use the word 'disk' for short.

4)  Run the grub-setup command, inserting the -d option and specifying the path to the /boot/grub directory of the operating system you're trying to fix,
sudo grub-setup -d /media/disk/boot/grub /dev/sda
The -d option tells GRUB to use files from the specified directory.
Please substitute the word 'disk' with the name of your own mount point as found in step 3)
The '/dev/sda' part tells grub-setup to install GRUB to MBR in the first hard disk, which is called '/dev/sda'.
You may use the same command to install GRUB in any other disks in your computer by replacing the /dev/sda part of the command with /dev/sdb or /dev/sdc and so on.

- If the command fails with feedback about not being able to access a device.map file, you might need to try again and specify the exact device.map file to use with the -m option.
sudo grub-setup -d /media/disk/boot/grub -m /media/disk/boot/grub/device.map /dev/sda
The -m option tells GRUB what device.map you want to use.

 example thread:  Computer won't boot to 9.10; No Grub Menu

=============

More to do with the grub-setup command,
sudo grub-setup -b /media/disc/boot/grub/boot.img -c /media/disc/boot/grub/core.img -m /media/disk/device.map /dev/sda 
With the -b option you can specify the exact file path and file name for a specific boot image you want to install somewhere.
With the -c option you can also specify the file path and file name for a specific core image you want to install to an new partition.
I wasn't able to get these two working the last time I tried.
 



grub-mkfont
- /usr/bin/grub-mkfont - a program for changing fonts to make then suitable for use by GRUB. For working with graphical GRUB menus.

I don't know much about this subject yet ... sorry for any inconvenience.
See the GNU GRUB Wiki: gfxterm: Help for graphical terminal.




grub-mkdevicemap - usr/sbin/grub-mkdevicemap.exe (generates a new device.map file)
Users would rarely need to concern themselves with this command, it's for use by other programs or scripts.
grub-mkdevicemap automatically generates a new device.map file for grub (the file containing the mapping between the GRUB device names, and the system device names.
That file is used at installation time but not at boot time.

NAME
       grub-mkdevicemap - manual page for grub-mkdevicemap (GRUB) 1.96

SYNOPSIS
       grub-mkdevicemap [OPTION]...

DESCRIPTION
       Generate a device map file automatically.

       -n, --no-floppy
              do not probe any floppy drive

       -s, --probe-second-floppy probe the second floppy drive

       -m, --device-map=FILE
              use FILE as the device map [default=/boot/grub/device.map]

       -h, --help
              display this message and exit

       -V, --version
              print version information and exit

       -v, --verbose
              print verbose messages
(8)grub-mkdevicemap, - (5)grub_device.map.





grub-mkimage - usr/bin/grub-mkimage.exe (Makes a new  boot image, used by grub-install/mkrescue)
Makes a new core.img (boot image), that's the image is typically copied on the first sectors of a hard disk after the MBR.
grub mkimage isn't a script that users need to concern themselves with, it's just supplied to be used by  grub-install. and grub-mkrescue.

grub-mkimage makes a bootable image of GRUB, compressed with lzo [usually named core.img].
NAME
       grub-mkimage - manual page for grub-mkimage (GRUB) 1.96

SYNOPSIS
       grub-mkimage [OPTION]... [MODULES]

DESCRIPTION
       Make a bootable image of GRUB.

       -d, --directory=DIR
              use images and modules under DIR [default=/usr/lib/grub/i386-pc]

       -p, --prefix=DIR
              set grub_prefix directory [default=/boot/grub]

       -m, --memdisk=FILE
              embed FILE as a memdisk image

       -o, --output=FILE
              output a generated image to FILE [default=stdout]

       -h, --help
              display this message and exit

       -V, --version
              print version information and exit

       -v, --verbose
              print verbose messages

 grub mkimage - (8)grub-mkimage




grub-probe
- usr/sbin/grub-probe.exe  (Probes for device info, used by scripts)

grub-probe isn't a script that users need to concern themselves with, it's just supplied to be used by other programs. grub_probe detects the required partmap (pc partition table, disklabel...) and abstraction (lvm, raid) modules. The program that invoked grub-probe can gather the information. Normally, grub-probe is automatically invoked by grub-install or  grub-mkconfig or update-grub.

No manual entry for grub-probe
See 'man 7 undocumented' for help when manual pages are not available.

(8)grub-probe