zpools don't automatically mount after boot

You need to edit the file /etc/default/zfs with your favourite editor, eg: nano, vim or something else, and change the lines

ZFS_MOUNT='no'
ZFS_UNMOUNT='no'

to

ZFS_MOUNT='yes'
ZFS_UNMOUNT='yes'

The other option is to install mountall (apt-get install mountall) from the ZFS Stable PPA, it takes care of that for you. The first option is preferable and faster.


For me on Ubuntu 14.04 LTS, I had to set the following

To automatically import the zpools, change the value from 1 to 0:

File: /etc/init/zpool-import.conf

modprobe zfs zfs_autoimport_disable=0

To automatically mount the zfs mounts, add the following line:

File: /etc/rc.local

zfs mount -a

Restarted, and the zpool ZFS mounts were mounted automatically.


Using Ubuntu 16.04 zfs, there is something I found that fixes mounting zfs shares at boot without creating rc.local or systemd scripts, and without manually running zfs set sharesmb=on after each boot.

To sum up: zfs mount -a and zfs share -a do not work, but using zfs set sharesmb=on does work. Running sudo /etc/init.d/zfs-share restart works too. Also, the mountall program in 16.04 does not support zfs, for whatever reason.

I think the problem is that when you set sharesmb=on, it creates a share name based on poolname/sharename like so: poolname_sharename

But it seems that this share name can be too long. I've read that you should limit netbios names to 14 characters or less, and also limit the number of characters in the Comments field too.

So, I created a new filesystem with a combined length of less than 14 characters, including the underscore:

sudo zfs create -o casesensitivity=mixed -o nbmand=on pool/share

Then edit /etc/default/zfs, and disable smb mounting/sharing: (I think one is for NFS, but I disable it all)

ZFS_MOUNT='no'
ZFS_UNMOUNT='no'
ZFS_SHARE='no'
ZFS_UNSHARE='no'

Finally, enable sharesmb for the new filesystem:

sudo zfs set sharesmb=on pool/share

I also made sure the /ect/hostid file exists. (google how to create one)

Now when I reboot, I run this command without having to do anything else, and my share appears:

smbclient -U guest -N -L localhost  (or use smbclient -L localhost)

Sharename       Type      Comment
---------       ----      -------
print$          Disk      Printer Drivers
IPC$            IPC       IPC Service (my server (Samba, Ubuntu))
pool_share      Disk      Comment: /pool/share

And yes, I know that samba supports names longer than 14 characters, but it seems to screw up mounting zfs shares at boot.

I'd love to know if this works for anyone else, or if its just some quirk on my system...


I had the same problem on a clean install on 16.04 LTS.

After a restart, no pools were present (zpool status showed no pools), but a zpool import <poolName> would restore my pool.

Turned out to be fixed by the answers to ZFS Pools not mounted 16.04. Reproducing the working answer here:

sudo apt remove zfs.doc
sudo apt install zfsutils-linux

This


I've found that even with mountall it just doesn't work right sometimes. I literally built two identical servers, placed identical model HDs in each one and installed Ubuntu and the ZFS PPA at the same time from the same sources. One would automount, the other wouldn't. Even following the extra FAQ instructions about adding a sleep in the mountall.conf file, etc., it never would mount at boot. I ended up putting a mountall command in /etc/rc.local.