I have a small number of removable hard drives. At any one time, one of them will be mounted to /backup except while changing drives. I swap the drive periodically. That is I have 4 hard drives and I rotate them.

Currently I manually mount / unmount the drive. But there are times when this machine is turned off and worse, sometimes it gets turned off without my knowledge. The daily backup script will fail if a drive isn't mounted.

The drives don't currently share a UUID or Label. I can't garuntee that the disk will always be available on /dev/sdb1. Is there a good way to mount one of a number of drives automatically from /etc/fstab when I just don't know which drive will be inserted?

Note this is a linux (debian) system without a monitor or keyboard. Drives are currently manually mounted / unmounted over ssh after I plug / before I unplug.

  • Is this a UNIX or Linux based system? systemd.automount may be an option if it is Linux based. Commented Feb 14, 2018 at 12:13
  • I'm not sure an fstab entry is the way to go about this, especially if the drives will be swapped while the machine is powered on (unclear from the question)
    – Matt
    Commented Feb 14, 2018 at 12:43
  • @Matt I'm open to alternatives. The important feature I'm looking for is to have the disk mounted at startup. Yes it will me manually unmounted / remounted in certain circumstances. Commented Feb 14, 2018 at 12:49

2 Answers 2


After coming back to this question a long time later I've realised the solution is actually the same as optionally mounting a drive in /etc/fstab. This is discussed here https://wiki.archlinux.org/index.php/fstab#External_devices

In short my solution is to simply have two almost identical entries mounting to the same place. Eg:

UUID=cd49ca72-db24-47ba-b3bc-f0ba8e290599 /backup    ext4    nofail,x-systemd.device-timeout=1  0       0
UUID=d28c6d3a-461e-4d7d-8737-40a56e8f384a /backup    ext4    nofail,x-systemd.device-timeout=1  0       0

As long as only one of them is plugged in when the system boots, the other will "silently" timeout after a 1 second. So whichever is plugged in will get mounted, and the other entry will not trip up the boot process.

Note: Only use this solution if toy are confident that only one of the drives will be mounted at a time.


What about if you generate a new uuid to all those drives if you will not plug them all at once?

Generate a new uuid with the uuid command(on some systems, it is the uuidgen command. Example:

# uuid

Check your current UUID, and if you want, write it down anywhere:

# vol_id /dev/sdb1 | grep UUID

Change the UUID using tune2fs. Do this once per external drive you have:

# tune2fs /dev/sdb1 -U 30dcffac-1187-11e8-8338-0050569774ad
tune2fs 1.41.3 (12-Oct-2008)

Mount it using the new generated UUID at fstab. Example:

UUID=30dcffac-1187-11e8-8338-0050569774ad  /backup  ext4  defaults    0       0

This way, mount -a should be enough to mount the drives on-the-fly, and if the computer is restarted it shall mount it automatically the partition with UUID 30dcffac-1187-11e8-8338-0050569774ad. And as i have not tested this on a physical machine, i don't know what are the consequences of inserting 2 of those disks at the same time and trying to mount them.

If the disks are GPT format, PARTUUID should be used at fstab.

You must log in to answer this question.

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