Personal tools
You are here: Home Issue tracker should we use /dev/disk/by-id or rather /dev/disk/by-path?

#77 — should we use /dev/disk/by-id or rather /dev/disk/by-path?

State Unconfirmed
Version: 0.6.9
Area Functionality
Issue type Bug
Severity Medium
Submitted by (anonymous)
Submitted on Jul 15, 2010
Responsible
Target release:
Return to tracker
Last modified on Jul 15, 2010
I ran into this issue while playing with zfs-fuse on a VMWare virtual machine:

1) zpool create testpool sdo sdp sdq
2) zpool export testpool
3) zpool import testpool # Doesn't show anything.

4) it works using this syntax:
zpool import -d /dev/disk/by-path testpool

The reason why it fails is as follows:
On VMware, virtual scsi disks do not support page80 inquiry and don't have a SCSI serial.
Look at this output difference:
VMWare SCSI disk:
# udevinfo -q all -n /dev/sdo
P: /block/sdo
N: sdo
S: disk/by-path/pci-0000:00:12.0-scsi-0:0:5:0
E: ID_VENDOR=VMware,
E: ID_MODEL=VMware_Virtual_S
E: ID_REVISION=1.0
E: ID_SERIAL=
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_PATH=pci-0000:00:12.0-scsi-0:0:5:0

Physical disk:
P: /block/sda
N: sda
S: disk/by-id/scsi-3600605b00164675012ae65f03a411442
S: disk/by-path/pci-0000:04:00.0-scsi-0:2:0:0
E: ID_VENDOR=LSI
E: ID_MODEL=MR9260-4i
E: ID_REVISION=2.70
E: ID_SERIAL=3600605b00164675012ae65f03a411442
E: ID_TYPE=disk
E: ID_BUS=scsi
E: ID_PATH=pci-0000:04:00.0-scsi-0:2:0:0

I'm using this simple patch to change the default directory and it fixes my problem:
*** zfs-fuse-0.6.9p1/src/cmd/zpool/zpool_main.c.orig 2010-06-30 01:47:26.000000000 +0200
--- zfs-fuse-0.6.9p1/src/cmd/zpool/zpool_main.c 2010-07-15 17:14:55.000000000 +0200
***************
*** 1739,1746 ****
        if (searchdirs == NULL) {
          struct stat s;
                searchdirs = safe_malloc(sizeof (char *));
! if ((0==stat("/dev/disk/by-id", &s)) && (S_ISDIR(s.st_mode)))
! searchdirs[0] = "/dev/disk/by-id";
          else
              searchdirs[0] = "/dev";
                nsearch = 1;
--- 1739,1746 ----
        if (searchdirs == NULL) {
          struct stat s;
                searchdirs = safe_malloc(sizeof (char *));
! if ((0==stat("/dev/disk/by-path", &s)) && (S_ISDIR(s.st_mode)))
! searchdirs[0] = "/dev/disk/by-path";
          else
              searchdirs[0] = "/dev";
                nsearch = 1;


I think (IMHO) it could be better to search several directories by default (first /dev/disk/by-id and then /dev/disk/by-path, maybe) for better handling of pool imports..

Thanks,

Vincent
Steps to reproduce:
1) create VMWare/Xen/KVM/VirtualBox VM with several SCSI disks
2) create a ZFS pool on them and export it.
3) you won't be able to re-import it unless you use this:
zpool import -d /dev/disk/by-path <pool>
(it's not -obvious- IMHO to do that for the administrator).