Linux command
genfstab 命令
文本
涉及管道、覆盖或删除,执行前请先确认路径和参数。
常用示例
Example
genfstab -U /mnt >> /mnt/etc/fstab
Example
genfstab -L [path/to/mount_point]
Example
genfstab -U [path/to/mount_point]
Example
genfstab -t [LABEL|UUID|PARTLABEL|PARTUUID]
Append
genfstab -U [path/to/mount_point] | sudo tee -a /etc/fstab
说明
genfstab generates output suitable for an /etc/fstab file by detecting mounted filesystems under a given root directory. It's primarily used during Arch Linux installation to create the fstab file for a new system. The tool reads mount information from /proc/self/mountinfo and outputs proper fstab entries with the appropriate source identifiers (UUID, LABEL, etc.), mount points adjusted relative to the specified root, filesystem types, and mount options. Using UUIDs (-U) is recommended as they remain stable across hardware changes, unlike device names like /dev/sda1 which can change.
参数
- -U
- Use UUIDs for source identifiers
- -L
- Use filesystem labels for source identifiers
- -t _TAG_
- Use specified tag: LABEL, UUID, PARTLABEL, or PARTUUID
- -f _FILTER_
- Restrict output to mountpoints matching the given prefix filter.
- -p
- Exclude pseudofs mounts (default behavior).
- -P
- Include pseudofs mounts.
- -h
- Display usage and options.
FAQ
What is the genfstab command used for?
genfstab generates output suitable for an /etc/fstab file by detecting mounted filesystems under a given root directory. It's primarily used during Arch Linux installation to create the fstab file for a new system. The tool reads mount information from /proc/self/mountinfo and outputs proper fstab entries with the appropriate source identifiers (UUID, LABEL, etc.), mount points adjusted relative to the specified root, filesystem types, and mount options. Using UUIDs (-U) is recommended as they remain stable across hardware changes, unlike device names like /dev/sda1 which can change.
How do I run a basic genfstab example?
Run `genfstab -U /mnt >> /mnt/etc/fstab` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
What does -U do in genfstab?
Use UUIDs for source identifiers