Advertisement
Guest User

test trim ssd linux

a guest
Nov 28th, 2018
499
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.71 KB | None | 0 0
  1. #!/bin/bash
  2. #
  3. # Test if TRIM is working on your SSD. Tested only with EXT4 filesystems
  4. # in Ubuntu 11.10 and Fedora 16. This script is simply an automation of
  5. # the procedures described by Nicolay Doytchev here:
  6. #
  7. # https://sites.google.com/site/lightrush/random-1/checkiftrimonext4isenabledandworking
  8. #
  9. # Author: Dorian Bolivar <dbolivar@gmail.com>
  10. # Date: 20120129
  11. #
  12.  
  13. if [ $# -ne 3 ]; then
  14.         echo
  15.         echo "Usage: $0 <filename> <size> <device>"
  16.         echo
  17.         echo "<filename> is a temporary file for the test"
  18.         echo "<size> is the file size in MB"
  19.         echo "<device> is the device being tested, e.g. /dev/sda"
  20.         echo
  21.         echo "Example: $0 tempfile 5 /dev/sda"
  22.         echo
  23.         echo "This would run the test for /dev/sda creating a"
  24. SECTOR=`hdparm --fibmap "$FILE" | tail -n1 | awk '{ print $2; }'`
  25.  
  26. # Read the first sector prior to deletion
  27. hdparm --read-sector $SECTOR "$DEVICE"
  28. echo
  29. echo "This is a sector of the file. It should have been successfully read"
  30. echo "and show a bunch of random data."
  31. echo
  32. read -n 1 -p "Press any key to continue..."
  33.  
  34. # Delete the file and re-read the sector
  35. rm -f $FILE
  36. sync
  37. echo
  38. echo "File deleted. Sleeping for 120 seconds before re-reading the sector."
  39. echo "If TRIM is working, you should see all 0s now."
  40. sleep 120
  41. hdparm --read-sector $SECTOR "$DEVICE"
  42. echo
  43. echo "If the sector isn't filled with 0s, something is wrong with your"
  44. echo "configuration. Try googling for \"TRIM SSD Linux\"."
  45. echo
  46.  
  47. exit 0
  48. ~
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement