November 22, 2024, 11:33:39 AM

News : LinuxSolved.com Linux Help Community Forum..


Author Topic: Mounting Fat partitions automatically  (Read 16986 times)

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Mounting Fat partitions automatically
« 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..

Offline neo

  • Linux Learner
  • ***
  • Posts: 125
    • http://www.investorsgain.com
Mounting Fat partitions automatically
« Reply #1 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.

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Mounting Fat partitions automatically
« Reply #2 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..

Offline kennynoah

  • Linux Noob !
  • *
  • Posts: 6
Mounting Fat partitions automatically
« Reply #3 on: January 19, 2004, 01:05:33 PM »
how do i mount an NTFS partition

Offline Ricky

  • LST CareTaker
  • Specially Skilled
  • *****
  • Posts: 2381
Mounting Fat partitions automatically
« Reply #4 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

Offline huihuitiao

  • New Member
  • Posts: 1
only mount windows partition c ,can't mount d,e f
« Reply #5 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?

Offline liquid

  • New Member
  • Posts: 1
[b]mounting fat partitions in Linux red hat 9[/b]
« Reply #6 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.

Offline Alien74

  • New Member
  • Posts: 2
Mounting Fat partitions automatically
« Reply #7 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:

Offline MhykGyver

  • Linux Noob !
  • *
  • Posts: 13
Mounting Fat partitions automatically
« Reply #8 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...