edoceo

grub-probe: error: cannot find a device for / (is /dev mounted?)

This problem is most often seen during an apt-get update or similar.

Issues in chroot

Mostly this is caused by some issues when running in a chroot. Before switching to the chroot, it's necessary to mount at least the /dev and /proc directories. However sometimes we've seen this issue even with these mounts properly configured.

In this example vm1 represens the device our system is running on; it could as easily have been /dev/sda1 or /dev/sdx4.

~ # mount /dev/vg0/vm1 /mnt/vm1
~ # mount -o bind /dev /mnt/vm1/dev
~ # mount -o bind /dev/pts /mnt/vm1/dev/pts
~ # mount -o bind /proc /mnt/vm1/proc
~ # mount -o bind /run /mnt/vm1/run
~ # mount -o bind /sys /mnt/vm1/sys
~ # chroot /mnt/vm1 /bin/bash

Viewing grub-mkconfig Details

Run grub-mkconfig with debug spew to see details.

~ # sh -x /usr/sbin/grub-mkconfig -o /boot/grub/grub.cfg

Work Arounds

If grub-probe still fails for you, even if properly entering chroot there is one last-ditch work-around.

The purpose of grub-probe is to simply output the file-system type for /. So, in the worst case you can do this.

~ # mv /usr/sbin/grub-probe /usr/sbin/grub-probe.orig
~ # curl edoceo.com/pub/grub-probe.sh > /usr/sbin/grub-probe
~ # chmod 0755 /usr/sbin/grub-probe

Here we effectively replace the binary grub-probe with a shell script that simply echos a known good value.

Core of grub-probe

The grub-probe utility is a binary that does something like this.

  1. Examine /proc/filesystems
  2. Examine /boot/grub/device.map
  3. Probe /dev/sd*
  4. Examine /proc/devices
  5. Examine /proc/self/mountinfo

From that information it will output the file-system type, device, file-system UUID which are fed to the grub-mkconfig

Loading Comments from Disqus...