I have encrypted luks partition. Key file is located on USB flash drive. I also created copy of that flash drive to another flash. How I can add two mount points in /etc/fstab that points to same target directory. Booth flash drives to server not connected at same time. I just want to setup system that I can replace USB flash if it fails and system boots up correctly.

/etc/crypttab contains

cryptolvm       /dev/disk/by-uuid/a172345c-c0bd-1234-abcd-3febeeef9730  /media/sdb1/keyfile     luks

/etc/fstab (USB part of)

#kingston 16GB 
UUID=622548b9-2223-4444-1234-5f61228bfa1c /media/sdb1   ext3    ro,nosuid,nodev,nofail,x-gvfs-show 0 0

# Adata 16GB 
UUID=7342c8a5-4321-1111-1234-34742b566af1 /media/sdb1   ext3    ro,nosuid,nodev,nofail,x-gvfs-show 0 0

At this moment when server boots it show errors:

1) systemd-fstab-generator: failed to create mount unit file /run/systemd/generator/media-sdb1.mount, as it already exists. Duplicate entry in /etc/fstab?
2) dependency failed for /media/sdb1
  • Maybe labeling the filesystem on USB and mounting with the label could do the trick. tune2fs -L usbkey /dev/sdb1 and add LABEL=usbkey /media/sdb1... to your /etc/fstab and remove the other UUID entries. – Thomas Feb 10 '18 at 11:01
  • I try it and report results – Guntis Feb 10 '18 at 11:11
  • @Thomas, That worked, can You convert comment to answer? So, I can accept it – Guntis Feb 10 '18 at 11:48

Using UUID as mount source is not applicable when trying to mount different devices on the same folder. This normally also should not happen as it could lead to unwanted system behaviour and therefore systemd fails.

In your case that would be OK, since you are only inserting one USB drive at a given time. To work around this, you can use e.g. the LABEL=usbkey option in /etc/fstab to mount any filesystem that has the label usbkey in a particular folder.

In your case remove the UUID entries and replace them with one entry as follows.

LABEL=usbkey /media/sdb1   ext3    ro,nosuid,nodev,nofail,x-gvfs-show 0 0

Second, you need to be sure that your filesystems have the correct label set. On each USB stick you would have to run the command as follows, provided that /dev/sdb is your USB drive and /dev/sdb1 is the partition with the filesystem you want to mount.

tune2fs -L usbkey /dev/sdb1

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.