Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.