Test that TRIM really works on SSDs in RAID0

I installed OpenSuse on two SSDs in RAID0. I enabled TRIM by adding discard to all EXT4 partitions in fstab. The thing is that I would like to test that the TRIM really works (since it’s in RAID 0). There is a method for that when you simply create a file, delete it and then using hdparm directly access sectors of the deleted file. If TRIM works, there should be only zeros after a while. My problem is that I don’t know how to access sectors on RAID 0.


~ # hdparm --fibmap tempfile

tempfile:
 filesystem blocksize 4096, begins at LBA 229103616; assuming 512 byte sectors.
 byte_offset  begin_LBA    end_LBA    sectors
           0  234346496  234352639       6144

I know the position, but I can’t access it:

~ # hdparm --read-sector 234346496 /dev/md125

/dev/md125:
/dev/md125 is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)
Aborting.

It tells me to specify an aboslute LBA but I’m not sure how to do that.

On 2013-06-30 15:16, tobice wrote:

> I know the position, but I can’t access it:
>
>
> Code:
> --------------------
> ~ # hdparm --read-sector 234346496 /dev/md125
>
> /dev/md125:
> /dev/md125 is a RAID device: please specify an absolute LBA of a raw member device instead (raid1 only)
> Aborting.
> --------------------
>
>
> It tells me to specify an aboslute LBA but I’m not sure how to do that.

The same as above, but on /dev/sda, /dev/sdb, or equivalent. You have to
access the members of the array, not the array.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

Well that is possible… but how does it work? hdparm --fibmap prints one exact sector number and no device so I guess the sector number is relevant to the whole raid array. It’s not clear which array member to use (and since it’s RAID 0 the data would be split anyway). There must be some kind of translation or a way to access directly the RAID array…

On 2013-06-30 18:56, tobice wrote:
>
> Well that is possible… but how does it work? hdparm --fibmap prints
> one exact sector number and no device

No, that is not exact, that command takes a file path as input, and it
finds where that file resides. Look:


Telcontar:~ # hdparm --fibmap /data/raid/dentro
Unable to determine start offset LBA for device, aborting.

That’s a raid 5.


> Telcontar:~ # l yast2b.log
> -rw-r--r-- 1 root root 77660 Jan 26  2003 yast2b.log
> Telcontar:~ # hdparm --fibmap yast2b.log
>
> yast2b.log:
>  filesystem blocksize 4096, begins at LBA 53641098; assuming 512 byte sectors.
>  byte_offset  begin_LBA    end_LBA    sectors
>            0   91773386   91773537        152
> Telcontar:~ #


> so I guess the sector number is
> relevant to the whole raid array. It’s not clear which array member to
> use (and since it’s RAID 0 the data would be split anyway). There must
> be some kind of translation or a way to access directly the RAID
> array…

You have to assume that, being raid 1, both members are identical.


Cheers / Saludos,

Carlos E. R.
(from 12.3 x86_64 “Dartmouth” at Telcontar)

I’m not sure I understand. I have two 256GB SSDs in RAID 0 which means block-level striping. When I save a 2MB file, 1MB goes to /dev/sda and 1MB goes to /dev/sdb (generally speaking). That’s what makes it so fast. Hdparm gives me only one number and no disk so I assume that the number is the number of the first sector on the “virtual” 512GB disk. How do I access the sector directly? Maybe my whole approach is wrong… how would you suggest I should test that the TRIM is working?

This setup (two SSDs in RAID 0) came preinstalled in this laptop with Windows 8. I simply treated the configuration as it was only one 512GB disk and installed OpenSUSE on it. After the installation I enabled TRIM (as it was suggested) and I suppose it works. There is no error in dmesg and hdparm -I /dev/sda |grep TRIM shows Data Set Management TRIM supported (limit 16 blocks). It says “supported” but does it mean that it’s actually “on”? That’s why I would like to really test it. And I would also like to see the raw data magically turn into zeros :slight_smile:

On 2013-07-01 00:06, tobice wrote:
>
> I’m not sure I understand. I have two 256GB SSDs in RAID 0 which means
> block-level striping.

Oops. Sorry, I read raid 0 but I was mentally seeing raid 1.

No, then I don’t know how to do it.


Cheers / Saludos,

Carlos E. R.
(from 11.4, with Evergreen, x86_64 “Celadon” (Minas Tirith))