10

I tried to install zfs on debian 9.1, however I'm experiencing some errors.

My first installation was only of zfs-dkms however I read on the net that also the spl-dkms is required for zfs-dkms to run.


My steps were to change my sources.list adding the contrib non-free as follows:

/etc/apt/sources.list

deb http://ftp.nl.debian.org/debian/ stretch main contrib non-free
deb-src http://ftp.nl.debian.org/debian/ stretch main contrib non-free

deb http://security.debian.org/debian-security stretch/updates main contrib non-free
deb-src http://security.debian.org/debian-security stretch/updates main contrib non-free

# stretch-updates, previously known as 'volatile'
deb http://ftp.nl.debian.org/debian/ stretch-updates main contrib non-free
deb-src http://ftp.nl.debian.org/debian/ stretch-updates main contrib non-free

Done a classic apt-get update and then tried installing zfs with the following:

apt-get install spl-dkms

and only after

apt-get install zfs-dkms

As a result, I have these errors:

root@debian:/etc/apt# apt-get install zfs-dkms
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
  libnvpair1linux libuutil1linux libzfs2linux libzpool2linux zfs-zed zfsutils-linux

...

DKMS: install completed.
Setting up libzpool2linux (0.6.5.9-5) ...
Setting up libzfs2linux (0.6.5.9-5) ...
Setting up zfsutils-linux (0.6.5.9-5) ...
Created symlink /etc/systemd/system/zfs-mount.service.wants/zfs-import-cache.service â /lib/systemd/system/zfs-import-cac
Created symlink /etc/systemd/system/zfs.target.wants/zfs-import-cache.service â /lib/systemd/system/zfs-import-cache.serv
Created symlink /etc/systemd/system/zfs-share.service.wants/zfs-mount.service â /lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-mount.service â /lib/systemd/system/zfs-mount.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-share.service â /lib/systemd/system/zfs-share.service.
Created symlink /etc/systemd/system/multi-user.target.wants/zfs.target â /lib/systemd/system/zfs.target.
zfs-import-scan.service is a disabled or a static unit, not starting it.
Job for zfs-mount.service failed because the control process exited with error code.
See "systemctl status zfs-mount.service" and "journalctl -xe" for details.
zfs-mount.service couldn't start.
Job for zfs-share.service failed because the control process exited with error code.
See "systemctl status zfs-share.service" and "journalctl -xe" for details.
zfs-share.service couldn't start.
Setting up zfs-zed (0.6.5.9-5) ...
Created symlink /etc/systemd/system/zed.service â /lib/systemd/system/zfs-zed.service.
Created symlink /etc/systemd/system/zfs.target.wants/zfs-zed.service â /lib/systemd/system/zfs-zed.service.
Processing triggers for libc-bin (2.24-11+deb9u1) ...

Reading journalctl -xe as suggested I get:

root@debian:/etc/apt# journalctl -xe
Aug 02 23:13:13 debian systemd[1]: zfs-share.service: Main process exited, code=exited, status=1/FAILURE
Aug 02 23:13:13 debian systemd[1]: Failed to start ZFS file system shares.
-- Subject: Unit zfs-share.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit zfs-share.service has failed.
--
-- The result is failed.
Aug 02 23:13:13 debian systemd[1]: zfs-share.service: Unit entered failed state.
Aug 02 23:13:13 debian systemd[1]: zfs-share.service: Failed with result 'exit-code'.
Aug 02 23:13:13 debian systemd[1]: Starting Mount ZFS filesystems...
-- Subject: Unit zfs-mount.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit zfs-mount.service has begun starting up.
Aug 02 23:13:13 debian zfs[81481]: The ZFS modules are not loaded.
Aug 02 23:13:13 debian zfs[81481]: Try running '/sbin/modprobe zfs' as root to load them.
Aug 02 23:13:13 debian systemd[1]: zfs-mount.service: Main process exited, code=exited, status=1/FAILURE
Aug 02 23:13:13 debian systemd[1]: Failed to start Mount ZFS filesystems.
-- Subject: Unit zfs-mount.service has failed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit zfs-mount.service has failed.
--
-- The result is failed.
Aug 02 23:13:13 debian systemd[1]: zfs-mount.service: Unit entered failed state.
Aug 02 23:13:13 debian systemd[1]: zfs-mount.service: Failed with result 'exit-code'.
Aug 02 23:13:13 debian systemd[1]: Starting ZFS file system shares...
-- Subject: Unit zfs-share.service has begun start-up
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- Unit zfs-share.service has begun starting up.
Aug 02 23:13:13 debian systemd[81483]: zfs-share.service: Failed at step EXEC spawning /usr/bin/rm: No such file or direc
-- Subject: Process /usr/bin/rm could not be executed
-- Defined-By: systemd
-- Support: https://www.debian.org/support
--
-- The process /usr/bin/rm could not be executed and failed.
--
-- The error number returned by this process is 2.

