Package: grub-common Version: 2.02~beta2-9 Severity: wishlist Tags: patch Dear Maintainer,
Whilst legacy grub-mkdevicemap is still in use, I have noticed that it doesn't have support for NVMe devices. I've added the device pattern, for grub-mkdevicemap to probe NVMe devices following other similar devices. I've tested it using qemu-system, booted with UEFI edk2 firmware and an NVMe device, here are sample instructions: cd `mktemp -d` cp /usr/share/ovmf/OVMF.fd . qemu-system-x86_64 -pflash OVMF.fd -m 1024 -drive file=nvme.img,if=none,id=D22 -device nvme,drive=D22,serial=1234 --enable-kvm -ctrl-grab -cdrom trusty-desktop-amd64.iso With the attached patch grub-mkdevicemap produces result for the nvme drive. Patch was created on top of locally generated `patched-experimental` branch.
>From b6a40d729005631017ed63191b00cd8f710a434d Mon Sep 17 00:00:00 2001 From: Dimitri John Ledkov <[email protected]> Date: Tue, 29 Apr 2014 16:45:44 +0100 Subject: [PATCH] Add support for nvme device in grub-mkdevicemap. --- util/deviceiter.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/util/deviceiter.c b/util/deviceiter.c index b61715d..0f871e5 100644 --- a/util/deviceiter.c +++ b/util/deviceiter.c @@ -371,6 +371,12 @@ get_fio_disk_name (char *name, int unit) { sprintf (name, "/dev/fio%c", unit + 'a'); } + +static void +get_nvme_disk_name (char *name, int controller, int namespace) +{ + sprintf (name, "/dev/nvme%dn%d", controller, namespace); +} #endif static struct seen_device @@ -875,6 +881,29 @@ grub_util_iterate_devices (int (*hook) (const char *, int, void *), void *hook_d } } + /* This is for standard NVMe controllers + /dev/nvme<controller>n<namespace>p<partition>. No idea about + actual limits of how many controllers a system can have and/or + how many namespace that would be, 10 for now. */ + { + int controller, namespace; + + for (controller = 0; controller < 10; controller++) + { + for (namespace = 0; namespace < 10; namespace++) + { + char name[16]; + + get_nvme_disk_name (name, controller, namespace); + if (check_device_readable_unique (name)) + { + if (hook (name, 0, hook_data)) + goto out; + } + } + } + } + # ifdef HAVE_DEVICE_MAPPER # define dmraid_check(cond, ...) \ if (! (cond)) \ -- 1.9.1
Regards, Dimitri.

