Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

share|improve this question
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. –  austin Nov 21 '12 at 12:53

2 Answers 2

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)

share|improve this answer

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)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.