8

I'm aware this more of a beginners question, but manpages, google and FreeBSD Handbook provided no solution.

I'm using ZFS Version 28 on a 8.2 Stable FreeBSD and my problem is the following: When I mount a ZFS filesystem (zfs mount ) the filesystem is mounted as expected, however child filesystems are not mounted.

Is there a builtin way to recursively mount a zfs filesystem AND it's children?

Thanks in advance for your help.

flexy

MadHatter
  • 79,770
  • 20
  • 184
  • 232
flexy
  • 81
  • 1
  • 2
  • 1
    Is there any reason you don't just mount all ZFS filesystems on boot by putting zfs_enable="YES" in /etc/rc.conf? I very rarely come across people who mount/unmount ZFS filesystems manually. – USD Matt Nov 21 '12 at 12:17
  • Hi Matt, this is beeing done. However I still need to manually mount/dismount filesystems for testing purposes, layout changes etc. Since this is a production maschine, reboots durring the workday are not an option. – flexy Nov 21 '12 at 12:24
  • Well it doesn't look like it. The closest you'll get is 'zfs mount -a' which will mount everything not already mounted that doesn't have canmount set to off/noauto. I can't tell if 'zfs mount -a pool/dataset' will work from the man page but I don't think so. – USD Matt Nov 21 '12 at 12:34
  • nope, zfs mount -a throughs "too many arguments", when invoked with an fs. Ok, so I'll go an write a sh-function now that does the job. This Post was more of a security meassure to make sure I'm not missing the obvious before starting this. Thanks. – flexy Nov 21 '12 at 12:39
  • _However I still need to manually mount/dismount filesystems for testing purposes, layout changes etc._ This does not sound like a true production environment. I would recommend you build a dev box for your testing. Again... more of an FYI then a follow up question. – au_stan Nov 21 '12 at 12:53
  • I'm a small time 1 person(parttime) IT-Department and when new features are being added, new user groups come in, I just have this one maschine, to serve them all. Even though I do the rough testing on a virtual maschine allready... Thanks for breaking your head over my situation though ^^ – flexy Nov 21 '12 at 13:11

2 Answers2

10

This works for me (tested on FreeBSD 9.2):

zfs list -rH -o name pool/path/dir | xargs -L 1 zfs mount

How does it work:

zfs list -rH -o name pool/path/dir – display name of each dataset in pool/path/dir (-H to omit header)
xargs -L 1 zfs mount – run mount for each line (separately)

Marián Černý
  • 222
  • 2
  • 7
0

you can enable the the Legacy mode of the ZFS mount points, so you can manage the mount points using the traditional /etc/fstab file to mount filesystems at boot time.

For example:

zfs set mountpoint=legacy (zfspool/mount-point)

Farhan
  • 4,269
  • 11
  • 49
  • 80