set zfs’s property snapdir to hidden or visible see snapshot directory

2 minute read

背景

zfs的snapshot, 以往我们可以通过clone或者rollback来查看snapshot的内容. 当然不推荐rollback, 因为会导致zfs回退.  
其实还有一种方法来查看snapshot的内容, 那就是设置zfs的snapdir属性,  
如果开启了这个属性的话, 可以直接在zfs目录的.zfs中查看对应的snapshot的内容.  
默认snapdir=hidden, 所以.zfs是不可见的.  
修改成visible后, .zfs目录可见.  
[root@db-172-16-3-150 zpp]# zfs set snapdir=visible zpp/test  
  
[root@db-172-16-3-150 test]# zfs get all zpp/test|grep snapdir  
zpp/test  snapdir               visible                local  
[root@db-172-16-3-150 test]# zfs get all zpp/test  
NAME      PROPERTY              VALUE                  SOURCE  
zpp/test  type                  filesystem             -  
zpp/test  creation              Tue May 27 16:31 2014  -  
zpp/test  used                  86K                    -  
zpp/test  available             63.3M                  -  
zpp/test  referenced            30K                    -  
zpp/test  compressratio         1.00x                  -  
zpp/test  mounted               yes                    -  
zpp/test  quota                 none                   default  
zpp/test  reservation           none                   default  
zpp/test  recordsize            128K                   default  
zpp/test  mountpoint            /zpp/test              default  
zpp/test  sharenfs              off                    default  
zpp/test  checksum              on                     default  
zpp/test  compression           off                    default  
zpp/test  atime                 on                     default  
zpp/test  devices               on                     default  
zpp/test  exec                  on                     default  
zpp/test  setuid                on                     default  
zpp/test  readonly              off                    default  
zpp/test  zoned                 off                    default  
zpp/test  snapdir               visible                local  
zpp/test  aclinherit            restricted             default  
zpp/test  canmount              on                     default  
zpp/test  xattr                 on                     default  
zpp/test  copies                1                      default  
zpp/test  version               5                      -  
zpp/test  utf8only              off                    -  
zpp/test  normalization         none                   -  
zpp/test  casesensitivity       sensitive              -  
zpp/test  vscan                 off                    default  
zpp/test  nbmand                off                    default  
zpp/test  sharesmb              off                    default  
zpp/test  refquota              none                   default  
zpp/test  refreservation        none                   default  
zpp/test  primarycache          all                    default  
zpp/test  secondarycache        all                    default  
zpp/test  usedbysnapshots       56K                    -  
zpp/test  usedbydataset         30K                    -  
zpp/test  usedbychildren        0                      -  
zpp/test  usedbyrefreservation  0                      -  
zpp/test  logbias               latency                default  
zpp/test  dedup                 off                    default  
zpp/test  mlslabel              none                   default  
zpp/test  sync                  standard               default  
zpp/test  refcompressratio      1.00x                  -  
zpp/test  written               18K                    -  
zpp/test  snapdev               hidden                 default  
  
[root@db-172-16-3-150 ~]# zfs snapshot zpp/test@1  
[root@db-172-16-3-150 ~]# cd /zpp/test  
[root@db-172-16-3-150 test]# ll  
total 0  
[root@db-172-16-3-150 test]# touch a  
[root@db-172-16-3-150 test]# zfs snapshot zpp/test@2  
[root@db-172-16-3-150 test]# touch b  
[root@db-172-16-3-150 test]# zfs snapshot zpp/test@3  
  
[root@db-172-16-3-150 test]# ll -la /zpp/test/  
total 4  
drwxr-xr-x 2 root root 4 May 27 16:33 .  
drwxr-xr-x 3 root root 3 May 27 16:31 ..  
-rw-r--r-- 1 root root 0 May 27 16:33 a  
-rw-r--r-- 1 root root 0 May 27 16:33 b  
dr-xr-xr-x 1 root root 0 May 27 16:31 .zfs  
  
[root@db-172-16-3-150 test]# cd .zfs  
[root@db-172-16-3-150 .zfs]# ll  
total 0  
dr-xr-xr-x 2 root root 2 May 27 16:33 shares  
dr-xr-xr-x 2 root root 2 May 27 16:33 snapshot  
[root@db-172-16-3-150 .zfs]# cd snapshot/  
[root@db-172-16-3-150 snapshot]# ll  
total 0  
dr-xr-xr-x 1 root root 0 May 27 16:33 1  
dr-xr-xr-x 1 root root 0 May 27 16:34 2  
dr-xr-xr-x 1 root root 0 May 27 16:34 3  
[root@db-172-16-3-150 snapshot]# cd 2  
[root@db-172-16-3-150 2]# ll  
total 1  
-rw-r--r-- 1 root root 0 May 27 16:33 a  
[root@db-172-16-3-150 2]# cd ../3  
[root@db-172-16-3-150 3]# ll  
total 1  
-rw-r--r-- 1 root root 0 May 27 16:33 a  
-rw-r--r-- 1 root root 0 May 27 16:33 b  

Flag Counter

digoal’s 大量PostgreSQL文章入口