17.6 SSD Configuration Recommendations for btrfs, ext4, and swap

When partitioning an SSD, align primary and logical partitions on one-megabyte (1048576 bytes) boundaries. If partitions, file system blocks, or RAID stripes are incorrectly aligned and overlap the boundaries of the underlying storage's pages, which are usually either 4 KB or 8 KB in size, the device controller has to modify twice as many pages than if correct alignment is used.

For btrfs and ext4 file systems, specifying the discard option with mount sends discard (TRIM) commands to an underlying SSD whenever blocks are freed. This option can extend the working life of the device but it has a negative impact on performance, even for SSDs that support queued discards. The recommended alternative is to use the fstrim command to discard empty blocks that the file system is not using, especially before reinstalling the operating system or before creating a new file system on an SSD. Schedule fstrim to run when it will have minimal impact on system performance. You can also apply fstrim to a specific range of blocks rather than the whole file system.


Using a minimal journal size of 1024 file-system blocks for ext4 on an SSD improves performance. However, it is not recommended that you disable journalling altogether as it improves the robustness of the file system.

Btrfs automatically enables SSD optimization for a device if the value of /sys/block/device/queue/rotational is 0. If btrfs does not detect a device as being an SSD, you can enable SSD optimization by specifying the ssd option to mount.


By default, btrfs enables SSD optimization for Xen Virtual Devices (XVD) because the value of rotational for these devices is 0. To disable SSD optimization, specify the nossd option to mount.

Setting the ssd option does not imply that discard is also set.

If you configure swap files or partitions on an SSD, reduce the tendency of the kernel to perform anticipatory writes to swap, which is controlled by the value of the vm.swappiness kernel parameter and displayed as /proc/sys/vm/swappiness. The value of vm.swappiness can be in the range 0 to 100, where a higher value implies a greater propensity to write to swap. The default value is 60. The suggested value when swap has been configured on SSD is 1. You can use the following commands to change the value:

# echo "vm.swappiness = 1" >> /etc/sysctl.conf
# sysctl -p
vm.swappiness = 1