If you haven’t yet, read man mount 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 fdisk -l (that’s l as in list) as root. That command will simply list your disk partitions and exit.
Below is a sample output: Code: fdisk -l
Device Boot Start End Blocks Id System
/dev/hda1 * x xxxx xxxx+ 7 HPFS/NTFS
/dev/hda2 xxxx xxxx xxxx b W95 FAT32
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 /dev/hda1 and /dev/hda2.
Now you should have everything you need to mount the filesystems.
Assuming you are root, create a directory to access your drive in /mnt. For this example, we’ll use ntfs as the directory name for the NTFS drive.
# mkdir /mnt/ntfs
Next, mount the partition using the mount command. When using mount, use the -t argument to specify the filesystem type (ntfs, in this case), then the device name (/dev/hda1 from the example) and the directory to access the drive (/mnt/ntfs):
# mount -t ntfs /dev/hda1 /mnt/ntfs
If you were going to mount a FAT32 partition, the -t type would be vfat.
# mount -t vfat /dev/hd /mnt/vfat
For MS-DOS partitions, the option would be msdos instead.
# mount -t msdos /dev/hd /mnt/msdos
Now that you know how to mount a Windows or MS-DOS filesystem, you can add an entry to your /etc/fstab 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: File: /etc/fstab
/dev/hda1 /mnt/ntfs ntfs defaults 0 0
The defaults 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 behaviour, then go on reading.
The same options that are available with the mount program can be passed in fstab as well. Again, read man mount 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 defaults to ro instead. File: /etc/fstab
/dev/hda1 /mnt/ntfs ntfs ro 0 0
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 noauto to the options. Options in the fstab file are comma separated, with no spaces between them. File: /etc/fstab
/dev/hda1 /mnt/ntfs ntfs ro,noauto 0 0
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 user 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
$ 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 users instead of user in the fstab line.”
In summary, add the user option to allow any user mount the partition, but that user will be the only one who can unmount it. Or add the users 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 uid and gid 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 uid and gid, run id .
$ id larry
So if you wanted everything owned as larry:users on /mnt/ntfs, this is what you would use in /etc/fstab: File: /etc/fstab
/dev/hda1 /mnt/ntfs ntfs uid=1000,gid=100 0 0
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. File: /etc/fstab
For example, if you want everybody to be able to read, write, and execute every file in your /mnt/c, you should specify the mask 0000:
/dev/hda1 /mnt/vfat vfat umask=0000 0 0
If you want only users from group 610 to be able to read, write, and execute:
/dev/hda1 /mnt/vfat vfat gid=610,umask=0707 0 0
If you want only users from group 610 to be able to read, and execute (not write):
/dev/hda1 /mnt/vfat vfat gid=610,umask=0727 0 0
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. File: /etc/fstab
/dev/hda1 /mnt/vfat vfat ro,nls=utf8 0 0
“nls=utf8″ doesn’t work for me on vfat (dmesg: “FAT: Unrecognized mount option “nls=utf8″ or missing value”)
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.