SC101/Mount Helper

From ZeroPain's Wiki

Jump to: navigation, search

This script will allow you to put entries into your fstab to attach/mount your sc101 partitions with a simple "mount -a". Here is the stab i use to give an example.

[edit] /etc/fstab

 
# <file system>                                 <mount point>   <type>  <options>                               <dump>  <pass>
proc                                            /proc           proc    defaults                                0       0
UUID=c47eb30f-27ca-4c1b-8c02-f5b6c216ce8f       /               ext3    defaults,noatime,nodiratime,errors=remount-ro   0       1
UUID=babdbe3e-8d6c-4c51-b1a1-41ae5858952f       none            swap    sw                                      0       0
/dev/scd0                                       /media/cdrom0   auto    user,noauto,exec                        0       0
/dev/fd0                                        /media/floppy0  auto    rw,user,noauto,exec                     0       0
4928947C-35BE-11DD-B1CC-005056C00008            /media/250GB-1  ut      _netdev,defaults,noatime,nodiratime     0       0
879B8B36-35C0-11DD-B1CC-005056C00008            /media/250GB-2  ut      _netdev,defaults,noatime,nodiratime     0       0
B5D04775-3741-11DD-B1CC-005056C00008            /media/250GB-3  ut      _netdev,defaults,noatime,nodiratime     0       0
3A3F66AD-3742-11DD-B1CC-005056C00008            /media/250GB-4  ut      _netdev,defaults,noatime,nodiratime     0       0
8D242890-EC9D-11DC-A648-0015E9668AD0            /media/300GB-1  ut      _netdev,defaults,noatime,nodiratime     0       0
2488DF6A-EC98-11DC-8CF0-0015E9668AD0            /media/300GB-2  ut      _netdev,defaults,noatime,nodiratime     0       0

i use the _netdev option this way it doesn't try to mount or attach my drive before my network has started.

[edit] /sbin/mount.ut

 
#!/bin/bash
# /sbin/mount.ut
# Author: Steven Norder
# Email: info@zeropain.com
# Website: http://wiki.zeropain.com/index.php/SC101/Mount_Helper
# Date: 07-05-2008
# Description: Allows Entries into fstab for mounting on boot
# Version 0.01
 
#!/bin/bash
if mount | grep -q $2
then
        #echo $2 already mounted
        exit 0
else
        if ps w -C ut | grep -q $1
        then
                #echo "Already Attached"
                PS=`ps w -C ut | grep -E $1 -m1`
                nbd=`echo $PS | sed -r "s/.*$1 //"`
                #echo Mounting $nbd
                mount $nbd $2 -o $4
        else
                #echo "Not Attached"
                for nbd in /dev/nbd* 
                do 
                        if [ "$stop" != "1" ]
                        then
                                if fuser -s $nbd
                                then
                                        #echo $nbd taken
                                        continue
                                else
                                        #echo "Attaching $1 to $nbd"
                                        ut attach $1 $nbd
                                        mount $nbd $2 -o $4
                                        stop=1
                                fi
                        fi
                done
        fi
fi

should be as easy as typing nano /sbin/mount.ut and then pasteing the above file then just ctrl+x y enter. oh and don't forget to chmod +x /sbin/mount.ut

Then just make sure you put your partition ids in your /etc/fstab like i did above and you should be good to go if you have any problems let me know. I have only tested this on ubuntu but i don't see why it wouldn't work on others. From what i understand they all use mount helpers in pretty much the same way

Personal tools
Google AdSense