What's wrong here? I missed something else? How is the zfs-linux package related to zfs installation?

What is the correct way to install zfs in debian 9 ?

  • What is the output of dkms status | grep zfs ? – GAD3R Aug 3 '17 at 10:07
7

The actual answer by @cas is good but have some corrections to be applied.

So let's take a fresh installation of Debian 9 and assuming that the contrib non-free repositories are also not enabled.


Step 0 - Enable the contrib non-free repositories

I used sed to find and replace the word main inside /etc/apt/sources.list

sed -i 's/main/main contrib non-free/g' /etc/apt/sources.list

apt-get update

Step 1 - ZFS Installation

Since the last fixes spl-dkms is correctly seen as zfs-dkms dependency so it's recalled automatically and it's not necessary to install it manually before zfs-dkms. The symbolic link is needed due to a bug inside the zfs distribution in Debian, that doesn't look for rm binary in the right position.

apt -y install linux-headers-$(uname -r)

ln -s /bin/rm /usr/bin/rm

apt-get -y install zfs-dkms

Step 2 - ZFS Restart

At this point zfs-dkms is installed but it throws errors in journalctl -xe; to start zfs properly use:

/sbin/modprobe zfs

systemctl restart zfs-import-cache
systemctl restart zfs-import-scan
systemctl restart zfs-mount
systemctl restart zfs-share

Step 3 - YOU MUST CREATE AT LEAST ONE ZPOOL

At this point I discovered that YOU must create a zpool before reboot otherwise zfs will not load the proper modules if there are no zpools. It's a sort of saving resources mechanism ( but even in that case this will still throw errors inside journalctl -xe )

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=864348

" We are not doing this because ZFS modules would taint the kernel, if there's no zpool available then it shouldn't be loaded. "

If you miss this part you have to start from Step 2

For example, by using the example provided by @cas, you can create this file based zpool or directly create your disk based ones.

truncate -s 100M /root/z1
truncate -s 100M /root/z2
zpool create tank /root/z1 /root/z2
zpool scrub tank
zpool status

then after a reboot everything will work with no errors in journalctl -xe

3

Slight variations for me on Debian 9.4 - after the Apt sources additions:

apt-get install linux-headers-amd64       # not tied to specific kernel version
apt-get install zfs-dkms zfsutils-linux   # my apt recommends is off

lsblk                                     # double-check which disks to pool

zpool create -f jeff -o ashift=12 -o autoexpand=on -o autoreplace=on mirror sdb sdd
zfs set mountpoint=/var/jeff jeff
zfs set compression=lz4 jeff
zfs create jeff/blog
zfs create jeff/docs
zfs create jeff/pics
zfs set compression=off jeff/pics

df -h

The mount was NOT present sigh - discovered that there was an existing /var/jeff with content - moved that out of the way and did a reboot...

After reboot:

df -htzfs
Filesystem        Size  Used Avail Use% Mounted on
jeff              849G  128K  849G   1% /var/jeff
jeff/blog         850G  128K  849G   1% /var/jeff/blog
jeff/docs         856G  128K  849G   1% /var/jeff/docs
jeff/pics         850G  128K  849G   1% /var/jeff/pics

