Mounting Windows Partitions

If you are dual-booting your system with Windows, at some point you may want to share files between the two operating systems. Fortunately, the Linux kernel provides full read/write support for FAT32 and the older FAT filesystems. Full NTFS read-only support is natively available in the kernel as well, along with a small (almost useless) write support. Full write support for NTFS is available using the userspace read-write driver. Install guide.

Many hardware flash drives (included in digital cameras, mp3 players, for example) format their partitions with the VFAT filesystem, and this guide will apply to those who want to access their data on those devices as well.

If you are interested in formatting your partitions to one of the FAT filesytems, mkfs.vfat and mkfs.msdos are available in the package.

Mounting your Windows drives is simply a matter of reconfiguring your kernel with the right options.

Recommended reading before proceeding includes the documentation for the Linux-NTFS project, which provides the user tools, and the MAN page for mount.

Kernel Configuration
If you are using genkernel, chances are that DOS/VFAT/NTFS support is already included into your kernel, and are readily available as modules. You can load them, as root, respectively, with

If you are compiling your own kernel and wish to add modular or included support into yours, issue and navigate to the File Systems menu. From there will be an entry for DOS/FAT/NT Filesystems leading to a sub-menu.

In the above example, all three options are selected as modules. In most cases, you'll never need MSDOS fs support, since that is for writing to very old FAT16/FAT32 file systems. Most general users would need to add VFAT (Windows-95) fs support to access their Windows system and/or flash devices, and NTFS file system support to access their Windows partitions.

Before exiting your kernel configuration, there is one more thing to add: Native language support. The kernel's Help sub-option describes the necessity well:

To get to NLS support, exit out of the DOS/FAT/NTFS sub-menu, and enter the sub-menu in File Systems for Native Language Support.

If you've already enabled one of the filesystem options in the other menu, the first option in this menu will be marked as included (--- Base native language support). The second line has a default NLS option. Don't change it unless you know you need to.

If you are going to use MS-DOS support (read/write to MS-DOS partitions, not VFAT), then you will have to either compile in or select one of the Codepage options as a module. Each codepage option has a country or region listed next to it, so choosing yours shouldn't be difficult. If you are only using VFAT and/or NTFS support, you can skip that option.

Users of VFAT and/or NTFS read/write support, will need to choose one of the NLS ISOs that are available. Again, choose the selection that most closely resembles your region or language. For English-speaking countries, the first option, NLS ISO 8859-1, is what you will need.

If you need to add support for files saved with Unicode characters, then NLS UTF8 is availabe as an option as well.

Save your settings, recompile your kernel (and reboot), or load the modules when finished.

Mounting Partitions
If you haven't yet, read for some really good information on what your options and limitations are in mounting each filesystem type.

Once support is added into your kernel, you're ready to go. If you want to mount some existing partitions on your harddrives, the first thing to do is find out what their device names are listed as. A good way to find out is to run (that's l as in list) as root. That command will simply list your disk partitions and exit.

Below is a sample output: fdisk -l

In this example, the harddrive running Windows has its C:\ drive formatted as NTFS and its D:\ drive formatted as Windows 95 FAT32 (VFAT). And, from the Device column, we can see that they are listed as and.

Now you should have everything you need to mount the filesystems.

Basics
Assuming you are root, create a directory to access your drive in. For this example, we'll use as the directory name for the NTFS drive.

Next, mount the partition using the mount command. When using mount, use the argument to specify the filesystem type (, in this case), then the device name ( from the example) and the directory to access the drive :

If you were going to mount a FAT32 partition, the type would be.

For MS-DOS partitions, the option would be msdos instead.

/etc/fstab
Now that you know how to mount a Windows or MS-DOS filesystem, you can add an entry to your file, so that next time you can simplify the process.

The filesystem tabular file (fstab) entries should be one per line, with spaces or tabs between columns. The columns are in order of filesystem (or device), mountpoint, filesystem type, options, and dump / pass variables.

Open up the file with your favorite editor (as root), and add a new line at the end of the file.

First, put your filesystem's device. From our example above, if you wanted to mount your Windows C:\ drive formatted as NTFS with the default values (more options explained below), this is what you would add to your file:

The option will both mount the partition at every time at boot, and set it to read/write access for root only. If you also want to change this behavior, then go on reading.

Mount Options
The same options that are available with the mount program can be passed in fstab as well. Again, read for a full explanation of your options, as this wiki entry will only cover the basics.

ro: readonly filesystem
If you wanted it so you can only read data, and not write to the hard drive, change to  instead.

noauto: don't mount at boot
With that option /mnt/ntfs will always be mounted everytime you boot. If you didn't want it to automatically mount each time, but instead mount it manually, add to the options. Options in the fstab file are comma separated, with no spaces between them.

user, users: let users mount and unmount
Taking a page from man mount (which explains it much better than we ever could),

"Normally, only the superuser can mount file systems. However, when fstab contains the option on a line, then anybody can mount the corresponding system.

Thus, given a line in /etc/fstab /dev/cdrom /mnt/cdrom  iso9660  ro,user,noauto,unhide

any user can mount the iso9660 file system found on his CDROM using the command $ mount /dev/cdrom

or

$ mount /mnt/cdrom

''For more details, see fstab(5). Only the user that mounted a filesystem can unmount it again. If any user should be able to unmount, then use instead of  in the fstab line."''

In summary, add the option to allow any user mount the partition, but that user will be the only one who can unmount it. Or add the option to let any user mount or unmount that partition.

uid,gid: mount as (user,group)
On all three filesystems (MS-DOS, VFAT, NTFS), mount lets you pass the and  options, which let you set the user and group IDs of who the files are shown to when the filesystem is mounted.

To find out the values for and, run.

$ id larry uid=1000(larry) gid=100(users)

So if you wanted everything owned as larry:users on /mnt/ntfs, this is what you would use in /etc/fstab:

Without any options, mount will default to user 0 and group 0, or root.

umask: octal file permissions
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:
 * character '0': Indicates that this is an octal number, not decimal.
 * first digit: owner user permissions
 * second digit: owner group permissions
 * third digit: world permissions (every other user on the system)

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

M | R W X - 0 | * * * 1 | * * - 2 | * - *  3 | * - - 4 | - * * 5 | - * - 6 | - - * 7 | - - -

Note: These octal number codes differ from the octal number codes used by chmod.

To create a simple and full access to a partition for all users you need for instance: /dev/hda2     /mnt/WINXP     ntfs     auto,umask=0000    0 0 /dev/hda7     /mnt/WINME    vfat     auto,umask=0000    0 0 /dev/hdb5     /mnt/EXT         ext3    defaults,users           0 0

utf8: Unicode support
You may also add "utf8" option, if you can't see some files with international characters in filenames.

Troubleshooting
If after changing permittion options in /etc/fstab you mount partition and permissions did not change, check if this partition is already mounted to another directory. Unmount the partition first, since you cannot mount the same partition to different directories with different options at the same time.