In this quick article I'll demonstrate how we can easily rename a loopback file system mounted from a global zone to a local zone and also change the zone's configuration to make the changes persistent.
The concerned mount point is /data_new on a zone named test-zone.
root@test-zone:/# df -h /data_new
Filesystem size used avail capacity Mounted on
/data_new 500M 21K 500M 1% /data_new
root@test-zone:/#
The concerned mount point is /data_new on a zone named test-zone.
root@test-zone:/# df -h /data_new
Filesystem size used avail capacity Mounted on
/data_new 500M 21K 500M 1% /data_new
root@test-zone:/#
From the global zone we can view the loopback mount point:
root@sandbox:/# mount -v | grep data
/zonefs on /zones/test-zone/root/data_new type lofs read/write/setuid/devices/dev=2d50007 on Mon Oct 2 19:59:16 2017
Let's unmount the file system from the globasl zone and remount it as /data.
Note: If you are about to do this in a production environment then make sure that no process is currently accessing the concerned file system.
root@sandbox:/# umount /zones/test-zone/root/data_new
root@sandbox:/# mkdir /zones/test-zone/root/data
root@sandbox:/# mount -F lofs /zonefs /zones/test-zone/root/data
Now if we take a look at the mount -v output we can notice that the /zonefs file system is now mounted as /data on the zone.
root@sandbox:/# mount -v | grep data
/zonefs on /zones/test-zone/root/data type lofs read/write/setuid/devices/dev=2d50007 on Mon Oct 2 21:17:58 2017
root@sandbox:/#
Let's take a look inside the zone as well.
root@test-zone:/# df -h /data
Filesystem size used avail capacity Mounted on
/data 500M 21K 500M 1% /data
root@test-zone:/#
This is fine but the zone configuration still has the old mount point entry.
root@sandbox:/# zonecfg -z test-zone info fs
fs:
dir: /data_new
special: /zonefs
raw not specified
type: lofs
options: []
So whenever the zone reboots it will mount /zonefs as /data_new. So let's correct it:
root@sandbox:/# zonecfg -z test-zone
zonecfg:test-zone> select fs dir=/data_new
zonecfg:test-zone:fs> set dir=/data
zonecfg:test-zone:fs> set special=/zonefs
zonecfg:test-zone:fs> set type=lofs
zonecfg:test-zone:fs> end
zonecfg:test-zone> verify
zonecfg:test-zone> commit
zonecfg:test-zone> exit
root@sandbox:/#
Now if we view the fs info via zonecfg we observe that the modifications have been updated.
root@sandbox:/# zonecfg -z test-zone info fs
fs:
dir: /data
special: /zonefs
raw not specified
type: lofs
options: []
root@sandbox:/#
The /zonefs file system itself is of type zfs.
root@sandbox:/# mount -v | grep zonefs | grep zfs
rpool/zonefs on /zonefs type zfs read/write/setuid/devices/nonbmand/exec/xattr/atime/dev=2d50007 on Mon Oct 2 19:35:10 2017
root@sandbox:/# df -h /zonefs
Filesystem size used avail capacity Mounted on
rpool/zonefs 500M 21K 500M 1% /zonefs
root@sandbox:/#
No comments:
Post a Comment