Detect and mount external usb drive - Linux (Debian)
Mounting external hard drive on boot can be very tricky, troublesome operation. First, it adds delay to the boot sequence, then the drive has to be recognized and mounted. Imagine, if for some reason, the OS can't find the drive. It will get stuck at its boot sequence, waiting for the user to tell it to continue or not. You don't want this to happen.
What you need is autofs. Just apt-get install autofs
and configure automounts -> create an entry for this drive in /etc/auto.master
.
Example:
/mnt /etc/auto.mnt --timeout=120 --ghost
; Then in /etc/auto.mnt
put: ``backup -fstype=ntfs,rw UUID=
Related videos on Youtube
Omar Mir
Updated on September 18, 2022Comments
-
Omar Mir almost 2 years
I have a 3TB USB 3.0 External HDD (Seagate) that I would like my Debian machine to pick up on boot so that I can use rsync to backup to it using cron.
If i unplug the drive and plug it back in then it shows up when I do:
/dev/disk/by-uuid -lah
Then I can mount it (the UUID is in fstab already) by doing:
sudo mount -a
Unfortunately when I reboot the drive is not detected. This is a headless Linux box.
The drive is NTFS formatted.
Help would be appreciated!
Thanks,
-
Paul almost 12 yearsIs it the /dev/disk/by-uuid/ link that is not present, or the actual device?
-
Omar Mir almost 12 yearsThe actual device. If I unplug the USB and plug it back in then the device shows up.
-
Vinnyt almost 12 yearsAfter rebooting does the device show up when you run lsusb? This is before the /dev shows up but while the device is plugged in
-
Yasushi Shoji almost 12 yearsIt could be power stabilization time. 3TB USB 3.0 HDD is huge. It might not be ready by when udevadm runs. What do you see in your kernel log file when you plug it in? What do you see when you cold-boot with the HDD pluged in? Does anything change if you hot reboot?
-
terdon almost 12 yearsHave you tried simply using gvfs? That should pick it up ok.
-
Omar Mir almost 12 yearslsusb has no effect @i.. - I have tried that as per a few suggestions in my research.
-
Omar Mir almost 12 years@YasushiShoji I'll try that, I normally don't have a screen attached to the system.
-
Omar Mir almost 12 years@terdon not sure I can use gvfs on a headless, gnome-less box.
-
Yasushi Shoji almost 12 years@OmarMir, you do not have to have a screen attached. Check the files under
/var/log/
. -
Omar Mir almost 12 years@YasushiShoji I'll try that soon and get back to you :)
-
zero2cx almost 12 yearsWhat does this mount's
/etc/fstab
entry look like? What did your look at the log files tell you?
-