On Thu, 9 Aug 2018, Iznogoud wrote:

>> ( sudo fdisk -l | grep -E "[0-9]T .*(NTFS|Microsoft)" ) 2>&1 | grep -v "physical sector boundary"
>
> Can't one use "udev" to take care of all this given that USB can be 
> queried by udev and then udel rules can be used? Maybe a little less "ad 
> hoc" or not?

Thanks, Iznogoud!

I don't know how to use udev, but it does seem like the sort of thing I 
should learn.  Here's what's happening on my system:

(1) there are several USB drives attached to the machine
(2) when it reboots, those drives are not automounted, until...
(3) I log in at the console, and then they are mounted, but...
(4) if I'm not there, but I ssh in, they are still not mounted.

So I came up with my way of doing it remotely.  It would be much better if 
the system were to mount all attached drives before I logged in.  (The 
fdisk/grep command above is really just listing the USB drives that are 
not mounted.)  I think the udev system could be made to do that.

Is that right?

While I'm on this topic, because of how they are mounted, these drives are 
only accessible to me -- to my user account -- and not to other users or 
processes.  I would like to be able to make them available to, say, the 
Apache web server.  Does anyone know how to do that?

Best answer would do this:

(1) mount all attached USB drives at startup before anyone logs in and
(2) all mount points have certain owner/group permissions:
     I am owner (rw), www-data is group (r-only)
(3) do the same thing when a new USB drive is attached to the already-running system

Thanks in advance to anyone who can tell me how this works!

Mike