add encrypted btrfs on ssd nvme tips

This commit is contained in:
Maciej Lebiest 2023-12-08 21:53:03 +01:00
parent 8fa9bc4549
commit 623ccd1671

View file

@ -126,3 +126,58 @@ Make the changes to `/usr` persist reboots
```bash ```bash
rpm-ostree usroverlay --hotfix rpm-ostree usroverlay --hotfix
``` ```
## encrypted BTRFS on ssd-like disk maintenance/health
It is **very** important for performance to have trimming working. To test it
run the below to trim all mounted filesystems (can take long time, like over
10,20 minutes) (if root disk is not trimmed, it have discard not enabled at
some level):
```bash
fstrim -av
```
If trimming is not working, check the below:
- `/etc/crypttab` if it have discard set for root
- `discard=async`, `discard=sync`, or `discard` flags set in `/etc/fstab`
- `lsblk -o +DISC-GRAN,DISC-MAX` - the additional columns should have non-zero values
- `cryptsetup luksDump /dev/nvme0n1p3` - if flag `allow-discards` is set
(optional but best way to make cryptsetup allow discards by default)
Setting performance improving flags on luks volume:
```bash
cryptsetup refresh \
--allow-discards \
--perf-no_read_workqueue \
--perf-no_write_workqueue \
--persistent \
/dev/mapper/<disk>
```
Arch wiki about workqueues: https://wiki.archlinux.org/title/Dm-crypt/Specialties#Disable_workqueue_for_increased_solid_state_drive_(SSD)_performance
Recommended flags for btrfs volume mounting (compression flag optional, I guess):
```
noatime,space_cache=v2,discard=async,compress-force=zstd:1
```
If for some reason `space_cache` is not set properly on volume mount, do this
, (fs need to be unmounted):
- clear any v1 and v2 space_cache
- mount with space_cache=v2 flag
- check if flag is set correctly (maybe also create some file there?)
```bash
btrfs check --clear-space-cache v1 /dev/mapper/<device>
btrfs check --clear-space-cache v2 /dev/mapper/<device>
mount -o space_cache=v2 /dev/mapper/<device> /mnt
mount | grep space_cache
echo "hello" > /mnt/some/path/file.txt
umount /mnt
```