Partitioning
Recommended / Best Practices
- /boot 200Mb
- swap 1.5x times the amount of RAM
- /
- /home
- /tmp
- /var
- /var/log
- /var/log/audit
- Encrypt all partitions except /boot
Creating an LVM partition
Create a Physical Partition
- Open the drive in fdisk, create a new primary partition
- Mark the new partition as type '8e' or Linux LVM
- Write the partition table
Create Physical LVM Volume
pvcreate /dev/sdc1 (assuming /dev/sdc1 was the partition just created)Volume Group Creation
The default physical extent size is 4MB. Modern LVM no longer has the 65,536 extent limit that old versions did, so the default extent size is fine for most use cases. You can still increase it if you want slightly less metadata overhead on very large volumes.
| |
Logical Volume Creation
The following creates a 1GB logical volume. To use all remaining space, use -l 100%FREE instead of -L.
Securing Partitions
- Add
nodevto all non-root local ext{2,3,4} partitions in/etc/fstab - Add
nosuidandnoexecto/tmppartition - Bind mount /tmp to /var/tmp with
rw,nodev,nosuid,noexec,bindas options - If removable storage is enabled add
nodev,nosuid,noexecto their partitions - Disable auto mounter (autofs)
- Dynamically encrypt the swap partition (not for any machine that will be hibernated)
Encrypting Additional Partitions
Modern cryptsetup defaults to strong cipher settings (aes-xts-plain64, 256-bit key, argon2id for key derivation), so explicit cipher options are rarely needed.