7

I have Linux installed on a Dell XPS 9343 with an Samsung PM851 SSD.
I recently read that many SSDs don't support TRIM operations.
So I'd like to check if discard option effectively works on my system.

At first step, I tried to simply run sudo fstrim --verbose --all and it reported 41GB trimmed; this makes me fear because I was expecting a really little value because I have the continuously TRIM enabled (see above); in fact, if I re-run that command again I get O bytes trimmed. Is it normal? even if I have the discard option in the /etc/fstab?

PS: I tried to follow the proposed solution here but it stucks on the second command due to trim.test: FIBMAP unsupported.
PS2: it's a flat SSD (no LVM or RAID) with GPT and EXT4 filesystem

mattia.b89
  • 3,238
  • fstrim is basically saying you have 41G of free space on your partition. Are you sure you put your trim.test file on your ext4 filesystem? For example, filefrag will not work on a tmpfs like /tmp. – meuh Aug 28 '16 at 16:01
  • you are right! I don't have to run it on my /tmp, that is a tmpfs partition...I will answer my own question below. – mattia.b89 Aug 28 '16 at 16:34
  • anyhow, I don't understand why the first time I launch sudo fstrim --verbose --all, it reports N GB trimmed, while when I re-run it immediately after, I get 0 bytes trimmed - OP updated to reflect this point – mattia.b89 Aug 28 '16 at 16:34

2 Answers2

17

Try lsblk -D

TRIM/discard is available, if the DISC-MAX column is not 0B

Example (SSD/trim available)

[root@foo bar]# lsblk -D
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0        4K       1G         0

Example (HDD/trim not available)

[root@foo bar]# lsblk -D
NAME   DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda           0        0B       0B         0
beck
  • 171
  • 1
    DISC-MAX is not a reliable indicator. lsblk -D shows me non-zero (64M) for my SD card mmcblk0, which has not TRIM. – Martin Vegter Jul 24 '17 at 17:16
  • 2
    @MartinVegter Technically it might have TRIM, as the flash chips are mostly identical, they just add a controller in front of it to translate between the flash and the SD interface. Though from what i know the SD Spec does not include TRIM, so this is would count as one of the cases of broken TRIM implementations like some SSDs which announce TRIM but have no or a broken implementation. – beck Sep 04 '17 at 16:57
  • 1
    So in summary: if DISC-MAX is 0B then you cannot use TRIM commands. Otherwise, YMMV. – RobM Mar 29 '22 at 13:46
2

as @meuh pointed out in the comment, I need to run the test on my EXT4 partition, while I tried it on my /tmp SOLVED!

PS: following the test result, I can confirm that the drive on my XPS 9343 (Samsung PM851 M.2 2280 256GB, firmware revision: EXT25D0Q) supports TRIM command, even if dmesg reports NCQ Send/Recv Log not supported

mattia.b89
  • 3,238