I need to configure a RAID-1 on one SSD and one HDD. Both SSD and HDD has some preinstalled software, which I don't need so both can be fully wiped if that is any advantage.My research so far lead me to the --write-mostly option, which I understand that I should be using on the HDD such that read operations will get the full speed of the SSD.But it is not clear to me, how to ensure the TRIM command is properly used.I read warnings about mdadm writing to every sector of the device during setup leaving the SSD with no spare sectors regardless of any TRIM performed before setting up the raid.Am I better off first creating the RAID degraded with the SSD as the only device and then adding the HDD, such that only the HDD gets written to?What would I need to do to the SSD before setting up the RAID, such that any needed TRIM has been performed? The SSD has preinstalled software (that I don't need), which means I don't know which sectors has been previously written.In case it is of any relevance, the SSD is 128GB and is in dmesg output mentioned as SAMSUNG MZ7LF128HCP-00000, FXT0101Q by the ata layer and SAMSUNG MZ7LF128 101Q PQ by the sd layer.
Configuring a mdadm RAID-1 on SSD and HDD
linux;mdadm;ssd;trim
Just use --assume-clean and don't even sync in the first place.Once you create your RAID, the first thing you do is mkfs... and mkfs TRIMs by default without even asking (unless you use -E nodiscard or similar) and your RAID sync is already gone at this point anyway.Basically it's impossible to keep a mixed SSD+HDD RAID in sync as long as TRIM affects only one side. Even with SSD+SSD RAID, a TRIM will likely cause differences if it's different SSD models or different partition offsets.It's not a problem as long as it only affects free space. The actual data itself will still be in sync and thus redundancy is provided.If the SSD ever fails or you decide to replace the HDD with another SSD later on, that's where you get the full sync on SSD since that's the only way md knows how to do things. md does not record TRIM commands and thus remember free regions to speed up syncing; it is also not smart enough to TRIM (and thereby zero) the target SSD and only write non-zero data. Maybe when SSD become more common such features will be added to speed up resyncs.Even so it's not something you should worry too much about; TRIM is a long-term measure, your filesystem will see TRIM during regular use, so over time even a fully written SSD will see enough trimmed areas.