I can't seem to find an answer to this so I thought I would ask here:

In /etc/fstab and when using the mount command in ext4 you would add the option discard to activate TRIM on an SSD. Similarly the discard option activates TRIM on btrfs volumes as confirmed at btrfs.wiki.kernel.org. Btrfs is supposed to enable copy on write by nature and if this is the case does the discard option effectively disable copy on write?

I'm imagining TRIM erasing all of the blocks that would have contained previous versions of files. If copy on write still functions doesn't that reduce the performance of an SSD long term, if eventually none of the blocks are zeroed out?

2 Answers 2


Copy-on-write means that allocated blocks are not overwritten – instead, when a data block in a file changes, a new block is allocated with the new data and the file is updated to refer to the new block instead of the original one. When the old block is no longer referenced by any part of the file system, it is freed. Copy-on-write does not mean that no blocks are ever freed.

The discard option just tells Btrfs to report free blocks to the underlying device. Btrfs already keeps track of which blocks are free, and reporting this information to the underlying device won't affect copy-on-write behaviour.


Copy-on-write does not imply keeping references to no-longer-used blocks. The blocks themselves become free space (unless in use by another snapshot), and as far as I know, btrfs from then on no longer even knows they belonged to the file that they now hold the previous content of.

You are entirely right that discard makes the no-longer-used blocks, i.e. the previous content, unrecoverable.

I don't know what you expected, but I was actually sure there was a simple btrfs command that could revert a file to some older version if the new version was corrupt and you were lucky that the old content was still intact floating in the free space pool. Having googled my ass off, I find no source to back this claim, so it seems btrfs never gave you this in the first place.

So copy-on-write is not a data resilience feature in itself, it is an implementation detail that happens to increase your chances of undeleting the previous content, except it doesn't if you use discard.

You must log in to answer this question.

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