SC101/Auto Mounting Script

From ZeroPain's Wiki

Jump to: navigation, search

Below is my script i will be improving on it shortly just needed something quick that worked :)

I have writen a new script /sbin/mount.ut it may provide more of what your looking for. as it will mount on boot in most cases.

 
#!/bin/bash
# ut-mount-all.sh
# Author: Steven Norder
# Email: info@zeropain.com
# Website: http://wiki.zeropain.com/index.php/Auto_Mounting_Script_SC101-nbd
# Date: 06-11-2008
# Description: Automatically find and mount SC101 Partitions
# Version 0.02
 
### Config Start
MOUNTDIR=/media
UT=/sbin/ut
FS=ext3
FSOPTIONS=noatime
### Config End
 
echo -n "Checking if nbd needs to be loaded... "
if [ -e /dev/nbd0 ]
then
        echo "Loaded"
else
        echo "Not Loaded. \nTrying to Load Now..."
        modprobe nbd
fi
 
n=0
partitionsfound=`ut listall | 
sed -nr '/^([A-Z0-9]*)-([A-Z0-9]*)-([A-Z0-9]*)-([A-Z0-9]*)-([A-Z0-9]*)\s*(\S*)\s*([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*)\s*([0-9]*)$/p'`
 
echo "Partition Id\t\t\t\tLabel\tIP\t\tSize\tNBD\tMount Point"
echo "$partitionsfound" |
while read partid label ipaddress size
do
        n=$(($n+1))
        echo -n "$partid\t$label\t$ipaddress\t$size"
        $($UT attach $partid /dev/nbd$n)
        echo -n "\tnbd$n"
        mkdir -p /$MOUNTDIR/$label
        mount -t $FS -o $FSOPTIONS /dev/nbd$n /$MOUNTDIR/$label
        echo "\t$MOUNTDIR/$label"
done
exit 0
Personal tools
Google AdSense