The TRIM command allows an OS to inform an SSD which sectors contain data, and which are free. This allows the disk to re-use free sectors internally and improves wear leveling.

Now, if an SSD is cloned to anoher via dd, each single sector is copied to the target disk. However, dd does not know if the content of the sectors is actually data, or unused. That is, it can not send a TRIM command to the target disk. To my understanding, the target disk has to consider EACH written sector as used.

The only way around would be if the used/free information is somehow stored in the sectors themself, and so is copied by dd to the new disk.

So, how is it done? Is there a problem?

  • No problem. There's no real way to tell whether a block is mapped to actual / wanted data or not. You can at best mount all the filesystems on the clone and fstrim them all after cloning. (Although, sparse might help you avoid writing all-zero blocks...? That's technically irrelevant with whether the source block was TRIM'd before cloning though.)
    – Tom Yan
    Jul 19, 2021 at 17:46
  • Yes there is a problem in that you have written to a disk and caused ware on it. Don't use dd with a SSD as target.
    – NiKiZe
    Aug 8, 2021 at 14:03

2 Answers 2


Use fstrim (man fstrim) after having cloned the partitions.

Example: I've got a system over BTRFS which was cloned to an SSD, so I boot it and run:

 λ sudo fstrim -v /    
/: 190.4 GiB (204443279360 bytes) trimmed

The TRIM standard states that reading a trimmed block gives undefined results. Some versions of trim will simulate returning a zeroed block when you read it, others may return the previous data, or some random data.

  • ACS-3 says the drive will report whether it does deterministic read after TRIM and whether such reads return zeroes. Most modern SSDs will do both. Jul 20, 2021 at 0:32
  • That is not what I'm asking. My question is: dd blindly copies blocks from source to target. It does not know if a block is trimmed, and so does not tell the target disk. Finally, when cloning an empty disk with all trimmed blocks, you will end up with an empty target disk where each block is marked as used...
    – sweber
    Jul 20, 2021 at 4:03
  • 1
    @sweber: that's not a question, that's the answer. And if you don't like that result, don't use dd. For instance, you could create a new fs on the new disk and copy with a tar pipe or something. Or use a fs clone utility that knows about filesystem free space and doesn't copy it.
    – user10489
    Jul 20, 2021 at 4:41

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .