Skip to content

GRUB fails to resolve canonical path to device, uses invalid partition and fails to detect zfs #5

@seletskiy

Description

@seletskiy

Let's suppose following scenario:

I've want to create zpool that use entire device /dev/sda:

# ls -al /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001   
lrwxrwxrwx 1 root root 9 Dec 31 15:46 /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001 -> ../../sda

I'm using by-id path to disk while creating zpool:

# zpool create zroot /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001
# zpool status
  pool: zroot
 state: ONLINE
  scan: none requested
config:

    NAME                         STATE     READ WRITE CKSUM
    zroot                        ONLINE       0     0     0
      ata-QEMU_HARDDISK_QM00001  ONLINE       0     0     0

errors: No known data errors

# zfs list
NAME    USED  AVAIL  REFER  MOUNTPOINT
zroot   110K  3.91G    30K  /zroot

zroot is mounted into /zroot.

So, trying to grub-probe:

# grub-probe /zroot
grub-probe: error: failed to get canonical path of `/dev/ata-QEMU_HARDDISK_QM00001'.

Wut? So, GRUB detected that /zroot is a ZFS (otherwise, how did it know about ata-QEMU stuff?), but if fails to resolve correct path to device.

OK, let's try to fix it in a dirty way:

# ln -s /dev/sda /dev/ata-QEMU_HARDDISK_QM00001
# grub-probe /zroot
grub-probe: error: unknown filesystem.
# grub-probe -vv /zroot
grub-core/kern/fs.c:56: Detecting zfs...
grub-core/osdep/hostdisk.c:319: opening the device `/dev/sda' in open_device()
grub-core/fs/zfs/zfs.c:1183: label ok 0
grub-core/fs/zfs/zfs.c:1183: label ok 1
...
grub-core/kern/fs.c:78: zfs detection failed.

Didn't work. Hmmm... Looks like grub-probe tries to read from /dev/sda.
Take a look:

# zdb -l /dev/sda 
--------------------------------------------
LABEL 0
--------------------------------------------
failed to unpack label 0
--------------------------------------------
LABEL 1
--------------------------------------------
failed to unpack label 1
--------------------------------------------
...

 # fdisk -l /dev/sda
Device           Start          End Size Type
/dev/sda1         2048      8370175   4G Solaris /usr & Apple ZFS
/dev/sda9      8370176      8386559   8M Solaris reserved 1

# zdb -l /dev/sda1

--------------------------------------------
LABEL 0
--------------------------------------------
    version: 5000
    name: 'zroot'
    state: 0
    txg: 4
    pool_guid: 16263322471539432696
    hostname: 'archiso'
    top_guid: 9383719665143350581
    guid: 9383719665143350581
...

Indeed!

# ln -sf /dev/sda1 /dev/ata-QEMU_HARDDISK_QM00001
# grub-probe /zroot
zfs

After that series of hacks I can do grub-install and it finishes successfully.

So, my suggestion is that GRUB uses incorrect device path when zpool is created over entire device.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions