Linux command
crypttab 命令
文本
复制后可按需替换文件名、目录或参数。
常用示例
View current crypttab
cat /etc/crypttab
Basic encrypted partition entry
luks_root UUID=[device-uuid] none luks
Entry with keyfile
luks_data UUID=[device-uuid] /root/keyfile luks
Entry with discard/TRIM support
luks_ssd UUID=[device-uuid] none luks,discard
Entry for swap encryption
cryptswap /dev/sdX /dev/urandom swap,cipher=aes-xts-plain64,size=256
说明
/etc/crypttab defines encrypted block devices to be unlocked at boot by systemd-cryptsetup or cryptsetup. Each line describes one encrypted device: its mapped name, source device, key material, and options. The file works alongside /etc/fstab: crypttab unlocks encrypted devices, then fstab mounts the resulting mapped devices. For LUKS devices, the system prompts for a password at boot unless a keyfile is specified. UUID-based device identification is recommended over device paths for reliability across hardware changes.
FAQ
What is the crypttab command used for?
/etc/crypttab defines encrypted block devices to be unlocked at boot by systemd-cryptsetup or cryptsetup. Each line describes one encrypted device: its mapped name, source device, key material, and options. The file works alongside /etc/fstab: crypttab unlocks encrypted devices, then fstab mounts the resulting mapped devices. For LUKS devices, the system prompts for a password at boot unless a keyfile is specified. UUID-based device identification is recommended over device paths for reliability across hardware changes.
How do I run a basic crypttab example?
Run `cat /etc/crypttab` in a terminal, then adjust file names, paths, flags, or remote targets for your system.
Where can I find more crypttab examples?
This page includes 5 examples for crypttab, plus related commands for nearby Linux tasks.