[Ubuntu-PH] Mounting harddrives

Arman Awatin arman at weblogic-ht.net
Tue Aug 23 07:02:26 UTC 2005


Hi arlan,

I have a script which you can use to solve your problem, so you won't get
confuse configuring your fstab etc..
Make sure your HDDs are properly installed.

Also, you need to study the links they gave to you. Coz it's much better to
solve and face the problem by your own. :)

Save this script to anyfilename.sh
Then run the script at the shell by typing ./anyfilename.sh

### Begin ###

#!/bin/bash

if [[ $UID != 0 ]]; then
    echo 'you should run this program as r00t or by using sudo'
    exit 1
fi

RWALL=-1;

if [[ $1 == '-w' ]]; then RWALL=1; fi
if [[ $1 == '-r' ]]; then RWALL=0; fi

if [[ $RWALL == -1 ]]; then
    echo 'by default the disks will be writable only by r00t and'
    cat /etc/passwd | awk -F ':|,' '/:1000:/ {print $5 " (" $1 ")"}'
    echo 'Do you want to make the disk writable by all users instead? (Y/N)'
    read RESP
    if [[ $RESP == 'y' || $RESP == 'Y' ]]; then
        RWALL=1
    else
        RWALL=0
    fi
fi

if [[ $RWALL == 1 ]]; then
    OPTIONS='umask=0000'
else
    OPTIONS='umask=0022,uid=1000,gid=1000'
fi

drivesntfs=`fdisk -l | grep -i 'ntfs' | awk -F '/| ' '{print $3}'`
drivesfat=`fdisk -l | grep -i 'fat32' | awk -F '/| ' '{print $3}'`

for drive in $drivesntfs
do
    if [[ ! `grep $drive /etc/fstab` ]]
    then
        mkdir "/mnt/$drive"
        echo "#added by windows fstab" >> /etc/fstab
        echo "/dev/$drive /mnt/$drive ntfs ro,$OPTIONS 0 0" >> /etc/fstab
    fi
done
for drive in $drivesfat
do
    if [[ ! `grep $drive /etc/fstab` ]]
    then
        mkdir "/mnt/$drive"
        echo "#added by windows fstab" >> /etc/fstab
        echo "/dev/$drive /mnt/$drive vfat rw,$OPTIONS 0 0" >> /etc/fstab
    fi
do "sudo mount -a"
done

### End ###

got a problem? just explain it... :)
But Im sure 100%, it should work...

Cheers,

- arman


> Just new in using ubuntu, my problem is I don't know how to mount a
> windows harddisk since I need to copy some files in it.
>
> The system recognize that there are 2 hard drives but ubuntu can't see
> it. Hope you can help me. If ever please give the step by step
> process.
>
> Thanks in advance and more power!
> --
> Arlan R. Tiu
> Computer Teacher / I.T. Head
> St. Peter the Apostle School
> 1260 Pres. Quirino Ave. Ext., Paco, Manila, Philippines
> 0921-3098333
>
> --
> ubuntu-ph mailing list
> ubuntu-ph at lists.ubuntu.com
> http://lists.ubuntu.com/mailman/listinfo/ubuntu-ph
>





More information about the ubuntu-ph mailing list