Mounting the windows fat32 drive on startup for a normal user

This can be done by adding the line similar to the one shown below, to the end of the /etc/fstab.

/dev/sda6     /home/tony/win     vfat     defaults,uid=500,gid=500     0     0

This will automatically mount the fat32 drive/dev/sd6 to the directory /home/tony/win for the user with uid=500 in read/wite mode. Modify the /dev/sdax and /home/tony/win appropriately to reflect your setup.

The uid and gid of the user can be found by the command

[tony@localhost ~]$ id
uid=500(tony) gid=500(tony) groups=500(tony)

Before doing this take a backup of fstab by

[tony@localhost ~]$ su -
[root@localhost ~]# cp /etc/fstab /etc/fstab.bak

Now you can use gEdit to add the line

[root@localhost ~]# gedit /etc/fstab

Once we add the line, we could check the result of it immediately [without rebooting] by,

[root@localhost ~]# mount -a

Check whether we have the required result, if not modify the lines appropriately and recheck.

If a drive is mounted, you can unmount it, for any reason [perhaps to try another set of options] by,

[root@localhost ~]# umount /home/tony/Data/

A bit of info on how things work.

When a system boots the kernel reads the /etc/fstab and mounts the filesystems specified in it according to the list of options specified.
Each filesystem is described on a separate line. Fields on each line are separated by tabs or spaces.  Lines starting with ’#’ are comments.

The general form of the line is

device     directory     partition-type     mount-options     fs_freq     fs_passno

Lets see the possible values of these fields,
device – the partition as seen by linux
eg: /dev/sda5

directory – the directory that will be the mount point
eg: /home/john/windows

eg: vfat

mount-options – They are comma separated list of words which determine how the filesystem will be mounted. Some useful options are,
rw – read/write
ro – read only
auto – mounts automatically
noauto – not mounted automatically
exec – allows execution of binary files
noexec – no execution of binary
user – allows mounting by any user
users – allows mounting by any user but any other user can unmount.
sync – data written synchronously
async – data written asynchronously
uid=x,gid=x – Set the owner and group owner of the files (available only for some partition types)

defaults -rw,auto,exec,nouser,async

For full list and and more details on each of the options, check man mount.

fs_freq – This is used by  the dump command  to determine which filesystems need to be dumped. This field is 0 usually. Dump will assume that the filesystem does not need to be dumped.

fs_passno - This is used by the fsck program to determine the order in which filesystem checks are done at reboot time. It can be left 0. fsck will assume that the filesystem does not  need  to be checked.

man mount
man fstab

Leave a Reply

Your email address will not be published. Required fields are marked *

eight − 5 =

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>