Optimizando seu SSD no Linux

Kingston-SSDNow-KC100

Existe muita documentação sobre o uso de HDs SSD no LINUX. Algumas são antigas e outras pouco detalhadas.
Bem pesquisei várias documentações em diversos sites e baseado nas que achei mais interessantes criei um script para ser usado no Debian. Este script foi testado no Debian 8 Jessie mas imagino que possa funcionar bem no Wheezy e também no Ubuntu e Linux Mint devido a semelhança destes sistemas.

#!/bin/bash
# edmarcos antonio de souza
# contato arroba edeg.com.br
# 20150704
# http://stackoverflow.com/questions/18596778/difference-between-using-chmod-ax-and-chmod-755
# http://unix.stackexchange.com/questions/37313/how-do-i-grep-for-multiple-patterns
# http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/
# https://en.opensuse.org/SDB:SSD_performance
# https://wiki.freeswitch.org/wiki/SSD_Tuning_for_Linux
# https://wiki.archlinux.org/index.php/Solid_State_Drives

# fstrim -------------------------------
test -x /etc/cron.weekly/dofstrim || {
echo "#!/bin/sh
#
# To find which FS support trim, we check that DISC-MAX (discard max bytes)
# is great than zero. Check discard_max_bytes documentation at
# https://www.kernel.org/doc/Documentation/block/queue-sysfs.txt
#
# http://blog.neutrino.es/2013/howto-properly-activate-trim-for-your-ssd-on-linux-fstrim-lvm-and-dmcrypt/

for fs in \$(lsblk -o MOUNTPOINT,DISC-MAX,FSTYPE | grep -E '^/.* [1-9]+.* ' | awk '{print \$1}'); 
	do
	fstrim -v \"\$fs\"
	done" > /etc/cron.weekly/dofstrim

chmod a+x /etc/cron.weekly/dofstrim
}

# swappiness ---------------------------
echo "# https://en.opensuse.org/SDB:SSD_performance

vm.swappiness=1
vm.vfs_cache_pressure=50" > /etc/sysctl.d/30-ssd.conf 

# scheduler ----------------------------
# https://wiki.archlinux.org/index.php/Solid_State_Drives

test -f /etc/udev/rules.d/60-scheduler.rules || {
echo "# set deadline scheduler for non-rotating disks
ACTION==\"add|change\", KERNEL==\"sd[a-z]\", ATTR{queue/rotational}==\"0\", ATTR{queue/scheduler}=\"deadline\"

# set cfq scheduler for rotating disks
ACTION==\"add|change\", KERNEL==\"sd[a-z]\", ATTR{queue/rotational}==\"1\", ATTR{queue/scheduler}=\"cfq\"" > /etc/udev/rules.d/60-scheduler.rules

}

# fstab --------------------------------

FSTAB=/etc/fstab
IFS_CURRENT=$IFS
IFS=$(echo -en "\n\b")

# noatime
for i in `cat $FSTAB | grep -w "ext[3-4]" | grep -v "noatime"`
	do
	OPTIONS=$(echo $i | awk {'print $4'})
	LINE=$(echo $i | sed s/$OPTIONS/$OPTIONS,noatime/g)
	sed -i "s|$i|$LINE|" $FSTAB
	done

# commit=600
for i in `cat $FSTAB | grep -w "ext[3-4]" | grep -v "commit=600"`
	do
	OPTIONS=$(echo $i | awk {'print $4'})
	LINE=$(echo $i | sed s/$OPTIONS/$OPTIONS,commit=600/g)
	sed -i "s|$i|$LINE|" $FSTAB
	done

IFS=$IFS_CURRENT

Abaixo o link para o script.
Faça o download do mesmo renomeie a extensão .txt para .sh , de permissão de execução para o mesmo e execute.
task-ssd