Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Error grub-mkconfig with zfs and UEFI
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
jarek.w
n00b
n00b


Joined: 15 Jun 2021
Posts: 10

PostPosted: Thu Sep 30, 2021 8:17 am    Post subject: Error grub-mkconfig with zfs and UEFI Reply with quote

I got an error when I tried to generate new grub.cfg after a kernel upgrade:
Code:
# grub-mkconfig -o /boot/grub/grub.cfg

/usr/sbin/grub-probe: nvlist_lookup_string ("path"): No such file or directory


The problem is in the grub-probe. For example the same message is for:
Code:
# grub-probe --target=fs / -vv

grub-probe: info: cannot open `/boot/grub/device.map': No such file or directory.
grub-probe: nvlist_lookup_string ("path"): No such file or directory


When I changed the path parameter the problem disappeared:
Code:
# grub-probe --target=fs /boot   

fat


I think the error comes from grub-core/osdep/unix/getroot.c in the grub2 project - https://git.savannah.gnu.org/git/grub.git
Code:
  for (i = 0; i < nvlist_count; i++)
    {
      if (nvlist_lookup_string (children[i], "path", &device) != 0)
        error (1, errno, "nvlist_lookup_string (\"path\")");


The grub-mkconfig works fine after I've changed the script (/usr/sbin/grub-mkconfig) from:
Code:
# Device containing our userland.  Typically used for root= parameter.
GRUB_DEVICE="`${grub_probe} --target=device /`"

to:
Code:
# Device containing our userland.  Typically used for root= parameter.
GRUB_DEVICE="`${grub_probe} --target=device /boot`"


But In my opinion it is an ugly workaround. Do I have a bad configuration or is this a bug in GRUB project?
I have zfs for the root partition and FAT32 for the boot partition. My configuration is:
Code:
# fdisk -l

Disk /dev/nvme0n1: 238.47 GiB, 256060514304 bytes, 500118192 sectors
Disk model: SAMSUNG MZALQ256HAJD-000L2             
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: 1F2F6212-531B-47C0-B49E-2895C5B62A65
                                                                                                                                   
Device            Start       End   Sectors  Size Type                                                                             
/dev/nvme0n1p1     2048   3147775   3145728  1.5G EFI System                                                                       
/dev/nvme0n1p3  3147776  45090815  41943040   20G Linux filesystem
/dev/nvme0n1p4 45090816  53479423   8388608    4G Linux filesystem
/dev/nvme0n1p5 53479424 500116143 446636720  213G Linux filesystem


Disk /dev/sda: 931.51 GiB, 1000204886016 bytes, 1953525168 sectors
Disk model: ST1000DM010-2EP1
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: gpt
Disk identifier: C93C0962-62B8-184A-A7E7-381565D0FB0A

Device          Start        End    Sectors   Size Type
/dev/sda1        2048 1953507327 1953505280 931.5G Solaris /usr & Apple ZFS
/dev/sda9  1953507328 1953523711      16384     8M Solaris reserved 1


Code:
# cat /etc/fstab

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

/dev/cdrom              /mnt/cdrom              auto            noauto,ro,user                          0 0
/dev/nvme0n1p1          /boot                   vfat            noauto,noatime                          1 2
/dev/nvme0n1p3          none                    swap            sw                                      0 0


Code:
# zpool status

  pool: home_pool
 state: ONLINE
config:

        NAME                                                    STATE     READ WRITE CKSUM
        home_pool                                               ONLINE       0     0     0
          ata-ST1000DM010-2EP102_ZN1GQRSE                       ONLINE       0     0     0
        logs
          nvme-SAMSUNG_MZALQ256HAJD-000L2_S4ULNF0N449926-part4  ONLINE       0     0     0

errors: No known data errors

  pool: rpool
 state: ONLINE
  scan: scrub repaired 0B in 00:00:22 with 0 errors on Mon Jul  5 09:00:23 2021
config:

        NAME                                                    STATE     READ WRITE CKSUM
        rpool                                                   ONLINE       0     0     0
          nvme-SAMSUNG_MZALQ256HAJD-000L2_S4ULNF0N449926-part5  ONLINE       0     0     0

errors: No known data errors


Code:
# zfs list

NAME                  USED  AVAIL     REFER  MOUNTPOINT
home_pool             154G   745G       96K  /home_pool
home_pool/HOME        154G   745G       96K  none
home_pool/HOME/home   154G   745G      154G  /home
rpool                21.9G   183G       96K  /
rpool/ROOT           21.9G   183G       96K  none
rpool/ROOT/rootfs    13.3G   183G     13.3G  /
rpool/ROOT/var       8.54G   183G     8.54G  /var


I modified the /etc/default/grub by adding a line
Code:
GRUB_CMDLINE_LINUX="root=ZFS=rpool/ROOT/rootfs"

The full file:
Code:
# cat /etc/default/grub

# Copyright 1999-2020 Gentoo Authors
# Distributed under the terms of the GNU General Public License v2
#
# To populate all changes in this file you need to regenerate your
# grub configuration file afterwards:
#     'grub-mkconfig -o /boot/grub/grub.cfg'
#
# See the grub info page for documentation on possible variables and
# their associated values.

GRUB_DISTRIBUTOR="Gentoo"

# Default menu entry
#GRUB_DEFAULT=0

# Boot the default entry this many seconds after the menu is displayed
#GRUB_TIMEOUT=5
#GRUB_TIMEOUT_STYLE=menu

# Append parameters to the linux kernel command line
GRUB_CMDLINE_LINUX="root=ZFS=rpool/ROOT/rootfs"

#
# Examples:
#
# Boot with network interface renaming disabled
# GRUB_CMDLINE_LINUX="net.ifnames=0"
#
# Boot with systemd instead of sysvinit (openrc)
# GRUB_CMDLINE_LINUX="init=/usr/lib/systemd/systemd"

# Append parameters to the linux kernel command line for non-recovery entries
#GRUB_CMDLINE_LINUX_DEFAULT=""

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal.
# Note that you can use only modes which your graphic card supports via VBE.
# You can see them in real GRUB with the command `vbeinfo'.
#GRUB_GFXMODE=640x480

# Set to 'text' to force the Linux kernel to boot in normal text
# mode, 'keep' to preserve the graphics mode set using
# 'GRUB_GFXMODE', 'WIDTHxHEIGHT'['xDEPTH'] to set a particular
# graphics mode, or a sequence of these separated by commas or
# semicolons to try several modes in sequence.
#GRUB_GFXPAYLOAD_LINUX=

# Path to theme spec txt file.
# The starfield is by default provided with use truetype.
# NOTE: when enabling custom theme, ensure you have required font/etc.
#GRUB_THEME="/boot/grub/themes/starfield/theme.txt"

# Background image used on graphical terminal.
# Can be in various bitmap formats.
#GRUB_BACKGROUND="/boot/grub/mybackground.png"

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to kernel
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY=true

# Uncomment to disable generation of the submenu and put all choices on
# the top-level menu.
# Besides the visual affect of no sub menu, this makes navigation of the
# menu easier for a user who can't see the screen.
#GRUB_DISABLE_SUBMENU=y

# Uncomment to play a tone when the main menu is displayed.
# This is useful, for example, to allow users who can't see the screen
# to know when they can make a choice on the menu.
#GRUB_INIT_TUNE="60 800 1"
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Sep 30, 2021 9:23 am    Post subject: Reply with quote

Hi
zfs looses symlinks.
Could all this be caused by a broken symlink some place?
was your rpool created with
Code:

-O dnodesize=auto -O normalization=formD -O relatime=on -O xattr=sa

?
I found if you use this you will not have a problem with broken symlinks.
Just a thought..........
_________________
:)
Back to top
View user's profile Send private message
jarek.w
n00b
n00b


Joined: 15 Jun 2021
Posts: 10

PostPosted: Thu Sep 30, 2021 10:20 am    Post subject: Reply with quote

Hi, thank you for your response.
The only difference in the attributes is a value of the relatime. For rpool the values are:
Code:
$ zfs get all rpool | grep "dnodesize\|normalization\|atime\|xattr"

rpool  atime                 off                    local
rpool  xattr                 sa                     local
rpool  normalization         formD                  -
rpool  dnodesize             auto                   local
rpool  relatime              off                    default

but for the root file system volume the relatime is on:
Code:
$ zfs get all rpool/ROOT/rootfs | grep "dnodesize\|normalization\|atime\|xattr"

rpool/ROOT/rootfs  atime                 off                     inherited from rpool
rpool/ROOT/rootfs  xattr                 sa                      inherited from rpool
rpool/ROOT/rootfs  normalization         formD                   -
rpool/ROOT/rootfs  dnodesize             auto                    inherited from rpool
rpool/ROOT/rootfs  relatime              on                      temporary


I tried to find any broken symlinks with
Code:
find / -xtype l -print

but I found only in the proc fs like :
Code:
/proc/2/task/2/exe
/proc/2/exe
...

in /run like:
Code:
/run/udev/watch/65
...

and two more in the home_pool:
/home/user/.thunderbird/xxxxx.default-release/lock
/home/user/.mozilla/firefox/xxxxx.default-esr/lock

Should I change the value of the relatime for the rpool?
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Thu Sep 30, 2021 3:47 pm    Post subject: Reply with quote

