/etc/fstab

From Gentoo Wiki
< /etc
Jump to:navigation Jump to:search
This page is a translated version of the page /etc/fstab and the translation is 57% complete.
Outdated translations are marked like this.
Resources

fstabfile system table ) 文件(/etc/fstab) 是定义主要的文件系统在哪里以及如何挂载它们(特别是在启动时)的配置文件。

/etc/fstab 每一行包含了挂载到分区、驱动器或网络共享的必要设置。 每行有六列,并且使用空格或制表符(TAB)分割。每列内容如下:

  1. The device file, UUID or label or other means of locating the partition or data source.
  2. The mount point, where the data is to be attached to the filesystem.
  3. The filesystem type. See man 5 fstab for more supported file system types.
  4. Options, including if the filesystem should be mounted at boot.
  5. Adjusts the archiving schedule for the partition (used by app-arch/dump package). 0 disables, 1 enables the feature.
  6. Controls the order in which fsck checks the device/partition for errors at boot time. The root device should be 1. Other partitions should be either 2 (to check after root) or 0 (to disable checking for that partition altogether).

root 设备的示例:

文件 /etc/fstab
/dev/sda1   /   ext4   defaults   0   1

Special characters can be escaped by using their octal representation from an ASCII table. For example, if the name of the mount point contains spaces or tabs these can be escaped as \040 and \011 respectively.

更多详细信息请查看 man 5 fstab.

提示
Options such as discard may seem useful for SSDs, though it is generally recommended to use periodic trim jobs instead.

UUID 和卷标

在第一列,可以使用 UUID 替代设备文件:

文件 /etc/fstab对根分区使用 UUID
UUID=339df6e7-91a8-4cf9-a43f-7f7b3db533c6   /   ext4   defaults   0   1

另外,也可以使用 LABEL:

文件 /etc/fstab对根分区使用卷标
LABEL=Gentoo   /   ext4   defaults   0   1

根据分区表不同(例如,全局唯一标识分区表 GUID Partition Table "GPT"),可以使用 PARTLABEL:

文件 /etc/fstab对根分区使用卷标
PARTLABEL=Gentoo   /   ext4   defaults   0   1

Please read this for details on how to retrieve UUIDs and labels.

服务

下列 OpenRC 服务读取 fstab 来挂载或管理文件系统:

  • localmount —— 根据 fstab 挂载磁盘和交换分区。
  • netmount —— 根据 fstab 挂载网络共享。
  • fsck —— 根据 fstab 挂载检查和修复文件系统。
  • root —— 挂载根文件系统读写。

These services supplement the fstab, if the filesystems are not explicitly stated:

  • sysfs —— 挂载 /sys 文件系统。
  • devfs —— 挂载 /dev 内关键文件系统。

确认已经启用开机时启动它们:

root #rc-update show

另请参阅

外部资源