Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pool imported as sdX instead of /dev/disk/by-id #3043

Closed
azeemism opened this issue Jan 27, 2015 · 17 comments
Closed

Pool imported as sdX instead of /dev/disk/by-id #3043

azeemism opened this issue Jan 27, 2015 · 17 comments
Milestone

Comments

@azeemism
Copy link

Hi,

Exporting then importing a pool shows devices listed as sdX under zpool status.

Pool was created as
zpool create spool mirror /dev/disk/by-id/... /dev/disk/by-id/...

Unless the -d options is used each time the pool is imported.
zpool import -d /dev/disk/by-id spool

This is not the case with v0.6.3-766_gfde0d6d.

Not sure if this is somehow related to,
#2482

Using:
VirtualBox
(fresh install) Debian Jessie
(dailies) zfs v0.6.3-222d9d57jessie

Thanks,

Azeem

@azeemism
Copy link
Author

I can now report that after the dailies fix,

zfsonlinux/pkg-zfs#138

If a pool is export it is imported back automatically with /dev/disk/by-id after a reboot (tested in VirtualBox). This wasn't the case before the fix.

However if the pool is imported manually, unless the "-d /dev/disk/by-id" option is used it gets imported as /dev/sdX.


It would be nice if "zpool import tank" remembered the disk naming format from either,

zpool create tank mirror /dev/disk/by-id /dev/disk/by-id

Or a previous import,

zpool import -d /dev/disk/by-id tank

But that is a minor concern.

@FransUrbo
Copy link
Contributor

However if the pool is imported manually, unless the "-d /dev/disk/by-id" option is used it gets imported as /dev/sdX.

This is most likely due to the zpool.cache file. Try setting 'cachefile=none' on your pool(s) and, if it's still there, remove /etc/zfs/zpool.cache and recreate the initrd.

Also, make sure that USE_DISK_BY_ID='yes' in /etc/default/zfs (before recreating the initrd).=

@azeemism
Copy link
Author

Okay will try this out right now.

I assume the command to recreate the initrd is,

mv initrd.img-3.16.0-4-amd64 initrd.img-3.16.0-4-amd64.old
update-initramfs -c -k all

@azeemism
Copy link
Author

No change. An exported pool is always imported back as /dev/disk/by-id after reboot.'zpool import spool' is always imported as /dev/sdX

I am assuming it is better to have 'cachefile=none' specified as the default look to be '-', so I guess I should specify this setting moving on for all pool creation.


nano /etc/default/zfs
USE_DISK_BY_ID='yes'
Is the default setting which is good.

zpool set cachefile=none spool
Automatically deleted /etc/zfs/zpool.cache
At reboot zpool.cache was recreated

update-initramfs -c -k all

@nicko88
Copy link

nicko88 commented Feb 2, 2015

@Bronek
Copy link

Bronek commented Nov 15, 2015

I was experiencing identical issue until I removed zpool import -aN from initramfs ZFS hook of my system. After removing this command, my pools (except for root filesystem) are imported using zpool import -c /etc/zfs/zpool.cache -aN only. Since then the device names in my pools are no longer replaced with /dev/sdX . I raised an issue in ZFS package for my Linux distribution to remove zpool import -aN : archzfs/archzfs#50 .

It is possible that this issue might also be caused by iniramfs script importing indiscriminately all pools at boot time, rather than using zpool.cache

@alexanderhaensch
Copy link

I ran into this problem recently.
Wouldn't it be best to default the command
zpool import $pool
to
zpool import -d /dev/by-id $pool

The legacy /dev/sdX is getting more and more unreliable.

@behlendorf
Copy link
Contributor

@alexanderhaensch you can change the default search order with the ZPOOL_IMPORT_PATH environment variable. See zpool.8.

       ZPOOL_IMPORT_PATH
              The  search path for devices or files to use with the pool. This
              is a colon-separated list of directories in  which  zpool  looks
              for  device  nodes and files.  Similar to the -d option in zpool
              import.

That said, you may be right and it's time to change the default. The primary reason it was left as /dev/ for so long was many of the distributions hasn't yet standardized on the /dev/disk/by-id/ convention. However, times are a changing and I can't think of a disro offland that doesn't ship with those udev rules.

It would be great if you set ZPOOL_IMPORT_PATH on your systems to simulate a change in the default search paths.

@alexanderhaensch
Copy link

@behlendorf setting the environment variable works great. Now i can import my pool much easier without having the sdX which is changing every boot. :)

@behlendorf
Copy link
Contributor

@alexanderhaensch what did you end up setting it to. The default search order is as follows starting with by-vdev.

char *
zpool_default_import_path[DEFAULT_IMPORT_PATH_SIZE] = {
        "/dev/disk/by-vdev",    /* Custom rules, use first if they exist */
        "/dev/mapper",          /* Use multipath devices before components */
        "/dev/disk/by-uuid",    /* Single unique entry and persistent */
        "/dev/disk/by-id",      /* May be multiple entries and persistent */
        "/dev/disk/by-path",    /* Encodes physical location and persistent */
        "/dev/disk/by-label",   /* Custom persistent labels */
        "/dev"                  /* UNSAFE device names will change */
};

@alexanderhaensch
Copy link

For some reason, the function zfs_resolve_shortname does not use vdev to label. On my system always /dev is used.

@alexanderhaensch
Copy link

I tested a little bit:
with ZPOOL_IMPORT_PATH="/dev/disk/by-id" :

