HOWTO: Check If TRIM On Ext4 Is Enabled And Working On Ubuntu And Other Distributions
Trim with LVM and dm-crypt
Тестирование TRIM из SSD
Включение TRIM на SSD
$ sudo -i
# dd if=/dev/urandom of=tempfilez count=100 bs=512k oflag=direct
100+0 записей получено
100+0 записей отправлено
52428800 байт (52 MB, 50 MiB) скопирован, 0,485889 s, 108 MB/s
# sync
# hdparm --fibmap tempfilez
# hdparm --read-sector 44194816 /dev/sda
# rm tempfilez
# sync
$ wget -O /tmp/test_trim.sh "https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking/test_trim.sh?attredirects=0&d=1"
$ sudo nano /tmp/test_trim.sh
#!/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
$ chmod +x /tmp/test_trim.sh
Trim with LVM and dm-crypt
Тестирование TRIM из SSD
Включение TRIM на SSD
$ sudo -i
# dd if=/dev/urandom of=tempfilez count=100 bs=512k oflag=direct
100+0 записей получено
100+0 записей отправлено
52428800 байт (52 MB, 50 MiB) скопирован, 0,485889 s, 108 MB/s
# sync
# hdparm --fibmap tempfilez
# hdparm --read-sector 44194816 /dev/sda
# rm tempfilez
# sync
$ wget -O /tmp/test_trim.sh "https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking/test_trim.sh?attredirects=0&d=1"
$ sudo nano /tmp/test_trim.sh
#!/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
$ chmod +x /tmp/test_trim.sh
Комментариев нет:
Отправить комментарий