Difference between revisions of "Fstab"

Marked this version for translation
m (added languages and translate tags)
(Marked this version for translation)
Line 2: Line 2:
__TOC__
__TOC__
<translate>
<translate>
= fstab usage =
= fstab usage = <!--T:1-->
The {{ic|/etc/fstab}} root-owned configuration file is used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.
The {{ic|/etc/fstab}} root-owned configuration file is used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.


<!--T:2-->
Each filesystem is described in a separate line. These definitions will be converted into systemd mount units dynamically at boot, or when the configuration of the system manager is reloaded.
Each filesystem is described in a separate line. These definitions will be converted into systemd mount units dynamically at boot, or when the configuration of the system manager is reloaded.


<!--T:3-->
The {{ic|mount --all}} command will mount all filesystems mentioned in {{ic|fstab}}, (except for those whose line contains the {{ic|noauto}} keyword). The filesystems are mounted following their order in {{ic|fstab}}. The mount command compares filesystem source and target to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during {{ic|mount --all}}. This means that all duplicated fstab entries will be mounted.
The {{ic|mount --all}} command will mount all filesystems mentioned in {{ic|fstab}}, (except for those whose line contains the {{ic|noauto}} keyword). The filesystems are mounted following their order in {{ic|fstab}}. The mount command compares filesystem source and target to detect already mounted filesystems. The kernel table with already mounted filesystems is cached during {{ic|mount --all}}. This means that all duplicated fstab entries will be mounted.


= Example File =
= Example File = <!--T:4-->
Each line in the file describes a filesystem, and contain fields (specified in columns) used to provide information about its mountpoint, the options which should be used when mounting it etc. Each field can be separated from one another either by spaces or tabs:
Each line in the file describes a filesystem, and contain fields (specified in columns) used to provide information about its mountpoint, the options which should be used when mounting it etc. Each field can be separated from one another either by spaces or tabs:
  # /etc/fstab: static file system information.
  # /etc/fstab: static file system information.
Line 20: Line 22:
  UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2
  UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2


<!--T:5-->
Each column in the above are the fstab "fields" and will be explained in the next section.
Each column in the above are the fstab "fields" and will be explained in the next section.


= Field definitions =
= Field definitions = <!--T:6-->
== Filesystem Specification ==
== Filesystem Specification ==
This field describes one of each of the following:
This field describes one of each of the following:
Line 30: Line 33:
* swap file or swap partition to be enabled
* swap file or swap partition to be enabled


