recfstab
Generate fstab entries from mounted filesystems. Like genfstab for Arch Linux.
Overview
recfstab reads mounted filesystems under a root directory and outputs properly formatted fstab entries to stdout. This is the equivalent of Arch Linux's genfstab command.
The output is suitable for appending to /etc/fstab. Pseudo-filesystems (proc, sysfs, tmpfs) are automatically filtered out.
Usage
recfstab [OPTIONS] <ROOT>| Argument | Description |
|---|---|
ROOT | Root directory to scan for mounted filesystems (e.g., /mnt) |
Options
| Option | Description |
|---|---|
-L, --label | Use filesystem LABEL instead of UUID |
-p, --partuuid | Use partition UUID (PARTUUID) instead of filesystem UUID |
-t, --partlabel | Use partition LABEL (PARTLABEL) instead of filesystem UUID |
--version | Show version |
--help | Show help |
The identifier options (-L, -p, -t) are mutually exclusive. Default is UUID.
Examples
recfstab /mnt >> /mnt/etc/fstab recfstab -L /mnt >> /mnt/etc/fstab recfstab -p /mnt >> /mnt/etc/fstab recfstab /mnt Output Format
Each mount produces a commented device path followed by the fstab entry:
# /dev/nvme0n1p2
UUID=a1b2c3d4-e5f6-7890-abcd-ef1234567890 / ext4 rw,relatime 0 1
# /dev/nvme0n1p1
UUID=ABCD-1234 /boot vfat rw,relatime,fmask=0022,dmask=0022 0 2Fields: device identifier, mount point, filesystem type, options, dump, pass
Identifier Types
| Type | Flag | Example | Use Case |
|---|---|---|---|
| UUID | (default) | UUID=a1b2c3d4-... | Most reliable for single-disk systems |
| LABEL | -L | LABEL=root | Human-readable if you label filesystems |
| PARTUUID | -p | PARTUUID=12345678-01 | GPT partition UUID, survives reformatting |
| PARTLABEL | -t | PARTLABEL=EFI | GPT partition label if set during partitioning |
Filtered Options
Runtime-only mount options are automatically removed from the output since they should not persist in fstab:
rw/ro- Read-write/read-only (determined at mount time)seclabel- SELinux label optionnoatime,relatime- Access time options are preserved
Pseudo-Filesystems
These filesystem types are automatically excluded:
proc sysfs devtmpfs tmpfs devpts securityfs cgroup cgroup2
pstore bpf tracefs debugfs hugetlbfs mqueue fusectl configfs
efivarfs autofs fuse.gvfsd-fuse overlay squashfs erofsSwap Handling
Swap partitions and files under the root are included automatically:
- Swap partitions - Detected from
/proc/swaps, included with priority if set - Swap files - Detected and path adjusted relative to root
- zram - Excluded (runtime-only compressed RAM swap)
Error Codes
| Code | Description |
|---|---|
| E001 | Root directory does not exist |
| E002 | Path is not a directory |
| E003 | Failed to determine current directory |
| E004 | findmnt command not found (util-linux not installed) |
| E005 | findmnt command failed |
| E006 | No filesystems found under specified root |
| E007 | blkid command not found (util-linux not installed) |
Requirements
findmnt- Part of util-linux, used to enumerate mountsblkid- Part of util-linux, used to look up device identifiers- Root privileges (for blkid to read device UUIDs)
Comparison with genfstab
| Feature | recfstab | genfstab |
|---|---|---|
| Identifier types | UUID, LABEL, PARTUUID, PARTLABEL | Same |
| Output to stdout | Yes | Yes |
| Pseudo-filesystem filtering | Automatic | Automatic |
| btrfs subvolumes | Supported | Supported |
| Swap detection | Automatic | Automatic |
See Also
- recstrap - Extract the base system
- recchroot - Enter chroot environment
- Installation Tools Overview - Workflow overview