i've managed to get thing working, sort of, but i still don't understand. if i run kpartx against /dev/nbd0, it adds device nodes in /dev/mapper/, and i'm able to use those. grub-install runs fine, and doesn't complain. so for some reason, it seems to not like the device nodes in /dev/ - e.g. comparatively:
>l /dev/nbd* brw------- 1 root root 43, 0 Jun 20 17:12 /dev/nbd0 brw------- 1 root root 43, 1 Jun 20 17:12 /dev/nbd0p1 brw------- 1 root root 43, 2 Jun 20 17:12 /dev/nbd0p2 brw------- 1 root root 43, 32 Jun 20 17:12 /dev/nbd1 [...] >l /dev/mapper/nbd* brw------- 1 root root 252, 7 Jun 20 17:12 /dev/mapper/nbd0p1 brw------- 1 root root 252, 8 Jun 20 17:12 /dev/mapper/nbd0p2 in both cases, it seems to me the kernel has awareness of the partitions, because i can work with them as expected in any other way [even without running kpartx], but there's something about the /dev/ nodes that i guess grub doesn't like. why is this necessary? what is it about the /dev/ nodes that grub doesn't like? thanks -ben > On Jun 16, 2020, at 12.10, listsb <listsb-g...@bitrate.net> wrote: > > hi- > > i'm attempting to install grub to an esp partition on an nbd device, but it > fails, and says "error: cannot find a GRUB drive for /dev/nbd0p1" [see > below]. this is a qcow2 image, presented to the system as /dev/nbd0 [e.g. > qemu-nbd --connect ...]. i also have another "traditional" disk connected as > /dev/vdd, partitioned the exact same way, and this works as expected. > > i've tried --force, --removable, --no-nvram, with and without device.map > files, using a loop device - all with the same result. > > what makes grub decide it's not a grub drive? also, why doesn't --force make > it work? based on what the man page says, it seemed to me like it should. > > here's some hopefully relevant info - thanks!: > >> parted /dev/nbd0 print > Model: Unknown (unknown) > Disk /dev/nbd0: 1074MB > Sector size (logical/physical): 512B/512B > Partition Table: gpt > Disk Flags: > > Number Start End Size File system Name Flags > 1 1049kB 105MB 104MB fat32 esp boot, esp > 2 105MB 1073MB 968MB pv1 lvm > >> cat >> /opt/build/operating_systems/alpine/work/imagetest-c5676f32-412a-4ef4-b617-962b932b8ef2/boot/grub/device.map > (hd0) /dev/nbd0 > > installing grub to /dev/nbd0p1: > ============================= >> grub-install \ >> --verbose \ >> --force \ >> --removable \ >> --target=x86_64-efi \ >> --bootloader-id=alpine \ >> >> "--efi-directory=/opt/build/operating_systems/alpine/work/imagetest-c5676f32-412a-4ef4-b617-962b932b8ef2/boot/efi" >> \ >> >> "--boot-directory=/opt/build/operating_systems/alpine/work/imagetest-c5676f32-412a-4ef4-b617-962b932b8ef2/boot" > Installing for x86_64-efi platform. > grub-install: info: cannot open > `/opt/build/operating_systems/alpine/work/imagetest-c5676f32-412a-4ef4-b617-962b932b8ef2/boot/grub/device.map': > No such file or directory. > grub-install: info: /dev/nbd0p1 is not present. > grub-install: info: Looking for /dev/nbd0p1. > grub-install: info: /dev/nbd0 is a parent of /dev/nbd0p1. > grub-install: info: /dev/nbd0p1 is present. > grub-install: info: Looking for /dev/nbd0p1. > grub-install: info: /dev/nbd0 is a parent of /dev/nbd0p1. > grub-install: info: /dev/nbd0p1 is present. > grub-install: info: Looking for /dev/nbd0p1. > grub-install: info: /dev/nbd0 is a parent of /dev/nbd0p1. > grub-install: error: cannot find a GRUB drive for /dev/nbd0p1. Check your > device.map. > > installing grub to /dev/vdd1: > ============================= >> grub-install \ >> --force \ >> --removable \ >> --target=x86_64-efi \ >> --bootloader-id=alpine \ >> >> "--efi-directory=/opt/build/operating_systems/alpine/work/imagetest-1e909864-b820-4939-9dff-b4918184c632/boot/efi" >> \ >> >> "--boot-directory=/opt/build/operating_systems/alpine/work/imagetest-1e909864-b820-4939-9dff-b4918184c632/boot" > Installing for x86_64-efi platform. > File descriptor 4 (/dev/vdd1) leaked on vgs invocation. Parent PID 10249: > grub-install > You have a memory leak (not released memory pool): > [0x7fcace1b3f80] dtree > Internal error: Unreleased memory pool(s) found. > File descriptor 4 (/dev/vdd1) leaked on vgs invocation. Parent PID 10249: > grub-install > You have a memory leak (not released memory pool): > [0x7fcace1b3f80] dtree > Internal error: Unreleased memory pool(s) found. > Installation finished. No error reported.