removable media

created onJanuary 19, 2022

alternating mounting of several devices to the same mount point

This article describes how several removable media (i.e. portable hard disk, USB sticks) can be mounted at the same mount point, At a certain point of time, of course, only one media of the set of media, that you want to mount under that mount point. An application of this is swapping backup media, i.e. portable hard disks of the same model.

strategy

In , multiple entries with different labels or UUIDs pointing to the same mount point do not work. A possible solution is to define the same label to all the devices that are to be mounted at the specific mount point. Predefined, different UUIDs can be assigned to the devices in order to be able to identify the media currently mounted.

When mounting partitions, labels should be preferred over UUIDs anyway, as stated in the the mount man page, section :

" The recommended setup is to use tags (e.g. LABEL=label) rather than /dev/disk/by-{label,uuid,partuuid,partlabel} udev symlinks in the /etc/fstab file. Tags are more readable, robust and portable. The mount(8) command internally uses udev symlinks, so the use of symlinks in /etc/fstab has no advantage over tags. For more details see libblkid(3). "
mount man page, section *Indicating the device*

setting label an UUID to partitions

Define label for partition :

e2label /dev/sdc1 backup

Setting a predefined UUID of the partition :

tune2fs -U 00000000-0000-0000-0000-0000000000b0 /dev/sdc1

configure mount in /etc/fstab

In , configure the mounting of the partitions with the specified label under the mount point:

# USB backup HDs LABEL=backup /idoru/backup ext3 user,nosuid,nodev,nofail 0 0 # the UUIDs of the backup disks are set to the following UUIDs in order to be able # to distinguish them # 00000000-0000-0000-0000-0000000000b0 # 00000000-0000-0000-0000-0000000000b1

reference

mount man page