I'm currently building a new Ubuntu 13.04 server with 2 256GB SSDs in a raid mirror to run a MariaDB instance. We typically place LVM on top of dm-crypt encryption on top of an md raid 1 array, but haven't used SSDs in this setup previously.
My question is, since we'll be using a newer (3.8) kernel, it should allow fstrim to be applied to the raid volume directly as I understand it. Can I now simply rely on this to work properly with fstrim -v /
via a cron job, just as I would if the raid wasn't in place? Is this true even with LVM on top of the raid volume? We plan to use the hardware encryption present on the drives, so we won't need dm-crypt here.
NOTE: I'm aware that there are several similar questions involving backporting updated kernel versions and implementing discard with the md volume -- I'm asking specifically if fstrim
works against md-raid without further modification in newer kernels.
UPDATE: Just wanted to follow up and post that this worked fine. There's now a job in cron.daily that runs fstrim on /
and /boot
and it's working perfectly. Also, it turned out the hardware encryption on the SSDs (Samsung 840 Pros) appears to require TPM support, which we don't have, so we did configure with software encryption as shown in the link. By adding discard
to the options in /etc/crypttab
(not to /etc/fstab
) and issue_discards = 1
to the devices section of /etc/lvm/lvm.conf
, fstrim works fine even through LVM, encryption, and RAID layers. More info about configuring for trim/discard on SSDs with LVM and encryption is available here.
Patches for mdraid RAID 1 and 10 support for TRIM went up about a year ago.
You can test your kernel's support by mounting the filesystem with the
discard
option (which enables automatic TRIM). If it is supported, you'll see a message in syslog ordmesg
like the following:Otherwise you would get this:
You don't need to reboot to see if it's working: