Ever find you're constantly adding/removing drives and trying to find which device is which..where it mounted…I was doing it often enough, couldn't remember especially when they shift due to the way linux boots and changes the partitionidentity…on one boot, my main partition is sda1, next time, it's sdc1 so mount manual mount commands would need to be edited…

Enough I said…

This little script runs at boot in my /etc/rc.local, and now mounts all my partitions by their current id…ie, /mnt/sda1, /mnt/sdc1..etc

cd /;

# umount everything added now except root disk (will fail umount)
umount /dev/sd*;
umount /dev/hd*;

# make directory for all disks and partitions found, mount any that will
for d in /dev/sd*;do c=${d##*/};mkdir /mnt/$c;mount $d /mnt/$c ;if [ "$(ls -A /mnt/$c)" ]; then echo "mounted /mnt/$c" ;else rm -r /mnt/$c; fi;done
for d in /dev/hd*;do c=${d##*/};mkdir /mnt/$c;mount $d /mnt/$c ;if [ "$(ls -A /mnt/$c)" ]; then echo "mounted /mnt/$c" ;else rm -r /mnt/$c; fi;done

# find root disk and umount it from /mnt/…
df |head -n 2|tail -n 1| awk '{ print $1}'  >/holding
exec < /holding
while read FILESYSTEM
do
umount $FILESYSTEM
done

# remove /mnt/sd… and /mnt/hd… folders with no contents
for d in /mnt/sd*;do if [ "$(ls -A $d)" ]; then echo "contents in $d" ;else rm -r $d; fi;done
for d in /mnt/hd*;do if [ "$(ls -A $d)" ]; then echo "contents in $d" ;else rm -r $d; fi;done

In a nutshell, it simply drops all existing mounted partitions, then scans for partitions on all ide, sata and scsi devices, creates a mount point and mounts the partitions.  Then it drops the root drive from the list.  It finishes by clearing any mount points that failed (swap drives, etc). 

Verified by MonsterInsights