Linux Forums - Linux Help,Advice & support community:LinuxSolved.com

Linux in General => Linux Development & Programming => Topic started by: Ricky on November 25, 2003, 11:01:16 AM

Title: Mounting Fat partitions automatically
Post by: Ricky on November 25, 2003, 11:01:16 AM
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: [Select]
#!/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

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..
Title: Mounting Fat partitions automatically
Post by: neo on December 10, 2003, 02:20:42 PM
hey ricky
why donot we put the partitions to mount in fstab it will mount at startup and also unmount at shutdown.
Title: Mounting Fat partitions automatically
Post by: Ricky on December 10, 2003, 02:42:30 PM
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..
Title: Mounting Fat partitions automatically
Post by: kennynoah on January 19, 2004, 01:05:33 PM
how do i mount an NTFS partition
Title: Mounting Fat partitions automatically
Post by: Ricky on January 19, 2004, 01:50:28 PM
Your question is already answered here..
http://www.linuxsolved.com/forums/viewtopic.php?t=118 in first reply there
Title: only mount windows partition c ,can't mount d,e f
Post by: huihuitiao on April 17, 2004, 04:38:36 AM
I have four windows partitions ,c , d ,e ,f .use this script ,only mount partion c,can't mount other parttiions.why?
Title: [b]mounting fat partitions in Linux red hat 9[/b]
Post by: liquid on May 31, 2004, 08:49:37 AM
:( Hi ricky, i copied ur script on how mount fat partitions and i tried it. it works alright but it mounts only one fat partition a time. i have 3 fat partitions and when i restart linux it sometimes mount either of the 3 but not all and when i type df at the terminal i have duplicated drives mounted. how do i solve this problem. am kind of a newbie thanks. u've got the brain ricky.
Title: Mounting Fat partitions automatically
Post by: Alien74 on August 26, 2004, 06:40:54 AM
I dont think we have to write such a long script.
we can edit the gile /etc/fstab and put enteries of partitions to be mounted automatically.
They will be mounted during booting.
 :lol:
Title: Mounting Fat partitions automatically
Post by: MhykGyver on August 26, 2004, 12:41:34 PM
hello again guys...i tried typing the script then saving it to mountfat then typing chmod automount 755 but it just won''t work...do i have to save the script with a .txt  extension or another? i'm kinda' lost...i also tried tinkering with the /etc/fstab but i really don't know how to add my fat partition...my fat partitions are hd8 and hd7...help please...