Difference between revisions of "Fstab"

From ArchWiki
Jump to: navigation, search
(File example: update to current fstab from filesystem package)
(Label: update fstab)
Line 86: Line 86:
# <file system>        <dir>        <type>    <options>            <dump> <pass>
# <file system>        <dir>        <type>    <options>            <dump> <pass>
devpts                /dev/pts      devpts    defaults                0      0
tmp                   /tmp          tmpfs    nodev,nosuid,noexec  0      0
shm                   /dev/shm      tmpfs    nodev,nosuid           0      0
LABEL=Arch_Linux      /            ext4      defaults,noatime       0      1
LABEL=Arch_Linux      /            ext4      defaults,noatime     0      1
LABEL=Arch_Swap        none          swap      defaults               0      0
LABEL=Arch_Swap        none          swap      defaults             0      0

Revision as of 16:00, 10 August 2011

This template has only maintenance purposes. For linking to local translations please use interlanguage links, see Help:i18n#Interlanguage links.

Local languages: Català – Dansk – English – Español – Esperanto – Hrvatski – Indonesia – Italiano – Lietuviškai – Magyar – Nederlands – Norsk Bokmål – Polski – Português – Slovenský – Česky – Ελληνικά – Български – Русский – Српски – Українська – עברית – العربية – ไทย – 日本語 – 正體中文 – 简体中文 – 한국어

External languages (all articles in these languages should be moved to the external wiki): Deutsch – Français – Română – Suomi – Svenska – Tiếng Việt – Türkçe – فارسی

The Template:Filename file contains static filesystem information. It defines how storage devices and partitions are to be mounted and integrated into the overall system. It is read by the Template:Codeline command to determine which options to use when mounting a specific device or partition.

File example

A simple Template:Filename, using kernel name descriptors: Template:File

Field definitions

The Template:Filename file contains the following fields separated by a space or tab:

<file system>	<dir>	<type>	<options>	<dump>	<pass>
  • <file system> - the partition or storage device to be mounted.
  • <dir> - the mountpoint where <file system> is mounted to.
  • <type> - the file system type of the partition or storage device to be mounted. Many different file systems are supported: Template:Codeline and Template:Codeline. The Template:Codeline type lets the mount command guess what type of file system is used. This is useful for removable devices such as cdroms and dvds.
  • <options> - the options of the filesystem to be used. Note that some options are filesystem specific. Some of the most common options are:
  • <dump> - used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the <dump> entry.
  • <pass> - used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 - all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.

Identifying filesystems

There are three ways to identify a partition or storage device in Template:Filename: by its kernel name descriptor, label or UUID. The advantage of using UUIDs or labels is that they are not dependent on the disks order. This is useful if the storage device order in the BIOS is changed, or if you switch the storage device cabling. Also, sometimes the BIOS may occasionally change the order of storage devices. Read more about this in the persistent block device naming article.

Kernel name

You can get the kernel name descriptors using Template:Codeline. The kernel names are listed in the first row:


See the file example.


In order to use labels, the devices or partitions must have unambiguous labels. Labels should be unambiguous to prevent any possible conflicts - each label should be unique. To label a device or partition, see this article. To list all devices and partitions with their labels, you can use the command Template:Codeline. In Template:Filename you prefix the device label with Template:Codeline :



All partitions and devices have a unique UUID. They are generated by the make-filesystem utilities (Template:Codeline) when you create the filesystem. To list all devices and partitions with their UUID, you can also use Template:Codeline. In Template:Filename you prefix the device UUID with Template:Codeline :


Tips and tricks


In case your swap partition doesn't have an UUID, you can add it manually. This happens when the UUID of the swap is not shown with the Template:Codeline command. Here are some steps to assign a UUID to your swap:

Identify the swap partition:

# swapon -s

Disable the swap:

# swapoff /dev/sda7

Recreate the swap with a new UUID assigned to it:

# mkswap -U random /dev/sda7

Activate the swap:

# swapon /dev/sda7

Filepath spaces

You can use the escape character "\" followed by the 3 digit octal code "040" to emulate spaces in a path:


External devices

External devices that are to be mounted when present but ignored if absent may require the Template:Codeline option. This prevents errors being reported at boot. Template:File

atime options

The use of Template:Codeline, Template:Codeline or Template:Codeline can help disk performance for ext2, ext3, and ext4 filesystems. Linux by default keeps a record (writes to the disk) every times it reads from the disk Template:Codeline. This was more purposeful when Linux was being used for servers; it doesn't have much value for desktop use. The worst thing about the default Template:Codeline option is that even reading a file from the page cache (reading from memory instead of the disk) will still result in a disk write! Using the Template:Codeline option fully disables writing file access times to the disk every time you read a file. This works well for almost all applications, except for a rare few like Mutt that need the such information. For mutt, you should only use the Template:Codeline option. Using the Template:Codeline option enables the writing of file access times only when the file is being modified (unlike Template:Codeline where the file access time will never be changed and will be older than the modification time). The Template:Codeline option disables the writing of file access times only for directories while other files still get access times written. The best compromise might be the use of Template:Codeline in which case programs like Mutt will continue to work, but you'll still have a performance boost because files will not get access times updated unless they are modified.

Note: Template:Codeline already includes Template:Codeline. You don't need to specify both options.


tmpfs is a temporary filesystem that resides in memory and/or your swap partition(s), depending on how much you fill it up. Mounting directories as tmpfs can be an effective way of speeding up accesses to their files, or to ensure that their contents are automatically cleared upon reboot.

Some directories where tmpfs is commonly used are /tmp, /var/lock and /var/run. Do NOT use it on /var/tmp, because that folder is meant for temporary files that are preserved across reboots.

By default, a tmpfs partition has its maximum size set to half your total RAM, but this can be customized. Note that the actual memory/swap consumption depends on how much you fill it up, as tmpfs partitions don't consume any memory until it is actually needed.

To use tmpfs for Template:Filename, add this line to Template:Filename: Template:File

You may or may not want to specify the size here, but you should leave the Template:Codeline option alone in these cases to ensure that they have the correct permissions. In the example above, Template:Filename will be set to use up to half of your total RAM. To explicitly set a maximum size, use the Template:Codeline mount option: Template:File

See the mount command man page for more information.

Reboot for the changes to take effect. Note that although it may be tempting to simply run Template:Codeline to make the changes effective immediately, this will make any files currently residing in these directories inaccessible (this is especially problematic for running programs with lockfiles, for example). However, if all of them are empty, it should be safe to run Template:Codeline instead of rebooting (or mount them individually).

After applying changes, you may want to verify that they took effect with Template:Codeline: Template:Command

To use tmpfs for Template:Filename and Template:Filename, you can simply symlink them to Template:Filename. Make sure to close anything important before doing this, because you will have to reboot, and daemons may not stop cleanly.


Note: Arch will likely do this by default in the future. See https://bugs.archlinux.org/task/18157
Warning: Some daemons still have files and/or directories installed into Template:Filename and Template:Filename, and the Template:Filename scripts may need to be edited for them to work.


Other resources