Web lists-archives.com

Re: Command line mounting all partitions of pluggable device




Hi,

rhkramer@xxxxxxxxx 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).

For once:

  mkdir /media/all_sd_dir
  for i in a b c d e f g h i j
  do
    for j in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
    do
      mkdir /media/all_sd_dir/sd"$i""$j"
    done
  done

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
  do

    # Skip unresolved patterns which still contain brackets
    if echo "$i" | fgrep ']' >/dev/null
    then
  continue
    fi
 
    # Skip already mounted partitions
    if mount | grep '^'"$i"' ' >/dev/null
    then
  continue
    fi

    # 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"
    then
      echo "======= mounted:  $i  /media/all_sd_dir/sd$dp"
    fi
  done

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 :)

Thomas