HOW TO USE FAT16/FAT32/NTFS PARTITIONS IN LINUX


Copyright (C) 2004 Daniel Brodzik

This document is free software; you may distribute and/or modify it under the terms of the GNU Free Documentation License, either version 1.2 or, at your option, any later version, with no Front-Cover Texts, no Back-Cover Texts, and no Invariant Sections.


INTRODUCTION

This guide explains how to make your FAT16, FAT32, or NTFS partitions usable from Linux. FAT12, FAT16, and FAT32 are types of file systems that are used under DOS and Windows. If you have Windows NT/2000/XP or some other flavor of Windows NT, your Windows partitions may be in NTFS format rather than FAT16 or FAT32.


WARNING: FAT16 and FAT32 support is complete under Linux, meaning that you can safely read and write data under Linux to FAT partitions/disks. HOWEVER, NTFS write support is listed as dangerous under most, if not all, kernel versions! There is a good chance that you have such a kernel. So, if you use such a kernel (which many people do), you should mount your NTFS partitions READ-ONLY to avoid data loss! Most precompiled kernels that are included with the major distributions (e.g., Debian, Red Hat, Mandrake, SuSE, Slackware, etc.) have dangerous options like this disabled, but use caution!



PROCEDURE


FAT16 and FAT32

  1. Log into a console session as root.

  2. Type 'cd /mnt' and type 'mkdir dirname', replacing dirname with directory names you want to use to access your FAT partitions. I use 'dos0' and 'dos1' for my FreeDOS partitions, and I used to use 'win' for my Windows partition when I used Windows.

  3. Type 'fdisk -l' and note what the device filenames of the partitions you wish to mount are. These are something like /dev/hda2, which stands for hard drive 1 ('A'), partition 2.

  4. Type 'cd /etc'.

  5. Type 'nano fstab'. (You can use any text editor you want. However, since this document is mainly targeted to new users, I suggest GNU Nano because it is easy to use and because it's my favorite console-based editor. Other editors include Emacs ('Editing Macros', a spin-off of TECO, 'Text Editor and Corrector'), xemacs (a spinoff of GNU Emacs with better X11 support, among many other things), ne (Nice Editor, an easy-to-use console-based editor with pull-down menus accessible with Esc), vi (the rival of emacs), vim, joe, and many others.)

  6. If you want read AND write permissions for your user account(s), then type the following line, substituting device with the /dev/hda2 thing you got above and substituting dirname with the directory names you made in step 2, and use tabs to line everything up with the other lines:

    device /mnt/dirname vfat umask=000,quiet 0 0

    (To Linux, FAT12, FAT16, and FAT32 drives are ALL known as type 'vfat', after the Wincrap 9x VFAT 'subsystem'. Using type 'vfat' instead of 'msdos' gives you full long filename support under Linux. Actually, type 'auto' would work as well.) However, if you want only root to have full read and write access and your user account(s) to have read-only access, then type:

    device /mnt/dirname vfat umask=022,quiet 0 0

    NOTE: The 'quiet' flag keeps Linux from displaying error messages related to the fact that Linux can't set file permissions in FAT file systems. For example, I was highly annoyed every time I copied a file to a FAT partition with error messages stating that the file permissions couldn't be set. This turns off those messages. However, all important errors will still be reported.

  7. Press [CTRL][O], [ENTER] to save, and press [CTRL][X] to exit GNU nano.

  8. At the command prompt, type 'mount -a' to mount everything. Now, your partition(s) will be mounted to '/mnt/dirname' and will stay mounted after rebooting. Notice how you do not have to reboot! Under Windows, doing something like this most likely would require a reboot!


Notes:

Don't worry about losing or damaging any long filenames; Linux has full long filename support on FAT and NTFS drives. HOWEVER, even though your LONG filenames will not be damaged, the shortened ('MS-DOS') versions of the filenames may be assigned differently. Under Windows, they are assigned like this: The first six characters of the long name are taken, followed by a ~ and a number from 1 to 9. The first filename with the same first six characters gets 1, and it goes incrementally up to 9. Then it changes to the first five, and continues with 10. Then a dot followed by the first three characters of the extension are taken. Under Linux, it's the same up until 9. Then, they appear to be assigned like this: first two characters of the long name, followed by a four-digit hexadecimal serial number, followed by a ~3, a dot, and the first three characters of the extension. IN OTHER WORDS, THIS IS A WARNING NOT TO RENAME ANY WINDOWS SYSTEM DIRECTORIES WITH LONG FILENAMES UNDER LINUX! Doing so may screw up programs that refer to the short versions of the names.


NTFS

  1. Log into a console session as root.

  2. Type 'cd /mnt' and type 'mkdir dirname', replacing dirname with directory name(s) you want to use to access your NTFS partitions.

  3. Type 'fdisk -l' and note what the device filenames of the partitions you wish to mount are. These are something like /dev/hda2, which stands for hard drive 1 ('A'), partition 2.

  4. Type 'cd /etc'.

  5. Type 'nano fstab'. (You can use any text editor you want. However, since this document is mainly targeted to new users, I suggest GNU Nano because it is easy to use and because it's my favorite console-based editor. Other editors include emacs ('Editing Macros', a spin-off of TECO, 'Text Editor and Corrector'), xemacs (a spinoff of GNU Emacs with better X11 support, among many other things), ne (Nice Editor, an easy-to-use console-based editor with pull-down menus accessible with Esc), vi (the rival of emacs), vim, joe, and many others.)

  6. Due to a lack of sufficient information necessary to provide safe write support to NTFS volumes in Linux, the safe thing to do is to make the NTFS drive read-only. To do that, type the following line, substituting device with the /dev/hda2 thing you got above and substituting dirname with the directory names you made in step 2, and use tabs to line everything up with the other lines:

    device /mnt/dirname ntfs ro 0 0

    If you want read AND write permissions for your user account(s), then type:

    device /mnt/dirname ntfs rw,umask=000 0 0

    However, if you want only root to have full read and write access and your user account(s) to have read-only access, then type:

    device /mnt/dirname ntfs rw,umask=022 0 0

    Please note that unless you know exactly what you're doing or you are sure NTFS write support is as safe as FAT write support in the kernel version you're using, do not enable NTFS write support! If you want to be safe, use read-only support.

  7. Press [CTRL][O], [ENTER] to save, and press [CTRL][X] to exit GNU nano.

  8. At the command prompt, type 'mount -a' to mount everything. Now, your partition(s) will be mounted to '/mnt/dirname' and will stay mounted after rebooting. Notice how you do not have to reboot! Under Windows, doing something like this most likely would require a reboot!


Notes:

I cannot stress this enough—NTFS write support in the Linux kernel may still be DANGEROUS!! It's easy to trash an NTFS file system without much effort by enabling and using write support! You have been warned.


Linux supports many filesystems—more than Windows does! These include EXT2 (Linux native), EXT3 (Linux native), ReiserFS (UNIX), FAT12/16/32 (DOS and Wincrap), Minix, HPFS (OS/2), NTFS (Wincrap NT), HFS (yes, Linux can read Mac disks!), ISO-9660 (CD-ROM filesystem), ISO-9660 with Joliet (Windows long filenames on CD-ROMs), ISO-9660 with Rock Ridge (UNIX-like filesystem on a CD-ROM), and others.

1