Re: Command line mounting all partitions of pluggable device
- Date: Mon, 14 Jan 2019 16:22:53 +0100
- From: "Thomas Schmitt" <scdbackup@xxxxxxx>
- Subject: Re: Command line mounting all partitions of pluggable device
> > 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).
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 :)