3

I'm asking about a Debian Wheezy system running sysvinit and ZFS on Linux. While my problem manifests itself with ZFS, I strongly suspect that the underlying problem is not ZFS-specific.

For some reason, if I boot the system normally, zfs-import runs before cryptdisks-early during the system startup sequence. This is a problem, because I have ZFS pools on LUKS devices which then fail to import because the LUKS devices aren't yet available decrypted, and as a consequence lots of other things fail because they expect things to be available in the file system which aren't.

However, it seems like if I boot into single-user mode (by appending single to the kernel command line), cryptdisks-early runs before zfs-import just the way I want it to.

I cannot recall any time recently when the above has not been the case, but I can't guarantee that the services haven't automatically been started in the correct order when booting normally. I believe that this all started with a for me pretty large ZoL upgrade, with basically brand new init scripts that prompted some adjustments e.g. in /etc/insserv.conf.d as compared to the previous configuration, but I also suspect that the init scripts themselves are fine, just that something about the startup order gets messed up somehow.

Looking through /etc/rc?.d, I find in /etc/rcS.d among many others:

  • S10cryptdisks-early
  • S11zfs-import
  • S12cryptdisks

Naiively, it thus seems like everything should start in the correct order, but obviously, that doesn't always happen.

/etc/insserv.conf.d/zfs-mount contains $local_fs +zfs, which is expected (mounting ZFS file systems is part of providing local_fs). Note that in ZFS, import and mount are two distinct operations, where the import happens before the mount. (It is possible to import a ZFS pool without mounting any of its file systems, but not to mount any ZFS file system without having imported the pool the file system is stored on. Normally, and on my system, ZFS file systems are mounted automatically when the pool is imported.)

As a workaround to make sure the system actually boots cleanly, I have edited /etc/init.d/zfs-import to make it manually start cryptdisks-early before proceeding in its do_start. I would however much rather accomplish the same goal by fixing some configuration settings (which I suspect is possible).

I can't seem to find anything specific about the relative order of zfs-import and cryptdisks-early but I could be overlooking something obvious there.

I want to ensure that the system consistently starts (and waits for it to start; it can take a while) cryptdisks-early before trying to start zfs-import. What changes do I need to make to the system configuration files?

/etc/init.d/.depend.start doesn't list anything relevant, but /etc/init.d/.depend.boot does mention ZFS and cryptdisks together as seen in this extract from it:

cryptdisks: checkroot.sh cryptdisks-early udev mdadm-raid
cryptdisks-early: checkroot.sh udev mdadm-raid
zfs-mount: mountall.sh mountall-bootclean.sh cryptdisks cryptdisks-early zfs-import
zfs-import: mtab.sh

So if I'm reading that right, zfs-mount depends on zfs-import and cryptdisks, but zfs-import itself doesn't depend on cryptdisks, so init is free to start zfs-import before cryptdisks or even cryptdisks-early. Which is exactly the behavior I'm getting in practice, but not what the file names under /etc/rcS.d would seem to indicate.

I'll be happy to provide additional information if needed; just tell me what might be relevant.

  • Under /etc/init.d have a look at .depend.boot and .depend.start – Rui F Ribeiro Feb 26 '17 at 14:07
  • @RuiFRibeiro I find zfs-import: mtab.sh and zfs-mount: mountall.sh mountall-bootclean.sh cryptdisks cryptdisks-early zfs-import in .depend.boot (nothing cryptdisks-related in .depend.start, and the only ZFS-related entries there are unrelated to my problems; specifically zfs-zed and zfs-share). – a CVn Feb 26 '17 at 14:54
  • Try adding cryptdisks to the Required-Start: header field of /etc/init.d/zfs-import, then run insserv zfs-import and re-check .depend.boot. Btw. what does +zfs mean in /etc/insserv.conf.d/zfs-mount? Is there a zfs init script around? – Ferenc Wágner Feb 27 '17 at 10:00

Your Answer

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

Browse other questions tagged or ask your own question.