Page 1 of 1

automount - mounts all Linux partitions

Posted: Sat May 02, 2015 8:57 am
by machinebacon
...and no swap, of course. Please run it as root.

Code: Select all

#!/bin/bash
MNT=/tmp/mounttemp
MED=/tmp/mediatemp
MLIST=/tmp/mountlist

fdisk -l | grep Linux | grep -v swap | awk '{ print $1 }' > $MNT
sed 's/dev/media/' $MNT > $MED

for line in $(cat $MED); do
	mkdir -p $line
done
paste $MNT $MED > $MLIST
cat $MLIST | while read line
do
	mount $line
	echo "$line done"
done

Re: automount - mounts all Linux partitions

Posted: Sat May 02, 2015 4:33 pm
by stark
Insanely useful ! Thank You :)

Re: automount - mounts all Linux partitions

Posted: Sun May 03, 2015 12:07 pm
by simgin
Bloody hell Jules, you are a living bash encyclopedia :)