Not likely being the cause.
Maybe re-emerge and reinstall grub making sure it is built with USE="libzfs"
But before you do that just try
Code:

ZPOOL_VDEV_NAME_PATH=1 grub-mkconfig -o /boot/grub/grub.cfg

if it works no need to reemerge grub just add
Code:

export ZPOOL_VDEV_NAME_PATH=YES

in /etc/profile
plz see
https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS/5-bootloader.html#apply-workarounds
_________________
:)
Back to top
View user's profile Send private message
jarek.w
n00b
n00b


Joined: 15 Jun 2021
Posts: 10

PostPosted: Fri Oct 01, 2021 5:40 am    Post subject: Reply with quote

Unfortunately setting the variable ZPOOL_VDEV_NAME_PATH doesn't work:
Code:
# ZPOOL_VDEV_NAME_PATH=1 grub-mkconfig -o /boot/grub/grub.cfg

/usr/sbin/grub-probe: nvlist_lookup_string ("path"): No such file or directory

# ZPOOL_VDEV_NAME_PATH=YES grub-mkconfig -o /boot/grub/grub.cfg

/usr/sbin/grub-probe: nvlist_lookup_string ("path"): No such file or directory


It seems that GRUB is built with USE="libzfs":
Code:
$ equery u grub
[ Legend : U - final flag setting for installation]
[        : I - package is installed with flag     ]
[ Colors : set, unset                             ]
 * Found these USE flags for sys-boot/grub-2.06-r1:
 U I
 - - device-mapper            : Enable support for device-mapper from sys-fs/lvm2
 - - doc                      : Add extra documentation (API, Javadoc, etc). It is recommended to enable per package instead of
                                globally
 - - efiemu                   : Build and install the efiemu runtimes
 + + fonts                    : Build and install fonts for the gfxterm module
 - - grub_platforms_coreboot  : Coreboot platform support
 - - grub_platforms_efi-32    : EFI 32 bit platform support (Old MACs)
 + + grub_platforms_efi-64    : EFI 64 bit platform support
 - - grub_platforms_emu       : Emulation platform support
 - - grub_platforms_ieee1275  : IEEE1275 platform support
 - - grub_platforms_loongson  : MIPS loongson platform support
 - - grub_platforms_multiboot : Multiboot platform support
 - - grub_platforms_pc        : PC platform support
 - - grub_platforms_qemu      : QEMU platform support
 - - grub_platforms_qemu-mips : QEMU MIPS platform support
 - - grub_platforms_uboot     : U-Boot platform support
 - - grub_platforms_xen       : XEN (pvgrub2) platform support
 - - grub_platforms_xen-32    : Build 32-bit XEN (pvgrub2) platform support on amd64
 - - grub_platforms_xen-pvh   : XEN (pvhgrub2) platform support
 + + libzfs                   : Enable support for sys-fs/zfs
 - - mount                    : Build and install the grub-mount utility
 + + nls                      : Add Native Language Support (using gettext - GNU locale utilities)
 - - sdl                      : Add support for Simple Direct Layer (media library)
 + + themes                   : Build and install GRUB themes (starfield)
 - - truetype                 : Build and install grub-mkfont conversion utility


I will try to upgrade the system and recompile GRUB.
Back to top
View user's profile Send private message
alamahant
Advocate
Advocate


Joined: 23 Mar 2019
Posts: 3879

PostPosted: Fri Oct 01, 2021 9:44 am    Post subject: Reply with quote

Can you plz try
Code:

zpool set bootfs=rpool/ROOT/rootfs rpool

_________________
:)
Back to top
View user's profile Send private message
jarek.w
n00b
n00b


Joined: 15 Jun 2021
Posts: 10

PostPosted: Fri Oct 01, 2021 10:54 am    Post subject: Reply with quote

Thank you very much for your help. I've already done the folowing things:

  • upgraded the system,
  • rebuilt grub,
  • set bootfs property and ZPOOL_VDEV_NAME_PATH env

but the grub-mkconfig still cannot generate the grub.cfg. Still it shows the same error.
Thanks for the link
alamahant wrote:
plz see
https://openzfs.github.io/openzfs-docs/Getting%20Started/Arch%20Linux/Root%20on%20ZFS/5-bootloader.html#apply-workarounds

I have a similar problem with setting the root property in kernel cmdline. That is why I added a following line in /etc/default/grub.
Code:
GRUB_CMDLINE_LINUX="root=ZFS=rpool/ROOT/rootfs"

My kernel cmdline is:
Code:
 linux   /vmlinuz-5.10.61-gentoo root=UUID=C5CE-86ED ro root=ZFS=rpool/ROOT/rootfs

So I think it is connected.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum