Friday Sep 26, 2008

Moving a ZFS filesystem

In a past life, I did the code for moving files/directories across a qtree in WAFL. The mv used to degrade to a copy because of the effective change in the fsid. The algorithm I used to combat this was to copy directories and move files. I had to copy the directories because we needed a source and destination target for the renames. And this would not leave us in an inconsistent state.

So I was all prepared for pain and hoops when I wanted to rename a ZFS filesystem on a test box. And I am happy to be dismayed that did not happen:

[root@jhereg ~]> zfs create pool/builds
[root@jhereg ~]> zfs list
NAME                           USED  AVAIL  REFER  MOUNTPOINT
pool                          59.9G  74.0G    22K  /builds
pool/builds                     18K  74.0G    18K  /builds/builds
pool/jasmith                  22.5G  74.0G   866K  /builds/jasmith
pool/jasmith/nfs41-instp       773M  74.0G   731M  /builds/jasmith/nfs41-instp
pool/jasmith/nfs41-instp-bld  11.4G  74.0G  11.7G  /builds/jasmith/nfs41-instp-bld
pool/jasmith/nfs41-open        767M  74.0G   712M  /builds/jasmith/nfs41-open
pool/jasmith/nfs41-open-bld   9.62G  74.0G  10.3G  /builds/jasmith/nfs41-open-bld
pool/webaker                  37.4G  74.0G  17.5G  /builds/webaker
pool/webaker/vbox0            7.46G  74.0G  7.46G  /builds/webaker/vbox0
pool/webaker/vbox_ds1         1.48G  74.0G  7.82G  /builds/webaker/vbox_ds1
pool/webaker/vbox_ds2           17K  74.0G    18K  /builds/webaker/vbox_ds2
pool/webaker/vbox_ds3          118M  74.0G  7.77G  /builds/webaker/vbox_ds3
pool/webaker/vbox_master      7.77G  74.0G  7.77G  /builds/webaker/vbox_master
pool/webaker/vbox_mds         3.07G  74.0G  8.99G  /builds/webaker/vbox_mds
[root@jhereg ~]> zfs rename pool/jasmith pool/builds/jasmith
[root@jhereg ~]> zfs list
NAME                                  USED  AVAIL  REFER  MOUNTPOINT
pool                                 59.9G  74.0G    23K  /builds
pool/builds                          22.5G  74.0G    18K  /builds/builds
pool/builds/jasmith                  22.5G  74.0G   866K  /builds/builds/jasmith
pool/builds/jasmith/nfs41-instp       773M  74.0G   731M  /builds/builds/jasmith/nfs41-instp
pool/builds/jasmith/nfs41-instp-bld  11.4G  74.0G  11.7G  /builds/builds/jasmith/nfs41-instp-bld
pool/builds/jasmith/nfs41-open        767M  74.0G   712M  /builds/builds/jasmith/nfs41-open
pool/builds/jasmith/nfs41-open-bld   9.62G  74.0G  10.3G  /builds/builds/jasmith/nfs41-open-bld
pool/webaker                         37.4G  74.0G  17.5G  /builds/webaker
pool/webaker/vbox0                   7.46G  74.0G  7.46G  /builds/webaker/vbox0
pool/webaker/vbox_ds1                1.48G  74.0G  7.82G  /builds/webaker/vbox_ds1
pool/webaker/vbox_ds2                  17K  74.0G    18K  /builds/webaker/vbox_ds2
pool/webaker/vbox_ds3                 118M  74.0G  7.77G  /builds/webaker/vbox_ds3
pool/webaker/vbox_master             7.77G  74.0G  7.77G  /builds/webaker/vbox_master
pool/webaker/vbox_mds                3.07G  74.0G  8.99G  /builds/webaker/vbox_mds

In all fairness to WAFL, I expect that with their virtual volumes, this type of operation is just as painless. The FSID of the filesystem is not really changing - just the point at which it is mounted in the name space. I.e., the operation is on the filesystem and not the individual files. We don;t have to recurse to change the inodes for each file.

Back to the great ZFS discussion. What I wanted to do was push the name space down for the existing sub-filesystems and yet keep the existing name space. I.e., I don't want pool mounted on /builds, but I still want to see /builds/jasmith. I can finish this off thusly:

[root@jhereg ~]> zfs rename pool/webaker pool/builds/webaker
[root@jhereg ~]> zfs list pool
NAME   USED  AVAIL  REFER  MOUNTPOINT
pool  59.9G  74.0G    23K  /builds
[root@jhereg ~]> zfs set mountpoint=/pool pool
[root@jhereg ~]> zfs set mountpoint=/builds pool/builds
[root@jhereg ~]> zfs list
NAME                                  USED  AVAIL  REFER  MOUNTPOINT
pool                                 59.9G  74.0G    21K  /pool
pool/builds                          59.9G  74.0G    21K  /builds
pool/builds/jasmith                  22.5G  74.0G   866K  /builds/jasmith
pool/builds/jasmith/nfs41-instp       773M  74.0G   731M  /builds/jasmith/nfs41-instp
pool/builds/jasmith/nfs41-instp-bld  11.4G  74.0G  11.7G  /builds/jasmith/nfs41-instp-bld
pool/builds/jasmith/nfs41-open        767M  74.0G   712M  /builds/jasmith/nfs41-open
pool/builds/jasmith/nfs41-open-bld   9.62G  74.0G  10.3G  /builds/jasmith/nfs41-open-bld
pool/builds/webaker                  37.4G  74.0G  17.5G  /builds/webaker
pool/builds/webaker/vbox0            7.46G  74.0G  7.46G  /builds/webaker/vbox0
pool/builds/webaker/vbox_ds1         1.48G  74.0G  7.82G  /builds/webaker/vbox_ds1
pool/builds/webaker/vbox_ds2           17K  74.0G    18K  /builds/webaker/vbox_ds2
pool/builds/webaker/vbox_ds3          118M  74.0G  7.77G  /builds/webaker/vbox_ds3
pool/builds/webaker/vbox_master      7.77G  74.0G  7.77G  /builds/webaker/vbox_master
pool/builds/webaker/vbox_mds         3.07G  74.0G  8.99G  /builds/webaker/vbox_mds

And now I can construct other high level filesystems here:

[root@jhereg ~]> zfs create pool/home
[root@jhereg ~]> zfs set mountpoint=/export/home pool/home
[root@jhereg ~]> zfs set sharenfs=rw pool/home
[root@jhereg ~]> zfs create pool/home/tdh
[root@jhereg ~]> share | grep tdh
-@pool/home     /export/home/tdh   rw   ""  

Note that I set up the properties I want on pool/home and count on inheritance to make sure new filesystems under it have the properties I care about.


Originally posted on Kool Aid Served Daily
Copyright (C) 2008, Kool Aid Served Daily
About

tdh

Search

Archives
« April 2015
SunMonTueWedThuFriSat
   
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
  
       
Today