Hooray - all present and bit-rot protected :)

  • +1 but strongly recommend using /dev/disk/by-id/? rather than /dev/sd? devices. Either use the by-id names when creating the pool, or fix later with zpool export <pool> followed by zpool import -d /dev/disk/by-id/ <pool>. These names, unlike /dev/sd*, WILL persist across reboots. Also, if you have a label printer, you can print labels with short versions of the by-id device names (there's usually a serial number portion of the name which makes a good, short, unique label) and label the drives to make them easy to identify if they ever need to be replaced. – cas Apr 16 '18 at 10:52
  • Ummm - but ZFS doesnt care about the disk aliases used during create - all the info is written to zfs-part9 on the disk - and that is what is used to construct the array. I don't really care whether what was /dev/sdb changes to something else in the future, and I always check with lsblk -f just before dickering with drive hardware - for our production servers the Dell hdd blink tool is useful in relating the current os-alias to the physical unit :) - I think the /dev/disk/by-id is more useful for other mounting systems that don't have ZFS's built in consistency - e.g. fstab. – Jeff Apr 19 '18 at 10:15
  • using by-id will give you meaningful/useful names (identifying each drive's brand, model, and serial number) in zpool command like status and list, which can be easily copy-pasted into any necessary zpool offline/detach/replace/etc commands. sda doesn't tell you anything useful. ata-ST4000VN008-2DR166_ZDH35XXX identifies exactly what kind of drive it is and its serial number. You can still get the (current) short dev names if you ever want them using the -L option with zpool list, zpool status, etc (in my experience, mostly useful with zpool list -L -v). – cas Apr 19 '18 at 11:12
  • IME, the meaningful names help to reduce human error. It's easy to mistype, e.g., sdd as sdf. much harder to mistype a by-id name. – cas Apr 19 '18 at 11:14
  • Lol - lots of folks make the same recommendation - I personally find it easier to remember and type sdc sde sdf and sdg. We buy disks in batches and they all start with the same 48 or so by-id chars and just have 2-4 digit suffixes that differ. People don't type by-id names - they use tab-completion - more likely to lead to an oops IMHO. I find differentiating one letter in a three-char much easier than 2-4 digits in a 52 char name. I know that lots of folks also recommend UUID. As ZFS doesn't care, I think I will stick to what I find easier - less is sometimes more :) – Jeff Apr 20 '18 at 19:05
3

I just created a brand new stretch VM to test this. Minimal install (just ssh and standard system tools), edit sources.list to add contrib and non-free, then:

apt-get install spl-dkms zfs-dkms

You may also want to manually install zfsutils-linux. It should be installed automatically when you install zfs-dkms but the dependencies may vary for different Debian releases and for different versions of the Debian ZoL packages:

apt-get install  zfsutils-linux

It looks as if there's a bug in the systemd unit file for zfs-share. It's trying to run /usr/bin/rm instead of /bin/rm.

The quick fix is to run ln -s /bin/rm /usr/bin, or alternatively:

cd /etc/systemd/system
cp -a /lib/systemd/system/zfs-share.service .
edit zfs-share.service and change `/usr/bin/rm` to `/bin/rm`

and then restart the zfs services:

systemctl restart zfs-import-cache
systemctl restart zfs-import-scan
systemctl restart zfs-mount
systemctl restart zfs-share

NOTE: I manually ran modprobe zfs before restarting any of the zfs services. I'm not sure if they'll do that automatically or not, so you may need to do that too.

BTW, you probably want to apt-get install zfs-initramfs too, to ensure that zfs is loaded during the initramfs.


I tested that this works with:

# truncate -s 100M /root/z1
# truncate -s 100M /root/z2
# zpool create tank mirror /root/z1 /root/z2 

# zfs set compression=lz4 tank
# rsync -ax /etc /tank/
# du -sch /etc /tank/etc/
3.5M    /etc
825K    /tank/etc/
4.3M    total

# zpool scrub tank
# zpool status
  pool: tank
 state: ONLINE
  scan: scrub repaired 0 in 0h0m with 0 errors on Thu Aug  3 19:28:21 2017
config:

    NAME          STATE     READ WRITE CKSUM
    tank          ONLINE       0     0     0
      mirror-0    ONLINE       0     0     0
        /root/z1  ONLINE       0     0     0
        /root/z2  ONLINE       0     0     0

errors: No known data errors

The zpool is working and /tank is automounted after a reboot.

Conclusion: it works now.


BTW, this stretch VM uses a ZFS zvol created on my main sid system as its disk. I made a snapshot if it immediately after the initial installation, before installing spl-dkms and zfs-dkms so I could quickly revert and start again if anything major went wrong.

I first made the zvol with only 1GB and needed to increase it later to have enough space for build-essential, linux-headers-amd64 etc:

# zfs list -r -t all export/volumes/stretch
NAME                                         USED  AVAIL  REFER  MOUNTPOINT
export/volumes/stretch                      6.25G   834G  1.77G  -
export/volumes/stretch@2017-08-03-18:31:04   279M      -  1.09G  -

setting compression=lz4 on tank in the VM is probably worse than useless - the zvol already has lz4 compression on it.

  • I tried to install it on a fresh new vm but I'm experiencing still problems i guess.. some services aren't starting correctly.. As far I can see the ZFS DKMS bug list is filled of "can't install" bugs reports. I wonder if is normal that developers let months pass after such many bugfix requests reproducible just with apt-get install zfs-dkms .. – user3450548 Aug 11 '17 at 0:53
  • On the part where you ask for the cd directory you meant: /etc/systemd/system/ ? because /etc/systemd/service is non existant.. also i have this message: "Failed to restart zfs-import-mount.service: Unit zfs-import-mount.service not found." and "Failed to restart zfs-import-share.service: Unit zfs-import-share.service not found." – user3450548 Aug 11 '17 at 22:09
  • It seems i have also problems with ZFS-ZED service by reading journalctl -xe: Aug 11 23:03:23 debian zed[70734]: ZFS Event Daemon 0.6.5.9-5 (PID 70734) Aug 11 23:03:23 debian zed[70734]: Failed to initialize libzfs Aug 11 23:03:23 debian systemd[1]: zfs-zed.service: Main process exited, code=exited, status=1/FAILURE Aug 11 23:03:23 debian systemd[1]: zfs-zed.service: Unit entered failed state. Aug 11 23:03:23 debian systemd[1]: zfs-zed.service: Failed with result 'exit-code'. – user3450548 Aug 11 '17 at 22:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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