Linux – Two external hard drive on same mounting point in fstab, but only one should be mounted

debianfstablinux

I have two external hard drives in the fstab file. They are pointing to the same mounting point. During the startup only one of this two drives should be mounted at the mounting point and only one of them is attached to the pc. The second one is not attached the pc during the startup.

Please find attached my fstab file:

##External Harddrive (Removable Drive 1)
UUID=<Some UUID> /media/usb0 ext4 auto,nofail,noatime,rw,user    0   0

##External Harddrive (Removable Drive 2)
UUID=<Some UUID> /media/usb0 ext4 auto,nofail,noatime,rw,user    0   0

If the second drive is attached, the partition is not mounted to debian. If I try to mount it manually there are no errors, but if I try to access the mounting point it is empty. If I mount it manually to another mounting point, I am able to mount it.

Is there a way to mount the second drive if the first one is not connected to the system during startup?

Best Answer

Is there a way to mount the second drive if the first one is not connected to the system during startup?

Use a startup script with some logic to detect if the first drive is connected. If not check for the second drive. Mount whichever one is found. Cut /etc/fstab out of the mix.