De acordo com as Leis 12.965/2014 e 13.709/2018, que regulam o uso da Internet e o tratamento de dados pessoais no Brasil, ao me inscrever na newsletter do portal DICAS-L, autorizo o envio de notificações por e-mail ou outros meios e declaro estar ciente e concordar com seus Termos de Uso e Política de Privacidade.
Colaboração: Dorian Bolivar
Data de Publicação: 30 de janeiro de 2012
Pesquisando como verificar se o Linux estava corretamente enviando o comando TRIM a um HD SSD, me deparei com o seguinte website:
https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking
Decidi, então, criar um pequeno shell script para automatizar a tarefa, permitindo que o teste seja executado facilmente sempre que necessário.
Idealmente, rode o script bootando o Linux em modo single-user, para minimizar a chance de outros processos sobrescreverem os setores sendo testados.
Se você não sabe como habilitar o TRIM no Linux, confira esta página do mesmo autor:
https://sites.google.com/site/lightrush/random-1/howtoconfigureext4toenabletrimforssdsonubuntu
Essa configuração é válida para EXT4. Outras otimizações também são importantes, como a flag "noatime". Google it!
O script é auto-explicativo e um texto de ajuda é exibido quando executado sem argumentos. Decidi escrevê-lo em inglês visando a colaboração global. Sinta-se livre para alterá-lo para suas necessidades!
#!/bin/bash
#
# Test if TRIM is working on your SSD. Tested only with EXT4 filesystems
# in Ubuntu 11.10 and Fedora 16. This script is simply an automation of
# the procedures described by Nicolay Doytchev here:
#
# https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking
#
# Author: Dorian Bolivar < dbolivar@gmail.com>
# Date: 20120129
#
if [ $# -ne 3 ]; then
echo
echo "Usage: $0 < filename> < size> < device>"
echo
echo "< filename> is a temporary file for the test"
echo "< size> is the file size in MB"
echo "< device> is the device being tested, e.g. /dev/sda"
echo
echo "Example: $0 tempfile 5 /dev/sda"
echo
echo "This would run the test for /dev/sda creating a"
echo "temporary file named \"tempfile\" with 5 MB"
echo
exit 1
fi
FILE="$1"
SIZE=$2
DEVICE="$3"
# Create the temporary file
dd if=/dev/urandom of="$FILE" count=1 bs=${SIZE}M oflag=direct
sync
# Get the address of the first sector
hdparm --fibmap "$FILE"
SECTOR=`hdparm --fibmap "$FILE" | tail -n1 | awk '{ print $2; }'`
# Read the first sector prior to deletion
hdparm --read-sector $SECTOR "$DEVICE"
echo
echo "This is a sector of the file. It should have been successfully read"
echo "and show a bunch of random data."
echo
read -n 1 -p "Press any key to continue..."
# Delete the file and re-read the sector
rm -f $FILE
sync
echo
echo "File deleted. Sleeping for 120 seconds before re-reading the sector."
echo "If TRIM is working, you should see all 0s now."
sleep 120
hdparm --read-sector $SECTOR "$DEVICE"
echo
echo "If the sector isn't filled with 0s, something is wrong with your"
echo "configuration. Try googling for \"TRIM SSD Linux\"."
echo
exit 0
Fonte: Notícias Linux
Para quem não conhece, o Lubuntu é um variante do Ubuntu que utiliza o ambiente de área de trabalho The Lightweight X11 Desktop Environment, também conhecido como LXDE. Conheça as novidades previstas para nova versão em http://www.ubuntubrsc.com/novidades-previstas-para-proxima-versao-lubuntu-12-04.html
Postada por: Tiago Hillebrandt, tiagohillebrandt|arroba|ubuntu.com