config:

        NAME                                               STATE     READ WRITE CKSUM
        storage                                            ONLINE       0     0     0
          raidz1-0                                         ONLINE       0     0     0
            ata-ST3000VX000-1CU166_W1F4HC6Q                ONLINE       0     0     0
            ata-ST3000VX000-1CU166_W1F45XDY                ONLINE       0     0     0
            ata-ST3000VX000-1CU166_W1F45WV8                ONLINE       0     0     0

cache
          ata-Corsair_Force_GT_113882030000070000A4-part3  ONLINE       0     0     0 

with ZPOOL_IMPORT_PATH="/dev/disk/by-vdev" :

config:                                                                             
        NAME                                               STATE     READ WRITE CKSUM
        storage                                            ONLINE       0     0     0
          raidz1-0                                         ONLINE       0     0     0
            disk3                                          ONLINE       0     0     0
            disk2                                          ONLINE       0     0     0
            disk1                                          ONLINE       0     0     0
        cache
          ata-Corsair_Force_GT_113882030000070000A4-part3  ONLINE       0     0     0

without any ZPOOL_IMPORT_PATH :

config:
        NAME                                               STATE     READ WRITE CKSUM
        storage                                            ONLINE       0     0     0
          raidz1-0                                         ONLINE       0     0     0
            sdd                                            ONLINE       0     0     0
            sdf                                            ONLINE       0     0     0
            sda                                            ONLINE       0     0     0
        cache
          ata-Corsair_Force_GT_113882030000070000A4-part3  ONLINE       0     0     0

interestingly, the cache is always detected correct with the by-id name. It is the first matching entry. sda,sdd,sdf never match.

@rlaager
Copy link
Member

rlaager commented Apr 18, 2016

This came up in the Ubuntu bug tracker as well: https://bugs.launchpad.net/ubuntu/+source/zfs-linux/+bug/1571241

@samvde
Copy link

samvde commented Apr 19, 2016

Additional info (I logged the Ubuntu bug report): I was not able to get the ZPOOL_IMPORT_PATH working for the root filesystem on Ubuntu 16.04, i.e. adding it to /etc/default/zfs does not propagate this into the initrd.

@rlaager
Copy link
Member

rlaager commented Apr 19, 2016

Is zpool import ignoring zpool_default_import_path because of libblkid?

https://github.com/zfsonlinux/zfs/blob/8fc5674c522e22f0b97e4714bf5410e24d481afa/lib/libzfs/libzfs_import.c#L1599

behlendorf added a commit to behlendorf/zfs that referenced this issue Apr 20, 2016
When importing a pool using the blkid cache only the device
node path was added to the list of known paths for a device.
This results in 'zpool import' always using the sdX names
in preference to the 'path' name stored in the label.

To fix the issue the blkid import path has been updated to
add both the 'path', 'devid', and 'devname' names from the
label to known paths.  Sanity check is done to ensure these
paths do refer to the same device identified by blkid.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#3043
@behlendorf
Copy link
Contributor

@rlaager spot on, I've added a patch to the existing #4523 pull request to address this. At its core the patch adds any alternate paths to the device which are described by the vdev label. This will preserve the original name if the device still is accessible by that path.

@rlaager
Copy link
Member

rlaager commented Apr 21, 2016

@behlendorf I tested that patch. Applying only that patch fixes the issue observed in Ubuntu. That is, if I have a pool which was last imported using /dev/disk/by-id names, the patch causes zpool import to import it using /dev/disk/by-id names.

behlendorf added a commit to behlendorf/zfs that referenced this issue Apr 22, 2016
When importing a pool using the blkid cache only the device
node path was added to the list of known paths for a device.
This results in 'zpool import' always using the sdX names
in preference to the 'path' name stored in the label.

To fix the issue the blkid import path has been updated to
add both the 'path', 'devid', and 'devname' names from the
label to known paths.  Sanity check is done to ensure these
paths do refer to the same device identified by blkid.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue openzfs#3043
@behlendorf behlendorf added this to the 0.6.5.7 milestone Apr 25, 2016
nedbass pushed a commit to nedbass/zfs that referenced this issue May 6, 2016
When importing a pool using the blkid cache only the device
node path was added to the list of known paths for a device.
This results in 'zpool import' always using the sdX names
in preference to the 'path' name stored in the label.

To fix the issue the blkid import path has been updated to
add both the 'path', 'devid', and 'devname' names from the
label to the known paths.  A sanity check is done to ensure
these paths do refer to the same device identified by blkid.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#4523
Closes openzfs#3043
nedbass pushed a commit to nedbass/zfs that referenced this issue May 6, 2016
When importing a pool using the blkid cache only the device
node path was added to the list of known paths for a device.
This results in 'zpool import' always using the sdX names
in preference to the 'path' name stored in the label.

To fix the issue the blkid import path has been updated to
add both the 'path', 'devid', and 'devname' names from the
label to the known paths.  A sanity check is done to ensure
these paths do refer to the same device identified by blkid.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#4523
Closes openzfs#3043
ryao pushed a commit to ClusterHQ/zfs that referenced this issue Jun 7, 2016
When importing a pool using the blkid cache only the device
node path was added to the list of known paths for a device.
This results in 'zpool import' always using the sdX names
in preference to the 'path' name stored in the label.

To fix the issue the blkid import path has been updated to
add both the 'path', 'devid', and 'devname' names from the
label to the known paths.  A sanity check is done to ensure
these paths do refer to the same device identified by blkid.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Closes openzfs#4523
Closes openzfs#3043
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants