22

Running Ubuntu 13.10 server. Installed and setup zfs from the Ubuntu ppa. All appears to work fine after a reboot if I manually do a 'sudo zfs mount -a', but reading the FAQ on zfsonlinux.org it appears I should expect it to automatically mount. I'm not sure where to look to debug. I don't see any errors in /var/log/syslog related to zfs or mounting.

$ sudo zfs get all zp
NAME  PROPERTY              VALUE                  SOURCE
zp    type                  filesystem             -
zp    creation              Sat Mar 16 17:14 2013  -
zp    used                  464G                   -
zp    available             449G                   -
zp    referenced            13.3M                  -
zp    compressratio         1.00x                  -
zp    mounted               no                     -
zp    quota                 none                   default
zp    reservation           none                   default
zp    recordsize            128K                   default
zp    mountpoint            /zp                    default
zp    sharenfs              off                    default
zp    checksum              on                     default
zp    compression           off                    default
zp    atime                 on                     default
zp    devices               on                     default
zp    exec                  on                     default
zp    setuid                on                     default
zp    readonly              off                    default
zp    zoned                 off                    default
zp    snapdir               hidden                 default
zp    aclinherit            restricted             default
zp    canmount              on                     default
zp    xattr                 on                     default
zp    copies                1                      default
zp    version               5                      -
zp    utf8only              off                    -
zp    normalization         none                   -
zp    casesensitivity       sensitive              -
zp    vscan                 off                    default
zp    nbmand                off                    default
zp    sharesmb              on                     local
zp    refquota              none                   default
zp    refreservation        none                   default
zp    primarycache          all                    default
zp    secondarycache        all                    default
zp    usedbysnapshots       25.3K                  -
zp    usedbydataset         13.3M                  -
zp    usedbychildren        464G                   -
zp    usedbyrefreservation  0                      -
zp    logbias               latency                default
zp    dedup                 off                    default
zp    mlslabel              none                   default
zp    sync                  standard               default
zp    refcompressratio      1.00x                  -
zp    written               13.3M                  -
zp    snapdev               hidden                 default

8 Answers 8

15

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.

1
  • 4
    mountall seems to be the officially supported way of doing this in ubuntu now. There are no ZFS_MOUNT options in the /default/zfs file and adding them was not sufficient to get my pool mounted Nov 5, 2015 at 19:47
7

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.

4
  • 1
    I had the same problem (auto import not working at boot time) with a fresh Ubuntu 14.04 LTS installation and your solution solved it.
    – masgo
    Nov 18, 2015 at 0:16
  • Good to hear! :) Apr 23, 2016 at 0:48
  • 2
    /etc/init/zpool-import.conf doesn't appear to exist on Ubuntu 16.04, even after switching back from systemd to upstart.
    – GDorn
    May 25, 2016 at 0:23
  • @GDorn, have you tried this solution? - askubuntu.com/questions/768179/zfs-pools-not-mounted-16-04 May 25, 2016 at 4:58
2

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...

1
  • 1
    It looks like you're using Samba to mount a local disk, which is ... weird ... Aug 17, 2021 at 1:50
2

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

1

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.

1

04 My zfs was not mounting I did a: sudo zfs import It listed all my unmounted pools but it also gave me a option to mount by zfs name or number I did the import by it's number sudo zfs import ############## and now it auto mounts after every reboot

It looks like that number is the uuid of the array and all the drives in the array have the same number

Hope that helps

0

Ubuntu 20.04 here. I had problems about mount ordering. I got it working by following the instructions here:

https://openzfs.github.io/openzfs-docs/Getting%20Started/Ubuntu/Ubuntu%2020.04%20Root%20on%20ZFS.html

  1. Filesystem mount ordering
mkdir /etc/zfs/zfs-list.cache
touch /etc/zfs/zfs-list.cache/mypool
ln -s /usr/lib/zfs-linux/zed.d/history_event-zfs-list-cacher.sh /etc/zfs/zed.d

zfs set canmount=on mypool

After reboot the mount order is correct and I can bind mount directories from the ZFS volume.

0

In my case, the problem was that zfs would not import the cached pool on boot with the uuid. In my case, I originally created the pool as follows using the uuid:

zpool create -m /Backups Backups -f /dev/disk/by-uuid/c529a4ef-3c6a-4eb6-8d60-bc46785266cb

Noticing it would not import at boot and after searching forums and tinkering with configs to no avail, I attempting to export it and import it back in with id instead of uuid as follows:

zpool export Backups
zpool import -d /dev/disk/by-id Backups

After rebooting, it imported the cached pool without issue. I'm not sure why it malfunctions with uuid as opposed to id, merely reporting the fix if others come by here looking for a solution.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .