fstab

From ArchWiki
Revision as of 10:31, 22 June 2011 by Maveloth (talk | contribs) (fixed templates and added some other to uniform the page layout)
Jump to: navigation, search

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 initialized and integrated into the overall system.

Example

Here is an example Template:Filename using kernel naming (/dev/sdx) descriptors: Template:File

Here is another example using more mount options and the Template:Codeline method of identifying mountable devices. Template:File

Field definitions

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

<file system>	<dir>	<type>	<options>	<dump>	<pass>
  • <file systems> - defines the storage device (i.e. Template:Filename).
  • <dir> - tells the mount command where it should mount the <file system> to.
  • <type> - defines the file system type of the device or partition to be mounted. Many different file systems are supported. Some examples are: ext2, ext3, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap, and auto. The 'auto' type lets the mount command to attempt to guess what type of file system is used, this is useful for removable devices such as cdroms and dvds.
  • <options> - define particular options for filesystems. Some options relate only to the filesystem itself. Some of the more common options are:
  • auto - File system will mount automatically at boot, or when the command 'mount -a' is issued.
  • noauto - The filesystem is mounted only when you tell it to.
  • exec - Allow the execution binaries that are on that partition (default).
  • noexec - Do not allow binaries to be executed on the filesystem.
  • ro - Mount the filesystem read only
  • rw - Mount the filesystem read-write
  • sync - I/O should be done synchronously
  • async - I/O should be done asynchronously
  • flush - specific option for FAT to flush data more often, thus making copy dialogs or progress bars to stays up until things are on the disk
  • user - Permit any user to mount the filesystem (implies noexec,nosuid,nodev unless overridden.)
  • nouser - Only allow root to mount the filesystem. (default)
  • defaults - Default mount settings (equivalent to rw,suid,dev,exec,auto,nouser,async).
  • suid - Allow the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.
  • nosuid - Block the operation of suid, and sgid bits.
  • noatime - Do not update inode access times on the filesystem. Can help performance (see atime options).
  • nodiratime - Do not update directory inode access times on the filesystem. Can help performance (see atime options).
  • relatime - Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.) Can help performance (see atime options).
  • <dump> - Is used by the dump utility to decide when to make a backup. When installed (not installed by a standard installation of Arch Linux), 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> fsck reads the <pass> number and determines in which order the file systems should 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 get a 2. File systems with a <pass> value 0 will not be checked by the fsck utility.

Defining filesystems

You can define the filesystems in the Template:Filename configuration in three different ways: by kernel naming descriptors, by UUID, or by labels. The advantage of using UUIDs or labels is that they are not dependent on disk order. This is useful if you change your storage device order in the BIOS, you switch storage device cabling, or because some BIOS's may occasionally change the order of storage devices.

Kernel naming

You can get kernel naming descriptors using Template:Codeline:

Template:Cli

UUIDs

UUIDs are generated by the make-filesystem utilities (Template:Codeline) when you create a filesystem. Template:Codeline will show you the UUIDs of mounted devices and partitions:

Template:Cli

An example Template:Filename using the UUID identifiers:

Template:File

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.

First, if we don't know which is the swap partition, we have to find it with the command:

Template:Cli

Then disable the swap:

Template:Cli

Now, recreate the swap with a new UUID assigned to it:

Template:Cli

Finally, activate the swap:

Template:Cli

Labels

The device or partition is required to be labeled first. To do this, you can use common applications like Template:Package Official to label partitions or you can use Template:Codeline to label ext2, ext3, and ext4 partitions. Keep in mind that not all file system have labeling support (e.g. FAT file systems).

A device or partition must not be mounted before attempting to label them. Initially you will need to boot from a Live(CD/DVD/USB) before you can label with a Template:Package Official-like application or for ext partitions you can use Template:Codeline.

Template:Cli

Labels can be up to 16 characters long. Technically labeling can have spaces too, however there is no way to have your Template:Filename or GRUB configuration file (for that matter) be able to recognize them by that label if you do.

Labels should be unambiguous, meaning that each label should be original to prevent any possible conflicts. To enter labels into your Template:Filename, here is an example:

Template:File

Tips

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

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:Codeline in this case): Template:Cli

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.

Template:Cli

Dealing with paths that contain spaces

You can use the escape character followed by the 3 digit octal code for space "\040".

Template:File

External drives

External drives 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

Related

Resources