Web lists-archives.com

Re: Command line mounting all partitions of pluggable device




On 01/14/2019 09:02 AM, rhkramer@xxxxxxxxx wrote:
Top posting intentionally:  I guess the key is something has to know where to
mount those devices, and you are the one that has to decide that and tell
mount in one way or another.

Using your scheme of "/dev/sd<device_letter><n>" the desired mount point can be "computed" by piping the output of "lsblk -l -o name,label" to appropriate script(s).
The input parameter would be "sd<device_letter><n>".
The desired mount point would be
 "/media/richard/<label of sd<device_letter><n>>".
{Any 'partition' with a blank label is not to be mounted.}



On Monday, January 14, 2019 10:01:15 AM rhkramer@xxxxxxxxx wrote:
On Monday, January 14, 2019 09:12:30 AM Richard Owlett wrote:
On 01/14/2019 07:33 AM, rhkramer@xxxxxxxxx wrote:
On Monday, January 14, 2019 08:11:11 AM Richard Owlett wrote:
How do I mount all partitions of a specific device
(e.g. /dev/sdc)?

Assuming there are entries in fstab for each partition,

There are not. I have a varying number of devices. Each device is
normally associated with a specific function (e.g. sneaker-net) or
personal project. A specific physical device may be reformatted and
assigned a new purpose.

you could use a (bash) for loop, like:

for i in  /dev/sd<device_letter>*;  do  mount $i; done

Hmm, well, that makes it (for me) harder.

If they all have similar mounting options (e.g., RO, things like that), and
the mount points correspond to some system (e.g., /dev/sd<device_letter><n>
gets mounted on /mnt/<mountpoint><n>), then you might modify the mount
command in that loop appropriately, e.g.:

mount  /dev/sd<device_letter><n> /mnt/<mountpoint><n> <options>

Or, if groups of those devices have mountpoints that correspond to some
system, then you could haved multiple for loops to do the groups.

Or you could put mount commands in a file, one line per file, and run  a
for loop on the lines of the file, or some variation of this.