When you use zfs mount -a or zfs umount -a this really mounts or unmounts everything. And quite often this is not what you want. Thus in SRU75 a recursive mount was introduced, giving you more control what you are mounting.

Let`s assume the following ZFS pool with the following datasets

root@testbed:~# zpool create tank c2t0d0
root@testbed:~# zfs create tank/test1
root@testbed:~# zfs create tank/test2
root@testbed:~# zfs create tank/test3
root@testbed:~# zfs create tank/test4

Now let’s rearange the mountpoints a little bit from their defaults.

root@testbed:~# zfs set mountpoint=/mnt/tank/test4 tank/test4
root@testbed:~# zfs set mountpoint=/mnt/tank tank/test1

This leads to a structure like this.

root@testbed:~# mount | grep tank |cut -d " " -f 1-3
/tank on tank
/tank/test2 on tank/test2
/tank/test3 on tank/test3
/mnt/tank on tank/test1
/mnt/tank/test4 on tank/test4

With a zfs umount -a you really unmount a lot of filesystems:

root@testbed:~# mount | cut -d " " -f 1,3 | wc -l
51
root@testbed:~# zfs umount -a 
cannot unmount '/system/zones/testzone': Device busy
cannot unmount '/system/zones': Device busy
cannot unmount '/export/home/jmoekamp': Device busy
cannot unmount '/export/home': Device busy
cannot unmount '/export': Device busy
root@testbed:~# mount | cut -d " " -f 1,3 | wc -l
38
root@testbed:~# zfs mount -a 

Sometimes you need something less blunt while still being able to mount/unmount a lot of filesystems. For example you can unmount all datasets of the pool tank in one go.

root@testbed:~# zfs umount -r tank 
root@testbed:~# mount | cut -d " " -f 1,3 | wc -l
46
root@testbed:~# mount | grep "tank" | cut -d " " -f 1,3 
root@testbed:~#

Or just unmount the datasets with a mountpoint under /mnt/tank:

root@testbed:~# zfs mount -a 
root@testbed:~# zfs umount -r /mnt/tank
root@testbed:~# mount | grep "tank" | cut -d " " -f 1,3
/tank tank
/tank/test2 tank/test2
/tank/test3 tank/test3
root@testbed:~#

Or just umount the complete dataset tank and just remount everything under /mnt/tank

root@testbed:~# zfs unmount -r tank
root@testbed:~# zfs mount -r /mnt/tank
root@testbed:~# mount | grep "tank" | cut -d " " -f 1,3
/mnt/tank tank/test1
/mnt/tank/test4 tank/test4

BTW: The zfs man page1 now contains a history section noting when an subcommand, option or property was introduced to Solaris

+-----------------+------------------+---------------+
|   SUBCOMMAND    |      OPTIONS     |    RELEASE    |
+-----------------+------------------+---------------+
| mount, umount   | -r               | 11.4.75       |
+-----------------+------------------+---------------+
| retained        | -d, -h           | 11.4.63       |

  1. I have modified the output a little bit, removing a number characters in the second column in order to ensure it fits in one row on more devices in my blog. 

Comments

You can use your Fediverse (i.e. Mastodon, among many others) account to reply to this post.

Written by

Joerg Moellenkamp

Grey-haired, sometimes grey-bearded Windows dismissing Unix guy.