When I run sudo nixos-rebuild switch
I get this error installation of GRUB on /dev/nvme0n1p4 failed: Inappropriate ioctl for device
I found another similar issue on nix discourse but there was no reply and no solution posted issue. I’m brand new to nix and would appreciate and help thank you!
Share your grub config, whether you use UEFI or BIOS, and where your ESP is mounted.
I’m using UEFI my esp is /dev/nvme0n1p4 and here’s my grub.cfg (though it has a lot of entries that are different nix builds, I included them for completeness, I am using the most recent one atm)
`
search --set=drive1 --fs-uuid A3F5-584A
if [ -s $prefix/grubenv ]; then
load_env
fi
# ‘grub-reboot’ sets a one-time saved entry, which we process here and
# then delete.
if [ "${next_entry}" ]; then
set default="${next_entry}"
set next_entry=
save_env next_entry
set timeout=1
set boot_once=true
else
set default=0
set timeout=5
fi
set timeout_style=menu
function savedefault {
if [ -z "${boot_once}"]; then
saved_entry="${chosen}"
save_env saved_entry
fi
}
# Setup the graphics stack for bios and efi systems
if [ "${grub_platform}" = "efi" ]; then
insmod efi_gop
insmod efi_uga
else
insmod vbe
fi
insmod font
if loadfont ($drive1)//converted-font.pf2; then
insmod gfxterm
if [ "${grub_platform}" = "efi" ]; then
set gfxmode=auto
set gfxpayload=keep
else
set gfxmode=1024x768
set gfxpayload=text
fi
terminal_output gfxterm
fi
background_color '#2F302F'
insmod png
if background_image --mode 'normal' ($drive1)//background.png; then
set color_normal=white/black
set color_highlight=black/white
else
set menu_color_normal=cyan/blue
set menu_color_highlight=white/blue
fi
`
menuentry “NixOS” --class nixos --unrestricted {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/zmf3j2p11803msrjp5jgdqkln0gkjxsq-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
submenu “NixOS - All configurations” --class submenu {
menuentry “NixOS - Configuration 18 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/zmf3j2p11803msrjp5jgdqkln0gkjxsq-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 17 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/wrss9l4p6h8j4qdczmylkxxj7g9nj9kn-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 16 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/zmf3j2p11803msrjp5jgdqkln0gkjxsq-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 15 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/wrss9l4p6h8j4qdczmylkxxj7g9nj9kn-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 14 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/z3zc2wq5f3wl8vi7c79wirim522xl9ck-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 13 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/4fraqq78jc4yr5zgkaajyq8p1ahjvgjf-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 12 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/zmf3j2p11803msrjp5jgdqkln0gkjxsq-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 11 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/srlf9lsspg2nv7c66jn57y1vxh0xfj6n-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 10 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/zsna4hgy94fi0bb60mm3pmz6j797yx8l-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 9 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/19i2gh83vjaykzl2971rd6si23j460y8-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 8 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/272gx1imxwrw1znwb3ivi95mndv6yw1c-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 7 (2024-08-31 - 24.05.4469.6e99f2a27d60)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/bmyh7a4j9xim7xxc5x1qk1qvlb2y7186-linux-6.6.48-bzImage init=/nix/store/jw0ypf2sq6sk50wj1bw6qqwabl5xkh32-nixos-system-nixos-24.05.4469.6e99f2a27d60/init loglevel=4
initrd ($drive1)//kernels/jmr0mlyaqarnnrmmy3f0v9p73kq2s5qf-initrd-linux-6.6.48-initrd
}
menuentry “NixOS - Configuration 6 (2024-08-31 - 24.05.4396.ae2fc9e0e42c)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/1zr1wgz8lnfl5bjdqj35halgqvvrkh1g-linux-6.6.47-bzImage init=/nix/store/84jqjwjzd5b5f2a4q1ajal4lpm358d8z-nixos-system-nixos-24.05.4396.ae2fc9e0e42c/init loglevel=4
initrd ($drive1)//kernels/asc63a401bivcyl45anmfmgp4zcqp68p-initrd-linux-6.6.47-initrd
}
menuentry “NixOS - Configuration 5 (2024-08-31 - 24.05.4396.ae2fc9e0e42c)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/1zr1wgz8lnfl5bjdqj35halgqvvrkh1g-linux-6.6.47-bzImage init=/nix/store/0ar1y32yr2pigw8d9s6qm3bs9qw4x2cl-nixos-system-nixos-24.05.4396.ae2fc9e0e42c/init loglevel=4
initrd ($drive1)//kernels/asc63a401bivcyl45anmfmgp4zcqp68p-initrd-linux-6.6.47-initrd
}
menuentry “NixOS - Configuration 4 (2024-08-30 - 24.11.20240828.71e91c4)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/g2jkfv566lz06ikfrik3cjlqk66i04i6-linux-6.6.47-bzImage init=/nix/store/9v9iw02pz41mkn89qq14kv7ynhxks0b2-nixos-system-nixos-24.11.20240828.71e91c4/init loglevel=4
initrd ($drive1)//kernels/y8blc7p2i6zvq4aagcy9shygywbsmrrp-initrd-linux-6.6.47-initrd
}
menuentry “NixOS - Configuration 3 (2024-08-30 - 24.05.4396.ae2fc9e0e42c)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/1zr1wgz8lnfl5bjdqj35halgqvvrkh1g-linux-6.6.47-bzImage init=/nix/store/2lgznhr4lfd4qig1skpkkpgln54jma6b-nixos-system-nixos-24.05.4396.ae2fc9e0e42c/init loglevel=4
initrd ($drive1)//kernels/asc63a401bivcyl45anmfmgp4zcqp68p-initrd-linux-6.6.47-initrd
}
menuentry “NixOS - Configuration 2 (2024-08-30 - 24.05.4396.ae2fc9e0e42c)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/1zr1wgz8lnfl5bjdqj35halgqvvrkh1g-linux-6.6.47-bzImage init=/nix/store/fija593160xsvb2wqrqi8127lhlgqv6w-nixos-system-nixos-24.05.4396.ae2fc9e0e42c/init loglevel=4
initrd ($drive1)//kernels/asc63a401bivcyl45anmfmgp4zcqp68p-initrd-linux-6.6.47-initrd
}
menuentry “NixOS - Configuration 1 (2024-08-30 - 24.05.4396.ae2fc9e0e42c)” --class nixos {
search --set=drive1 --fs-uuid A3F5-584A
linux ($drive1)//kernels/1zr1wgz8lnfl5bjdqj35halgqvvrkh1g-linux-6.6.47-bzImage init=/nix/store/f5w31qbmi4yh3si75qbk5dpdp58isczi-nixos-system-nixos-24.05.4396.ae2fc9e0e42c/init loglevel=4
initrd ($drive1)//kernels/asc63a401bivcyl45anmfmgp4zcqp68p-initrd-linux-6.6.47-initrd
}
}
menuentry ‘Windows Boot Manager (on /dev/nvme0n1p1)’ --class windows --class os $menuentry_id_option ‘osprober-efi-40CF-F8F7’ {
insmod part_gpt
insmod fat
search --no-floppy --fs-uuid --set=root 40CF-F8F7
chainloader /efi/Microsoft/Boot/bootmgfw.efi
}
`
Where is your ESP mounted at? /boot or elsewhere?
And by config I meant your NixOS config related to grub or the ESP.
sorry, as i said i’m new here, esp is mounted to /boot
here is the relevant (as far as I’m aware) nix config for grub
boot.loader.systemd-boot .enable = false;
boot.loader.grub.device = "/dev/nvme0n1p4";
boot.loader.grub.enable = true;
boot.loader.grub.efiSupport = true;
boot.loader.grub.useOsProber = true;
I am dual booting and have a second efi partition with the windows boot loader which is why i’m using the full parition path instead of device path
You actually want "nodev"
when using EFI, as you’re also using an ESP (implying GPT) rather than installing grub to the MBR - hence you do not want to specify a device here.
Also, dual-booting has nothing to do with having multiple EFI partitions. By default I would recommend only having one ESP that has all the bootloaders, as some firmwares get confused by seeing multiple, but if it works it works I suppose. (People also assume you need to use grub to dual-boot with windows, also untrue.)
Thank you this resolved the issue for me, I appreciate the help.