<1 要掛載的裝置> <2 掛載到哪個目錄> <3 檔案系統的型態> <4 掛載的選項> <5 fs_freq> <6 fsck 檢查檔案系統時的順序>
自動掛載 FAT 分割區要在第 3 欄指定檔案系統的型態為 vfat,此外台灣地區 Windows 下繁體中文通常是以 Big5 來編碼,因此在第 4 欄的掛載選項中要加入 iocharset=utf8 以及 codepage=950 這兩個選項,否則掛載上去以後在 Nautilus 裡面的中文檔名可能變成亂碼,底下是從我 fstab 中擷取出來:/dev/sda2 /media/sda2fat32 vfat owner,exec,dev,suid,rw,auto,umask=000,iocharset=utf8,codepage=950 0 0
其中第 4 欄的 umask 是用來指定檔案及目錄的權限,當 FAT 磁區被掛載上去了以後通常是無法直接用 chmod 來更改磁區內檔案及目錄的權限的,必需從 fstab 中先設好。umask=000 代表打開所有的權限,即 -rwxrwxrwx;而 umask=777 則代表關閉所有權限,即 ----------。所以 umask 的設定方式正好與 chmod 相反,umask=674 相當於 chmod 103,umask=257 相當於 chmod 520 依此類推…。如果檔案和目錄想要指定不同的權限,則可以分別以 fmask 及 dmask 來指定,打 man mount 然後搜尋 umask 可以找到 umask、fmask 及 dmask 的用法。輸入命令 man fstab 可以看到更多 fstab 的詳細說明,第 4 欄的掛載選項的詳細說明則要打 man mount 去找。下面是我完整的 fstab,最後兩行掛載的就是 FAT 磁區:
# /etc/fstab: static file system information. # ## The following description is from 'man fsck': ## ## The root filesystem will be checked first unless the -P option is specified (see below). After ## that, filesystems will be checked in the order specified by the fs_passno (the sixth) field in ## the /etc/fstab file. Filesystems with a fs_passno value of 0 are skipped and are not checked at ## all. Filesystems with a fs_passno value of greater than zero will be checked in order, with ## filesystems with the lowest fs_passno number being checked first. If there are multiple ## filesystems with the same pass number, fsck will attempt to check them in parallel, although it ## will avoid running multiple filesystem checks on the same physical disk. ## ## Hence, a very common configuration in /etc/fstab files is to set the root filesystem to have a ## fs_passno value of 1 and to set all other filesystems to have a fs_passno value of 2. This will ## allow fsck to auto- matically run filesystem checkers in parallel if it is advantageous to do ## so. System administrators might choose not to use this configuration if they need to avoid ## multiple filesystem checks running in parallel for some reason --- for example, if the machine ## in question is short on memory so that excessive paging is a concern. ## ## Therefore, we should give a value, other than 0 and 1, to the fs_passno (the sixth) of swap, sda2 ## and sda5 if we want them to be checked. # # proc /proc proc defaults 0 0 # /dev/sdb6 UUID=a0cf5674-f414-4841-b3f4-86a11c6826ce / ext3 relatime,errors=remount-ro 0 1 # /dev/sdb7 UUID=8dd47df8-8c27-455f-806a-7b663184189d /data ext3 relatime 0 2 # /dev/sdb5 UUID=f63c79dd-13d2-48f6-817d-7479ef87e0bc none swap sw 0 3 /dev/scd1 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0 # FAT32 /dev/sda2 /media/sda2fat32 vfat owner,exec,dev,suid,rw,auto,umask=000,iocharset=utf8,codepage=950 0 0 /dev/sda5 /media/sda5fat32 vfat owner,exec,dev,suid,rw,auto,umask=000,iocharset=utf8,codepage=950 0 0