Before you can debug why GRUB picked the wrong disk or UUID, you need to know what GRUB thinks a path resolves to. grub-probe answers that, and never touches storage or configuration. This is a read-only investigation: the command does not install GRUB, regenerate grub.cfg, or change anything on disk. Allow about ten minutes. You need a shell and the grub-common package; some targets also need permission to inspect the underlying block device.
The examples were checked with Ubuntu package grub-common 2.12-1ubuntu7.3, and the installed manpage documents that same version, so treat the output and available targets as version-specific rather than universal.
Check the executable and version:
$ command -v grub-probe
/usr/sbin/grub-probe
$ grub-probe --version
grub-probe (GRUB) 2.12-1ubuntu7.3
Get the full target list for this machine from the command's own help:
$ grub-probe --help
Checkpoint: you should see targets including device, disk, drive, fs, fs_label, fs_uuid, partmap and partuuid. Never copy a target name from a different GRUB version without checking this list first.
The default target is fs. Give it a path, not a device name:
$ grub-probe /path/to/a/mounted/file
Swap in a real path. A successful result is a filesystem type such as ext2, xfs, or whatever else your installation supports. The command resolves the path through the mounted filesystem; it does not inspect the file's actual contents.
A nonexistent path exits non-zero and reports a canonicalisation failure:
$ grub-probe --target=fs /definitely/not/a/real/path
grub-probe: error: failed to get canonical path of `/definitely/not/a/real/path'.
$ printf '%s\n' "$?"
1
Checkpoint: verify the input before you start investigating GRUB itself:
$ test -e /path/to/a/mounted/file && echo 'path exists'
Use --target=device for the system device behind a path:
$ grub-probe --target=device /
/dev/md2
The exact device depends on the machine; the line above is the verified result on the system used for this guide, and a device like /dev/md2 can be a RAID device rather than a single physical disk, so do not assume the trailing number identifies a partition on one drive.
To inspect a device you already know, add --device (or -d), which changes how the final argument is interpreted:
$ grub-probe --target=device --device /dev/md2
/dev/md2
Without --device, /dev/md2 is treated as a path to resolve. With it, the argument is explicitly a system device. Keep the option right next to the device in scripts so the distinction stays visible on review.
Each target answers one piece of the question:
$ grub-probe --target=device /path/to/a/mounted/file
$ grub-probe --target=disk /path/to/a/mounted/file
$ grub-probe --target=fs /path/to/a/mounted/file
$ grub-probe --target=fs_uuid /path/to/a/mounted/file
$ grub-probe --target=partuuid /path/to/a/mounted/file
$ grub-probe --target=partmap /path/to/a/mounted/file
device reports the system device.disk reports the disk identity.fs reports the filesystem type.fs_uuid and partuuid report identifiers, when the storage layout provides them.partmap reports the partition map where one applies.An empty or failed result is not an invitation to guess; check the path, device permissions and storage layout instead.
For scripts, capture the status immediately and treat a failure as a real result to handle:
if device=$(grub-probe --target=device /path/to/a/mounted/file); then
printf 'GRUB device: %s\n' "$device"
else
status=$?
printf 'grub-probe failed with status %s\n' "$status" >&2
exit "$status"
fi
A path can resolve to a device the current user simply cannot inspect deeply. On the test machine, asking for the filesystem target of / produced a permission error opening /dev/md2, even though the device target alone printed fine:
$ grub-probe --target=fs /
mdadm: must be super-user to perform this action
grub-probe: error: cannot open `/dev/md2': Permission denied.
That is a diagnostic boundary, not proof the filesystem is missing. Retry the same read-only probe with an account that administers the host, elevating only because the storage stack requires it:
$ sudo grub-probe --target=fs /
Warning: review the command before entering a password. grub-probe is meant to report information, but running it through sudo still grants elevated access to storage. Never combine it with commands that alter RAID, mounts or boot files.
--device-map=FILE selects the device map used for probing, defaulting to /boot/grub/device.map. It does not create a map or rewrite your storage configuration:
$ grub-probe --device-map=/boot/grub/device.map --target=device /path/to/a/mounted/file
Only point it elsewhere when a documented GRUB setup requires it, and check the file exists first rather than creating or overwriting device.map as a troubleshooting reflex:
$ test -r /path/to/device.map && sed -n '1,80p' /path/to/device.map
--device was added for an explicit device argument.