<!--T:7-->
This field generally takes the form of:
This field generally takes the form of:
* /dev/XdY
* /dev/XdY
Line 37: Line 41:
As a [https://en.wikipedia.org/wiki/Universally_unique_identifier UUID] is necessarily unique, you will find that this is the default in use on more modern systems whereas a device name and label are only in use on older systems, so we'll concentrate on UUIDs in this tutorial, but know that if you insist on using these order systems, they still work at the time of this writing.
As a [https://en.wikipedia.org/wiki/Universally_unique_identifier UUID] is necessarily unique, you will find that this is the default in use on more modern systems whereas a device name and label are only in use on older systems, so we'll concentrate on UUIDs in this tutorial, but know that if you insist on using these order systems, they still work at the time of this writing.


<!--T:8-->
To get the UUID for all of your devices, execute the command  {{ic|blkid}} elevated to root:
To get the UUID for all of your devices, execute the command  {{ic|blkid}} elevated to root:


  sudo blkid
  <!--T:9-->
sudo blkid


<!--T:10-->
and you'll get someting like this:
and you'll get someting like this:


  /dev/sda1: LABEL_FATBOOT="ESP" LABEL="ESP" UUID="2462-755F" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="b86c0cae-3055-4d9e-9e12-1fa1e2cd32d2"
  <!--T:11-->
/dev/sda1: LABEL_FATBOOT="ESP" LABEL="ESP" UUID="2462-755F" BLOCK_SIZE="512" TYPE="vfat" PARTLABEL="EFI system partition" PARTUUID="b86c0cae-3055-4d9e-9e12-1fa1e2cd32d2"
  /dev/sda2: PARTLABEL="Microsoft reserved partition" PARTUUID="b0679b89-007c-441b-88a3-74a39f1f8b2b"
  /dev/sda2: PARTLABEL="Microsoft reserved partition" PARTUUID="b0679b89-007c-441b-88a3-74a39f1f8b2b"
  /dev/sda3: LABEL="WINSYS" BLOCK_SIZE="512" UUID="029873F49873E497" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="f8d444b9-ec60-4ac8-b12a-52448119fad1"
  /dev/sda3: LABEL="WINSYS" BLOCK_SIZE="512" UUID="029873F49873E497" TYPE="ntfs" PARTLABEL="Basic data partition" PARTUUID="f8d444b9-ec60-4ac8-b12a-52448119fad1"
Line 54: Line 62:
  /dev/sdc1: LABEL="Win-Data" BLOCK_SIZE="512" UUID="634E43D367B0A4B1" TYPE="ntfs" PARTUUID="ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"
  /dev/sdc1: LABEL="Win-Data" BLOCK_SIZE="512" UUID="634E43D367B0A4B1" TYPE="ntfs" PARTUUID="ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"


<!--T:12-->
Any one of the output of {{ic|blkid}} can be used as the first field in the fstab file.
Any one of the output of {{ic|blkid}} can be used as the first field in the fstab file.


<!--T:13-->
E.G. '''all''' of the following lines are valid entries ''for the first line'' of the output of the above example:
E.G. '''all''' of the following lines are valid entries ''for the first line'' of the output of the above example:
  # <file system>                          <mount point>  <type>  <options>                    <dump>  <pass>
  # <file system>                          <mount point>  <type>  <options>                    <dump>  <pass>
Line 63: Line 73:
  UUID=b86c0cae-3055-4d9e-9e12-1fa1e2cd32d2 /boot/efi      vfat    umask=0077                        0      2
  UUID=b86c0cae-3055-4d9e-9e12-1fa1e2cd32d2 /boot/efi      vfat    umask=0077                        0      2


<!--T:14-->
I.E. only one of the above lines should be present in your fstab file to mount the ESP partition, but any of them will work!
I.E. only one of the above lines should be present in your fstab file to mount the ESP partition, but any of them will work!
''However'' it is strongly recommended to use the UUID as that is '''globally unique!'''.  This means that if your move a disk to another machine, it will keep its UUID and there is no opportunity for surprises like the computer you've moved the existing disk to suddenly:
''However'' it is strongly recommended to use the UUID as that is '''globally unique!'''.  This means that if your move a disk to another machine, it will keep its UUID and there is no opportunity for surprises like the computer you've moved the existing disk to suddenly:
Line 70: Line 81:
* etc, etc.
* etc, etc.


== Mount Point ==
== Mount Point == <!--T:15-->
This field describes the mount point (target) inside your filesystem. For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces or tabs these can be escaped as `\040' and '\011' respectively.
This field describes the mount point (target) inside your filesystem. For swap partitions, this field should be specified as `none'. If the name of the mount point contains spaces or tabs these can be escaped as `\040' and '\011' respectively.


<!--T:16-->
For more information on the Linux Filesystem Hierarchy standard refer to the [[#See Also]] section, but in a nutshell you should specify an existing directory on your filesystem where you want to mount a partition.
For more information on the Linux Filesystem Hierarchy standard refer to the [[#See Also]] section, but in a nutshell you should specify an existing directory on your filesystem where you want to mount a partition.


<!--T:17-->
In the example {{ic|fstab}} file above, the following line in it's {{ic|blkid}} output:
In the example {{ic|fstab}} file above, the following line in it's {{ic|blkid}} output:
  /dev/sdc1: LABEL="Win-Data" BLOCK_SIZE="512" UUID="634E43D367B0A4B1" TYPE="ntfs" PARTUUID="ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"
  /dev/sdc1: LABEL="Win-Data" BLOCK_SIZE="512" UUID="634E43D367B0A4B1" TYPE="ntfs" PARTUUID="ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"
Line 83: Line 96:
* has a partition UUID of "ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"
* has a partition UUID of "ca8d0663-6a6e-4b09-a0d7-05b59d109ab1"


<!--T:18-->
and gets mounted on the {{ic|/media/Data}} according to this line:
and gets mounted on the {{ic|/media/Data}} according to this line:
  UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2
  UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2


== Filesystem Type ==
== Filesystem Type == <!--T:19-->
This field describes the type of the filesystem. Linux supports many filesystem types: ext4, xfs, btrfs, f2fs, vfat, ntfs-3g (for Windows compatibility), hfsplus (for Mac Compatibility), tmpfs, sysfs, proc, iso9660 (to allow you to mount CD/DVD ISO files as Read-Only directories), udf, squashfs, nfs, cifs, and many more.  
This field describes the type of the filesystem. Linux supports many filesystem types: ext4, xfs, btrfs, f2fs, vfat, ntfs-3g (for Windows compatibility), hfsplus (for Mac Compatibility), tmpfs, sysfs, proc, iso9660 (to allow you to mount CD/DVD ISO files as Read-Only directories), udf, squashfs, nfs, cifs, and many more.  


<!--T:20-->
An entry swap denotes a file or partition to be used for swapping.
An entry swap denotes a file or partition to be used for swapping.
An entry none is useful for bind or move mounts.
An entry none is useful for bind or move mounts.


<!--T:21-->
More than one type may be specified in a comma-separated list.
More than one type may be specified in a comma-separated list.


<!--T:22-->
Using the same example {{ic|fstab}} file and "Win-Data" line as above, {{ic|ntfs-3g}} is the file system we're mounting this one under although the {{ic|blkid}} shows {{ic|ntfs}}.  This is simply because the {{ic|ntfs}} driver is a read-only driver (allowing you to see your Windows files, but not modify them, whereas the {{ic|ntfs-3g}} (for 3rd generation) allows most NTFS options (except encryption) thus also read-write capabilities:
Using the same example {{ic|fstab}} file and "Win-Data" line as above, {{ic|ntfs-3g}} is the file system we're mounting this one under although the {{ic|blkid}} shows {{ic|ntfs}}.  This is simply because the {{ic|ntfs}} driver is a read-only driver (allowing you to see your Windows files, but not modify them, whereas the {{ic|ntfs-3g}} (for 3rd generation) allows most NTFS options (except encryption) thus also read-write capabilities:


  UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2
  <!--T:23-->
UUID=634E43D367B0A4B1                    /media/Data    ntfs-3g noauto,x-systemd.automount,x-systemd.device-timeout=10,rw,inherit,permissions,streams_interface=windows,windows_names,compression,norecover,hide_dot_files,hide_hid_files,big_writes 0 2


== Mount options ==
== Mount options == <!--T:24-->
This field describes the mount options associated with the filesystem.
This field describes the mount options associated with the filesystem.


<!--T:25-->
It is formatted as a comma-separated list of options. It contains at least the type of mount (ro or rw), plus any additional options appropriate to the filesystem type (including performance-tuning options).  
It is formatted as a comma-separated list of options. It contains at least the type of mount (ro or rw), plus any additional options appropriate to the filesystem type (including performance-tuning options).  


<!--T:26-->
Basic filesystem-independent options are:
Basic filesystem-independent options are:
* defaults: use default options: rw, suid, dev, exec, auto, nouser, and async.
* defaults: use default options: rw, suid, dev, exec, auto, nouser, and async.
Line 111: Line 131:
* nofail: do not report errors for this device if it does not exist.
* nofail: do not report errors for this device if it does not exist.


=== FAT Mount options ===
=== FAT Mount options === <!--T:27-->
TBD
TBD


=== EXT2/3/4 Mount options ===
=== EXT2/3/4 Mount options === <!--T:28-->
TBD
TBD


=== NTFS-3G Mount options ===
=== NTFS-3G Mount options === <!--T:29-->
TBD
TBD


== Dump? ==
== Dump? == <!--T:30-->
This field must be 1 or 0 and is used by {{ic|dump}} to determine which filesystems need to be dumped in case of a coredump (=crash). Defaults to zero (don’t dump) if not present.
This field must be 1 or 0 and is used by {{ic|dump}} to determine which filesystems need to be dumped in case of a coredump (=crash). Defaults to zero (don’t dump) if not present.


== Pass number ==
== Pass number == <!--T:31-->
This field is used by fsck(8) to determine the order in which filesystem checks are done at boot time. The root filesystem ''should be'' specified with a fs_passno of 1. Other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware.
This field is used by fsck(8) to determine the order in which filesystem checks are done at boot time. The root filesystem ''should be'' specified with a fs_passno of 1. Other filesystems should have a fs_passno of 2. Filesystems within a drive will be checked sequentially, but filesystems on different drives will be checked at the same time to utilize parallelism available in the hardware.


<!--T:32-->
Defaults to zero (don’t check the filesystem) if not present.
Defaults to zero (don’t check the filesystem) if not present.


= Tips and tricks =
= Tips and tricks = <!--T:33-->
The default setup will automatically `fsck` and `mount` filesystems before starting services that need them to be mounted. For example, systemd automatically makes sure that remote filesystem mounts like NFS or Samba are only started after the network has been set up. Therefore, local and remote filesystem mounts specified in `/etc/fstab` should work out of the box. See {{man 5 systemd.mount}} for details.
The default setup will automatically `fsck` and `mount` filesystems before starting services that need them to be mounted. For example, systemd automatically makes sure that remote filesystem mounts like NFS or Samba are only started after the network has been set up. Therefore, local and remote filesystem mounts specified in `/etc/fstab` should work out of the box. See {{man 5 systemd.mount}} for details.


=See Also=
=See Also= <!--T:34-->
https://refspecs.linuxfoundation.org/FHS_3.0/index.html
https://refspecs.linuxfoundation.org/FHS_3.0/index.html


</translate>
</translate>
[[Category:Contents Page{{#translation:}}]]
[[Category:Contents Page{{#translation:}}]]