SSD Tweaks for Linux

Add fstab option [discard, relatime] + tmpfs
# fstab
cat /etc/fstab

/dev/sda1	/  		ext4    rw,noatime,nodiratime,discard,delalloc,nobarrier,nobh,data=writeback	0 1
tmpfs		/tmp 		tmpfs	rw,nosuid				0 0
tmpfs		/run/lock 	tmpfs	rw,nosuid				0 0
tmpfs /home/alek/.ramdisk tmpfs rw,noatime,nodiratime,nodev,nosuid,uid=1000,gid=1000,mode=0700,size=2000M	0 0

# update initramfs
sudo update-initramfs -u -k all

Low-Latency IO-Scheduler
# check that kernel knows about your ssd
grep . /sys/block/sd?/queue/rotational
/sys/block/sda/queue/rotational is 1
/sys/block/sdb/queue/rotational is 1
/sys/block/sdc/queue/rotational is 0   <=== Only this is SSD!

# switch manually
echo deadline > /sys/block/sda/queue/scheduler

# udev permanent
cat /sys/block/sda/queue/scheduler
touch /etc/udev/rules.d/60-schedulers.rules
ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="deadline"

# check
grep . /sys/block/sd?/queue/scheduler

Trim service
sudo cp /usr/share/doc/util-linux/examples/fstrim.{service,timer} /etc/systemd/system
sudo systemctl daemon-reload
sudo systemctl enable fstrim.timer
sudo systemctl start fstrim.timer
Sysctl tweaks
cat /etc/sysctl.conf

vm.laptop_mode=5
vm.dirty_writeback_centisecs = 15000

vm.swappiness=1
vm.vfs_cache_pressure=1000