There were a couple of threads on automounting and I was thinking of
sharing this anyway. In my case, using Ubuntu, the problem is that my
server is rebooted remotely, but attached USB drives don't automount until
I log in at the console. They would then mount in /media/${USER}/ It
turns out there is a simple answer -- find the drive device in /dev
(say it turns out to be /dev/sdd2) and then run a command that looks like
this:
udisksctl mount -b /dev/sdd2
My little one-liner script below simplifies this (and helps me remember)
by allowing me to do this instead:
automount_drive d2
To find the proper device info, you can use fdisk -l, as root. For me
this one-liner provides exactly the drives I'm looking for and nothing
else:
( sudo fdisk -l | grep -E "[0-9]T .*(NTFS|Microsoft)" ) 2>&1 | grep -v "physical sector boundary"
Best,
Mike
#/bin/bash
# mounts USB drive in /media/${USER}/
#
# It is assumed to be /dev/sdXN (where XN are a letter and an number)
# syntax:
#
# automount_drive XN
#
# example - this mounted /media/mbmiller/DriveA:
#
# automount_drive f2
#
# It (sometimes) prompts for user password, then reports the mount point
#
# Those may change. To get the newest sdXN values, do this:
#
# sudo fdisk -l
#
# But that pumps out a lot. To find the attached drives with multiple TBs
# of storage, try this:
#
# sudo fdisk -l | grep -P "\dT "
#
# It's a simple command:
udisksctl mount -b /dev/sd$1