How to make use of chattr command for nocow folder(and check it)?

in /run/media/enio/wd ultrastar hdd i made folder Torrents (/run/media/enio/wd ultrastar hdd/Torrents). what is the command to make that folder nocowdata and all the files that will torrent make inside that folder nocow.

chattr +C /run/media/enio/wd ultrastar hdd/Torrents is this the precise command?

and how to use lsattr command to check that folder and maybe the folders inside if nocow is indeed disabled? i tried to make a torrent folder on the other drive nocow and i dont know if i did manage to do it.
and that other torrent file that is on wd gold, if i delete it i deleted also the nocow on that folder.(what if i make the same folder name in the same place, will it be cow or nocow?)

That’s right, chattr +C /path/to/directory will disable copy-on-write for that directory.

If you do snapshotting, you may wish to create a separate subvolume for that directory so it is excluded from snapshots. The snapshots will be copy-on-write.

You can also disable copy-on-write for a subvolume with the nodatacow mount option, however it needs to be a separate filesystem (for example, a separate partition) if your other subvolumes are copy-on-write. You can’t mount some subvolumes in a given filesystem with nodatacow and others with datacow.

You can read more about options related to disabling copy-on-write here:


i tried earlier on wd gold, i made Torrents folder, and did that command, and later tried to check if it worked with lsattr and it says something unknown, as in it cant locate the file to check or something.
what would be the correct command to use to check that:

chattr +C /run/media/enio/wd ultrastar hdd/Torrents

:that it worked and that the Torrents folder is indeed nocow.

and another thing, so this file would still be included in snapshots even if it is nocow? how would that work, that would be something different then judging how snapshots are taken on cow system?

If you are using spaces in your directory names, you will have to quote the path or escape the spaces.

lsattr is correct. To check the attributes of a directory, you will need the -d flag.

mkdir nocow/
chattr +C nocow/
lsattr -d nocow/
---------------C------ nocow

Only the directory is no-CoW. The directory lives in a subvolume which has been mounted CoW, unless you set up a separate filesystem so you can mount the subvolume nocow. My understanding is if you are snapshotting the subvolume that contains the no-CoW directory, CoW still occurs. See here:

$ chattr +C */dir/file*

This will disable copy-on-write for those operation in which there is only one reference to the file. If there is more than one reference, e.g. due to file clones / lightweight clones or filesystem snapshots, copy-on-write still occurs.

All you need to do to prevent the directory from being snapshotted is make a new subvolume for it.


hm, interesting topic, it is helping me to understand even more about the file system that I have been using for more than a year… Thanks @BluishHumility

1 Like

Just applied what you explained here
Not taking snapshots, and with cow disabled :slight_smile:

$ lsattr .mozilla/
---------------C------ .mozilla/extensions
---------------C------ .mozilla/firefox
$ sudo btrfs subvolume list / | grep .mozilla
ID 309 gen 5607 top level 295 path @home/myuser/.cache/mozilla
ID 312 gen 5606 top level 295 path @home/myuser/.mozilla

I managed to make the Torrents folder nocow and managed to check it via lsattr, good job guys and thanks. One more question, lets say i delete that folder, and make another with the same name, i would need to make this step again(chattr) to folder to be nocow again?

1 Like

Yes, you will need to apply it again. The new directory will not have the special attribute, even if it has the same name.


This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.