automount - mounts all Linux partitions

Submitted scripts and programs
Forum rules
Your own work only.
machinebacon
Baconator
Posts: 10253
Joined: Thu Sep 16, 2010 11:03 am
Location: Pfälzerwald
Contact:

automount - mounts all Linux partitions

Unread post by machinebacon » Sat May 02, 2015 8:57 am

...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
..gnutella..

User avatar
stark
MILF
Posts: 521
Joined: Sat Sep 27, 2014 6:38 pm
Location: Arpanet
Contact:

Re: automount - mounts all Linux partitions

Unread post by stark » Sat May 02, 2015 4:33 pm

Insanely useful ! Thank You :)
If you can do it go ahead and do it, if you can't do it then don't even criticize it. - gingerdesu

User avatar
simgin
Meme Fodder
Posts: 1167
Joined: Sun Jan 06, 2013 12:07 am
Location: Bradford-on-Avon, UK

Re: automount - mounts all Linux partitions

Unread post by simgin » Sun May 03, 2015 12:07 pm

Bloody hell Jules, you are a living bash encyclopedia :)
Someone told me that I am delusional, I almost fell off my unicorn.

Post Reply