3

I have a server with 2 SSDs:

Model Family:     Intel 520 Series SSDs
Device Model:     INTEL SSDSC2BW240A3F
Firmware Version: 400i
User Capacity:    240,057,409,536 bytes [240 GB]
Sector Size:      512 bytes logical/physical

On them I have 3 mdraid mirror devices (md0,1,2) formatted with EXT4 filesystem. I'm using mbr (not gpt) partition table. All 3 filesystems are mounted with discard mount option.

/dev/md0 on / type ext4 (rw,discard,errors=remount-ro)
/dev/md2 on /vservers type ext4 (rw,discard)
/dev/md1 on /var type ext4 (rw,discard)

The PROBLEM is that whenever I reboot the server, fstrim -v /any_mountpoint says it needed to trim ALL of the unused space. Once I do the full fstrim of the filesystems, everything works as expected until the next reboot. Running fstrim after a reboot again trims the whole filesystem.

Could somebody explain to me what I'm doing wrong? I thought ext4 remembered the already trimmed parts of filesystem (on my desktop with 1 ssd, it does). This is on Ubuntu 14.04 with 3.13.0-23-generic kernel.

umataro
  • 31
  • 1
  • 2

1 Answers1

2

I asked a very similar question not so long ago - fstrim trims more than half of partition size even though partition mounted with discard. There is a more detailed explanation/discussion of what happens on this question, but basically the record of what has been trimmed with fstrim (and the underlying FITRIM ioctl) is kept in kernel memory and is not written to disk. Every time fstrim is run after a reboot, the full possible range of FITRIM ioctls are issued.

Graeme
  • 33,607
  • 8
  • 85
  • 110
  • Which means in practice that...? – Flavius Mar 25 '15 at 07:02
  • @Falvius, I don't really understand what you mean by 'in practice'. After a reboot all the free space is trimmed after an `fstrim`. – Graeme Mar 25 '15 at 10:00
  • "the full possible range of FITRIM ioctls are issued." – Flavius Mar 25 '15 at 11:42
  • @Flavius, it means that `FITRIM` `ioctls` will be issued to cover all of the free space on the disk. – Graeme Mar 25 '15 at 13:26
  • @Flavius it means that the kernel will try to TRIM all free space, but the SSD controller knows which blocks are already trimmed, so will trim only the "new" ones anyway. – Marki555 Jun 28 '19 at 20:10