# UN2: Mounting MS Windows partitions (FAT,NTFS)

## pilla

Navigation: [Uncategorized] [Table of Contents]

Symptoms:

Cannot mount a Windows (tm) partition, or just root can access a mounted partition.

Solution:

Step 1 Build a kernel with support to your Windows (tm) file systems

There are two main types of Windows (tm) partitions: NTFS and FAT-based. The first step is to compile the file system support for these in your kernel or as modules.

In the kernel configuration menus, go to File Systems and enable:

```

...

<*> DOS FAT fs support

<*> MSDOS fs support

...

<*> VFAT (Windows-95) fs support

...

<*> NTFS file system support (read only)

...

```

Compile also the Native Language Support (usually ISO 8859-1) in  Native Language Support.

It is very important not enabling write support for NTFS, as it is DANGEROUS. These are recommended settings, if you are sure you do not need some of these, feel free not to select them. You can also build them as modules. Compile and install your new kernel and modules, reboot your computer and you are ready for the next step. 

Step 2 Setting your /etc/fstab

Considering that your Windows (tm) partition is on /dev/hda1 and it is a FAT32 partition, the basic configuration for your /etc/fstab should be:

```

/dev/hda1   /mnt/c   vfat   defaults   0 0

```

where /dev/hda1 is the partition, /mnt/c the mountpoint where the partition will be available after mounting, vfat is the file system type, defaults is the option to be passed to mount, and 0 0 is related to file system integrity test (no test with 0 0). This will allow only root to enter, read or write /mnt/c or its contents.  If you want to allow only a given user/group to access it, use the options uid and gid:

```

/dev/hda1   /mnt/c   vfat   defaults,uid=510,gid=610 0 0

```

will mount /mnt/c for the user with user id 510, and will set the group id for 610. But the default group permission is read-only, so users of the same group cannot enter the directory (because it is not set executable). 

 :Exclamation:  Options like "defaults,uid=510,..." are only separed by ",". A space or a tab will give a message like:

 *Quote:*   

> 
> 
> [mntent]: line 16 in /etc/fstab is bad
> 
> mount: can't find /mnt/c in /etc/fstab or /etc/mtab
> ...

 

You can change permissions using the parameter umask. But be aware that it must be the bitmask of permissions that are not present for the mountpoint. It is an octal number, formed like this:

 :Arrow:  first digit: permissions for everybody

 :Arrow:  second digit: group permissions

 :Arrow:  third digit: user permissions

The modes are as follows (the first column is the mode octal number):

 *Quote:*   

> 
> 
> M |	R	W	X
> 
> --------------------
> ...

 

For example, if you want that everybody be able to read, write, and execute every file in your /mnt/c, you should specify the mask 000:

```

/dev/hda1   /mnt/c   vfat   defaults,umask=000    0 0

```

If you want that only users from group 610 be able to read, write, and execute:

```

/dev/hda1   /mnt/c   vfat   defaults,gid=610,umask=707    0 0

```

If you want that only users from group 610 be able to read, and execute (not write):

```

/dev/hda1   /mnt/c   vfat   defaults,gid=610,umask=727    0 0

```

If you have a NTFS partition, change vfat to ntfs and add ro (read-only) to the option line:

```

/dev/hda1   /mnt/c   ntfs   defaults,ro      0 0

```

----------

## pilla

Please forward comments to this thread.

----------

