Linux in General > Linux Development & Programming

Mounting Fat partitions automatically

(1/2) > >>

Ricky:
Hi guys... i m here with a script which can mount your Fat partitions (windows partition) automatically....
I have tested it.. but i m inviting outher people to test it and if it has any problem please correct that or tell me.


--- Code: ---#!/bin/bash
label[1]="C"
label[2]="D"
label[3]="E"
label[4]="F"
label[5]="G"
label[6]="H"
label[7]="I"
label[8]="J"
label[9]="K"
label[10]="L"

fdisk -l | grep Win95 | grep -v Extended | grep -v "Ext'd" | cut -f 1 -d" " > /tmp/scriptdump
echo "Checking FAT partitions...."
i="1"
suffix=""
found="false"
working="true"

while read device
do
if [ $working = "true" ]
then
echo "#The Partition Found by Script" >> /etc/fstab
echo -e "Found Windows FAT partition(s). \nMounting them ..."
working="false"
fi
found="true"
echo "$device /mnt/${label[$i]}$suffix"" vfat defaults 0 0" >> /etc/fstab
mkdir /mnt/${label[$i]}$suffix""
done < /tmp/scriptdump


if [ $found = "true" ]
        then
echo "# Partition mounted by script" >> /etc/fstab
mount -a -t vfat
echo -e "\nSuccessfully mounted Windows partitions"
else
echo -e "\nNo Windows (FAT) partitions found\n"
fi

rm -f /tmp/scriptdump

--- End code ---

Copy this script to a file name :: "mountfat" and then chmod this file to 755 and then execute this script...
You should be login as root to run this script..

neo:
hey ricky
why donot we put the partitions to mount in fstab it will mount at startup and also unmount at shutdown.

Ricky:
Hmm.. that script needs to be run only once..  it will autmatically give make the entries in your fstab so that you get your fat partitions mounted automatically every time you boots..

kennynoah:
how do i mount an NTFS partition

Ricky:
Your question is already answered here..
http://www.linuxsolved.com/forums/viewtopic.php?t=118 in first reply there

Navigation

[0] Message Index

[#] Next page

Go to full version