LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Debian (http://www.linuxquestions.org/questions/debian-26/)
-   -   Enabling TRIM on ssd (http://www.linuxquestions.org/questions/debian-26/enabling-trim-on-ssd-4175426052/)

jas0n 09-06-2012 10:48 PM

Enabling TRIM on ssd
 
I just installed Squeeze on a 128 gb ssd and am trying to enable TRIM on the drive's partitions. I added the discard option in /etc/fstab and rebooted.

I had mixed verifying whether TRIM is enabled according to the directions I found in a couple guides on the subject.

Running the following indicated it is enabled:

$ sudo hdparm -I /dev/sda | grep 'TRIM'
* Data Set Management TRIM supported (limit 8 blocks)

But testing according to the following article indicates TRIM is not working:

http://techgage.com/article/enabling..._under_linux/2

To summarize, I created a test file; checked to see if data was present at the sector where the file started; deleted the file; and checked to see if the sector was zeroed out.

Is there a better, definitive way of checking whether this is working?

qrange 09-07-2012 01:22 AM

I think that is a bad test because physical sectors/blocks are much larger than logical. and TRIM probably works with physical ones.
some ssd drives (controlers) don't support TRIM, or you need to update controler firmware.
SandForce version 5.x for eg. has problems with TRIM.

TobiSGD 09-07-2012 04:00 AM

We need more information:
Which file-system are you using? For TRIM support you need to use ext4 or btrfs.
The hdparm command only tells you if TRIM is supported by the drive, not if you have activated it on a specific partition.
To test if TRIM works you can also do a manual test (as root) with
Code:

fstrim -v /
This will only work on ext4 partitions.

jas0n 09-07-2012 04:02 PM

I am using ext4. The drive is a Samsung 128 gb 830.

I ran fstrim on both the root and home partitions. In both instances the output indicated that it did trim blocks on the file system. It seems that the test I linked to is invalid, at least on my system, because the blocks the deleted file used are not trimmed immediately.

Do I need to manually run fstrim every so often or set up a cron job for it, or is this something that is handled automatically?

Cheesesteak 09-07-2012 08:59 PM

Are you running the default 2.6.32 kernel with Squeeze? Trim isn't supported until 2.6.33+.

jas0n 09-08-2012 09:42 AM

I beg your pardon. I installed Wheezy (I have Squeeze running on two other boxes). The kernel is 3.2.

rknichols 09-08-2012 02:18 PM

Quote:

Originally Posted by jas0n (Post 4774636)
But testing according to the following article indicates TRIM is not working:

http://techgage.com/article/enabling..._under_linux/2

To summarize, I created a test file; checked to see if data was present at the sector where the file started; deleted the file; and checked to see if the sector was zeroed out.

I wouldn't attach much significance to that test result. The drive isn't going to erase anything until the entire erase block (which is much larger than that little 4KB test file) is released by TRIM, or until a write somewhere else in that erase block forces the entire block to be reallocated. If it so happened that the test file was the only part of that erase block currently in use, then the drive might perform the erase immediately, but that action is something the drive's controller does at its leisure, and you can't control when it happens other than by triggering a (correctly working) secure erase of the entire drive.


All times are GMT -5. The time now is 09:22 PM.