I'm trying to make a Debian installation manually from scratch to an external disk within a live Debian CD.

I created a Debian Stretch rootfs via multistrap by following the instructions from here (44fbcc).

Inside chroot environment, when it comes to Grub installation, I install the Grub2 to MBR:

debian:~# grub-install /dev/sdX --boot-directory=/boot

Command runs without error. When I need to create the /boot/grub/grub.cfg, it throws the following error:

debian:~# grub-mkconfig
/usr/sbin/grub-probe: error: cannot find a device for / (is /dev mounted?).

Yes, /dev is mounted along with /sys, /proc and /run here.

How can I generate grub.cfg inside chroot environment?

  • Do you have /sys mounted in addition to /dev?
    – icarus
    Dec 23 '19 at 14:33
  • Yes, here.
    – ceremcem
    Dec 23 '19 at 14:35

The meaningful part of the error message was cannot find a device for /, because mount command does not output the device entry for /.

What I didn't tell in the question is that I was trying to directly install the rootfs into a BTRFS subvolume. Apparently, chroot can not detect the / device in this scenario.

Here is what I was currently doing: (X is the root partition (device), Y is the boot partition)

host:# mount /dev/X /mnt/mydiskroot
host:# btrfs sub create /mnt/mydiskroot/rootfs
host:# mkdir /mnt/mydiskroot/rootfs/boot
host:# mount /dev/Y /mnt/mydiskroot/rootfs/boot
host:# rsync -avP debian-stretch-rootfs/ /mnt/mydiskroot/rootfs
host:# do-chroot.sh /mnt/mydiskroot/rootfs
root@guest:/#  mount | awk '$3 == "/" {print}' # nothing shows up, so update-grub throws the mentioned error

Here is how I solved:

root@guest:/# exit
host:# mkdir /mnt/actual-rootfs
host:# mount -t btrfs -o subvol=rootfs,defaults /dev/X /mnt/actual-rootfs/
host:# umount /dev/Y
host:# mount /dev/Y /mnt/actual-rootfs/boot
host:# do-chroot.sh /mnt/actual-rootfs
root@guest:/# mount | awk '$3 == "/" {print}'
/dev/X on / type btrfs (rw,relatime,space_cache,subvolid=257,subvol=/rootfs)
root@guest:/# update-grub
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-4.9.0-11-amd64
Found initrd image: /boot/initrd.img-4.9.0-11-amd64

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.