I have an ARM server that I want to have booted with (not booting FROM) a USB flash drive containing a LUKS keyfile, that's needed to decrypt a hard drive I have connected to the drive. So in order to run /etc/crypttab (to decrypt the drive) I need the USB mounted first in order to mount the drive (fstab runs after crypttab). How could I mount a partition before crypttab starts? On systemd and Linux 4.4.

For clarity:

  1. First, I'd like the USB drive partition (let's say /dev/sdb1) to be mounted at /mnt/usb (not encrypted)
  2. Then, using crypttab to unlock the encrypted partition on one of the drives using a keyfile at /mnt/usb/mykeyfile
  3. Then, mounting filesystem to /mnt/crypt_fs
  • 1
    You might have to provide the specific mount points for clarity.
    – ILMostro_7
    Commented Aug 31, 2019 at 13:17

1 Answer 1


My solution was a bit hacky but it works: I made a systemd service to start before mqueue (just a random service that allowed me to use /dev/sd* and before fstab .mount units) which did basically what the crypttab would have done but in single command form. However, systemd wouldn't wait for the my service to finish and by the time it logged in so I just made a shell script that I would run on demand boot [first] sleep 10 (or something like that) to ensure the decryption has finished then [second] mount the subvolumes on the now mapped device then [third] to start all the services (pi hole, apache, gitea etc.) that needed to use the fstab HDD with systemctl start myservice, so it will be 100% sure HDD is mounted before server instances start. Again, a bit hacky but I'm not so used to with systemd, I use openrc because it's the gentoo default, and honestly I don't really care, it's going to be always on anyway, not much need to restart the system anyway. I may clean it up later on but for now this is okay.


You must log in to answer this question.

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