Wireless Army
This is a blog / tips and tricks website for web developers and security researchers.
follow us in feedly


enable triming on SSD
by admin
 at 2017-05-03 23:17:00.

Enabling TRIM support on dm-crypt

edit your fstab file (either /etc/fstab or /etc/crpttab) and add the discard option

# <target name>    <source device>    <key file>       <options>
sda2_crypt         /dev/sda2          none             luks,discard

Note: The usage of TRIM on dm-crypt could cause some security issues like the revelation of which sectors of your disk are unused.

Enabling TRIM support on LVM

edit etc/lvm/lvm.conf  and change issue_discards  to 1

Enabling TRIM support on the file system

make an executable bash file 

#! /bin/sh
for mount in / /boot /home; do
	fstrim $mount
done

rebuild your initramfs

run update-initramfs -u to rebuild your initramfs (or dracut -f) This script can be used to automatically detect and fstrim all filesystems that have TRIM support enabled.

#!/bin/sh
for fs in $(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print $1}'); do
	fstrim "$fs"
done