openzfs / zfs

OpenZFS on Linux and FreeBSD
https://openzfs.github.io/openzfs-docs
Other
10.55k stars 1.74k forks source link

The name of the block device created by zfs changes after ubuntu18 restart #11028

Closed httaotao closed 4 years ago

httaotao commented 4 years ago

Sorry to disturb, because I encountered an unsolvable problem when using zfs. The name of the block device created by zfs changes after ubuntu18 restart . For example:

when I use the command to create zfs volume:

sudo zfs create -V 1M -o compression=on gpool/DATA/glusterfs/k8s-1m-stg

'gpool/DATA/glusterfs' is a pool path.Then I find out the devices created by zfs,such as

$ sudo ls -ls /dev/zvol/gpool/DATA/glusterfs/k8s-*                                                                     
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-10m-test -> ../../../../zd48                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-12m-test -> ../../../../zd112                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-19m-test -> ../../../../zd176                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-1g-test -> ../../../../zd192                                       
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-1m-test -> ../../../../zd96                                        
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-22m-test -> ../../../../zd144                                      
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-29m-test -> ../../../../zd80                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-2g-test -> ../../../../zd272                                       
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-2m-test -> ../../../../zd16                                        
0 lrwxrwxrwx 1 root root 17 Oct  8 09:13 /dev/zvol/gpool/DATA/glusterfs/k8s-33m-test -> ../../../../zd288                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:14 /dev/zvol/gpool/DATA/glusterfs/k8s-34m-test -> ../../../../zd304                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-35m-test -> ../../../../zd224                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-3g-test -> ../../../../zd240                                       
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-3m-test -> ../../../../zd32                                        
0 lrwxrwxrwx 1 root root 16 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-4g-test -> ../../../../zd64                                        
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-500-test -> ../../../../zd208                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-600m-test -> ../../../../zd160                                     
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-700m-test -> ../../../../zd256                                     
0 lrwxrwxrwx 1 root root 17 Oct  8 08:52 /dev/zvol/gpool/DATA/glusterfs/k8s-stg -> ../../../../zd128   

But when I restart the system ubuntu18.04, the devices will change,like that

$ sudo ls -ls /dev/zvol/gpool/DATA/glusterfs/k8s-*                                                                     
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-10m-test -> ../../../../zd48                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-12m-test -> ../../../../zd128                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-19m-test -> ../../../../zd192                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-1g-test -> ../../../../zd208                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-1m-test -> ../../../../zd112                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-22m-test -> ../../../../zd160                                      
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-29m-test -> ../../../../zd80                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-2g-test -> ../../../../zd304                                       
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-2m-test -> ../../../../zd16                                        
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-33m-test -> ../../../../zd96                                       
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-34m-test -> ../../../../zd224                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-35m-test -> ../../../../zd256                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-3g-test -> ../../../../zd272                                       
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-3m-test -> ../../../../zd32                                        
0 lrwxrwxrwx 1 root root 16 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-4g-test -> ../../../../zd64                                        
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-500-test -> ../../../../zd240                                      
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-600m-test -> ../../../../zd176                                     
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-700m-test -> ../../../../zd288                                     
0 lrwxrwxrwx 1 root root 17 Oct  8 09:19 /dev/zvol/gpool/DATA/glusterfs/k8s-stg -> ../../../../zd144     

I don't know why does it happen. I also guess may the Linux kernel problem ,because when I install zfs, it also happened. The content of the configuration file is as follows

#/etc/default/zfs
ZFS_MOUNT='yes'
ZFS_UNSHARE='yes'
ZFS_UNMOUNT='yes
ZFS_SHARE='yes'
ZFS_UNSHARE='yes'
ZPOOL_IMPORT_ALL_VISIBLE='no
USE_DISK_BY_ID='yes'
VERBOSE_MOUNT='no'
DO_OVERLAY_MOUNTS='no'
ZPOOL_IMPORT_OPTS=""
MOUNT_EXTRA_OPTIONS=""
ZFS_DKMS_ENABLE_DEBUG='no'
ZFS_DKMS_DISABLE_STRIP='no'
ZFS_INITRD_PRE_MOUNTROOT_SLEEP='0'
ZFS_INITRD_POST_MODPROBE_SLEEP='0'

Finally, this is the zpool status infomation

  pool: bpool
 state: ONLINE
status: Some supported features are not enabled on the pool. The pool can
    still be used, but some features are unavailable.
action: Enable all features using 'zpool upgrade'. Once this is done,
    the pool may no longer be accessible by software that does not support
    the features. See zpool-features(5) for details.
  scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    bpool       ONLINE       0     0     0
      raidz2-0  ONLINE       0     0     0
        sda2    ONLINE       0     0     0
        sdb2    ONLINE       0     0     0
        sdc2    ONLINE       0     0     0
        sdd2    ONLINE       0     0     0
        sde2    ONLINE       0     0     0
        sdf2    ONLINE       0     0     0
        sdg2    ONLINE       0     0     0
        sdh2    ONLINE       0     0     0
        sdi2    ONLINE       0     0     0
        sdj2    ONLINE       0     0     0
        sdk2    ONLINE       0     0     0
    spares
      sdl2      AVAIL   

errors: No known data errors

  pool: gpool
 state: ONLINE
  scan: none requested
config:

    NAME                              STATE     READ WRITE CKSUM
    gpool                             ONLINE       0     0     0
      raidz2-0                        ONLINE       0     0     0
        wwn-0x5000cca278806fd4-part4  ONLINE       0     0     0
        wwn-0x5000cca27881b534-part4  ONLINE       0     0     0
        wwn-0x5000cca26f82f34c-part4  ONLINE       0     0     0
        wwn-0x5000cca27881ec1c-part4  ONLINE       0     0     0
        wwn-0x5000cca2918a0c30-part4  ONLINE       0     0     0
        wwn-0x5000cca29188949c-part4  ONLINE       0     0     0
        wwn-0x5000cca2918a1d44-part4  ONLINE       0     0     0
        wwn-0x5000cca2918a5f50-part4  ONLINE       0     0     0
        wwn-0x5000cca2918a8c9c-part4  ONLINE       0     0     0
        wwn-0x5000cca291898414-part4  ONLINE       0     0     0
        wwn-0x5000cca2918a9a4c-part4  ONLINE       0     0     0
    spares
      wwn-0x5000cca291859ad4-part4    AVAIL   

errors: No known data errors

  pool: hpool
 state: ONLINE
  scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    hpool       ONLINE       0     0     0
      raidz2-0  ONLINE       0     0     0
        sda5    ONLINE       0     0     0
        sdb5    ONLINE       0     0     0
        sdc5    ONLINE       0     0     0
        sdd5    ONLINE       0     0     0
        sde5    ONLINE       0     0     0
        sdf5    ONLINE       0     0     0
        sdg5    ONLINE       0     0     0
        sdh5    ONLINE       0     0     0
        sdi5    ONLINE       0     0     0
        sdj5    ONLINE       0     0     0
        sdk5    ONLINE       0     0     0
    spares
      sdl5      AVAIL   

errors: No known data errors

  pool: rpool
 state: ONLINE
  scan: none requested
config:

    NAME        STATE     READ WRITE CKSUM
    rpool       ONLINE       0     0     0
      raidz2-0  ONLINE       0     0     0
        sda3    ONLINE       0     0     0
        sdb3    ONLINE       0     0     0
        sdc3    ONLINE       0     0     0
        sdd3    ONLINE       0     0     0
        sde3    ONLINE       0     0     0
        sdf3    ONLINE       0     0     0
        sdg3    ONLINE       0     0     0
        sdh3    ONLINE       0     0     0
        sdi3    ONLINE       0     0     0
        sdj3    ONLINE       0     0     0
        sdk3    ONLINE       0     0     0
    spares
      sdl3      AVAIL   

errors: No known data errors
0xFelix commented 4 years ago

Why is it a problem? Just use the symbolic link created by ZFS instead of an absolute /dev/zdX path?

httaotao commented 4 years ago

Why is it a problem? Just use the symbolic link created by ZFS instead of an absolute /dev/zdX path?

Sorry, I don't know how to use the symbolic link created by ZFS.what's the command like? thanks.

drbraden commented 4 years ago

Sorry, I don't know how to use the symbolic link created by ZFS.what's the command like? thanks.

For example, if you need to reference k8s-1m-stg, use gpool/DATA/glusterfs/k8s-1m-stg (or /dev/zvol1/gpool/DATA/glusterfs/k8s-1m-stg depending on what you are doing).

That symbolic link will point at the correct device, regardless of how it is named during boot.