Re: Command line mounting all partitions of pluggable device
- Date: Mon, 14 Jan 2019 10:20:51 -0600
- From: Richard Owlett <rowlett@xxxxxxxxxxx>
- Subject: Re: Command line mounting all partitions of pluggable device
On 01/14/2019 09:22 AM, Thomas Schmitt wrote:
Assuming there are entries in fstab for each partition, [...]
for i in /dev/sd<device_letter>*; do mount $i; done
Rchard Owlett wrote:
There are not.
In the most general case i would have a where-to-mount directory with
lots of directories for the various partitions (here 10 drives with
20 partitions each).
But thankfully I don't have to deal with the most general case as I am
as compulsive about giving all partitions a reasonably unique label as
Debian is about assigning UUIDs.
I sketched a procedure in my response to rhkramer.
I have errands that must be run. When I return I will check to see if
your scripts catches anything mine doesn't.
for i in a b c d e f g h i j
for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
Then i'd use a variation of the proposed loop (in a script, of course):
for i in /dev/sd[a-j][1-9] /dev/sd[a-j]1[0-9] /dev/sd[a-j]20
# Skip unresolved patterns which still contain brackets
if echo "$i" | fgrep ']' >/dev/null
# Skip already mounted partitions
if mount | grep '^'"$i"' ' >/dev/null
# Obtain the drive letter and partition number from /dev/sd path
dp=$(echo "$i" | sed -e 's/\/dev\/sd//')
# Now try mounting and report success if mount did not fail
if mount "$i" /media/all_sd_dir/sd"$dp"
echo "======= mounted: $i /media/all_sd_dir/sd$dp"
Next, one could try to identify the content by skilled guessing and
create symbolic links to the mounted directories. (The risk is high
to end up with an systemd+udev revenant.)
Have a nice day :)