1

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?

Kaffi
  • 27
  • 1
  • 5
  • I would fist investigate the fact that if you mount it manually, in the end, it's not working either on that directory. Can you provide the log of "mount" at system boot? Can you provide the command that you launch manually? – Federico Galli Jul 25 '17 at 10:51

3 Answers3

0

mount -a mounts all filesystems in /etc/fstab.

If the drive is not yet in fstab, then it will do nothing with regard to that drive.

First, check how the disk is partitioned (e.g. with fdisk -l (that is an lowercase L, not a number 1) or with another tool such as gpart.)

If your hard drive is an LVM, these instructions won't work, stop and follow these directions: https://superuser.com/a/666034/121698

Test things with a manual mount command. Example: mount -t ext2 /dev/sdb1 /mnt.

The contents of the first partition should now be visible under /mnt.

Note that this assumed ext2 as file system. Adjust as needed.

Note that this assumed a /dev/sdb1, it could have been /dev/sdb2, sdb3, ... There can even be multiple partitions on that disk. Adjust as needed.

If this works: umount /mnt and add a line to /etc/fstab. Easiest is to copy one of the existing lines and adjust it. Understanding just what those values mean is recommended, so look at the top for a line like this:

Device Mountpoint FStype Options Dump Pass#
  • Device is the device you are trying to mount/ E.g. /dev/sdb1 mountpoint is the directory where you want the folders to show up.
  • FStype is the filesystem type. E.g. ext2, ext3, ext4, fat, iso9660, ...
  • Options are FS options, such as rw for read write, or ro for read only.
  • Dump and pass are for recovery. Which disk needs to be fsck'ed? In which sequence etc.

Thus... choose where you want to mount the disk. For example in /home/old_backup. It that directory does not exist then make it. (e.g. mkdir /home/old_backup). If there are already content in that directory then realise that you will not see them anymore once you mount a disk in that location. (They will show up again after you umount it, and they will still use diskspace).

Now edit /etc/fstab and add the relevant lines.

#Device       Mountpoint          FStype  Options       Dump    Pass#
/dev/sdb1     /home/old_backup    ext2    ro              2       2      

Test with mount /home/old_backup.

The next time you boot or issue a mount -a it will be automatically mounted.

Jenny D
  • 27,358
  • 21
  • 74
  • 110
0

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.

Daniel Widrick
  • 3,418
  • 2
  • 12
  • 26
0

Within /etc/fstab change auto to noauto for the second drive. Then edit and add the following line to /etc/rc.local before exit 0 line or at the end if it is absent:

test -L /dev/disk/by-uuid/uuid_of_1st_drive && mount UUID=uuid_of_2nd_drive
RLazar
  • 101
  • 3