public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* Settings compression for a filesystem
@ 2021-11-04 14:56 Martin Steigerwald
  2021-11-04 15:14 ` Forza
  0 siblings, 1 reply; 3+ messages in thread
From: Martin Steigerwald @ 2021-11-04 14:56 UTC (permalink / raw)
  To: linux-btrfs

Hi!

I do have a bunch of BTRFS on LUKS backup disks. Plasma desktop mounts 
them unter /media… however, it does not mount with compression enabled. 
I do have some older backup disks which are in /etc/fstab including 
mount option "compress=zstd".

Is there any way to tell BTRFS to always use a certain compression 
algorithm for all newly written files (and of course existing files which 
use compression) without adding an entry in fstab for each disk?

I thought about

btrfs property set MOUNTPOINT compression zstd

but that sets the property just on the root inode of the mounted 
filesystem. Does it propagate? The manpage does not seem to have any 
information on that.

If not, well then I add the entries to fstab.

Thanks,
-- 
Martin



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Settings compression for a filesystem
  2021-11-04 14:56 Settings compression for a filesystem Martin Steigerwald
@ 2021-11-04 15:14 ` Forza
  2021-11-04 17:23   ` Martin Steigerwald
  0 siblings, 1 reply; 3+ messages in thread
From: Forza @ 2021-11-04 15:14 UTC (permalink / raw)
  To: linux-btrfs; +Cc: Martin Steigerwald




On 2021-11-04 15:56, Martin Steigerwald wrote:
> Hi!
> 
> I do have a bunch of BTRFS on LUKS backup disks. Plasma desktop mounts
> them unter /media… however, it does not mount with compression enabled.
> I do have some older backup disks which are in /etc/fstab including
> mount option "compress=zstd".
> 
> Is there any way to tell BTRFS to always use a certain compression
> algorithm for all newly written files (and of course existing files which
> use compression) without adding an entry in fstab for each disk?
> 
> I thought about
> 
> btrfs property set MOUNTPOINT compression zstd
> 
> but that sets the property just on the root inode of the mounted
> filesystem. Does it propagate? The manpage does not seem to have any
> information on that.
> 
> If not, well then I add the entries to fstab.
> 
> Thanks,
> 

You can use `btrfs property set <file> compression zstd`[1] on 
directories and files. This enables compression for any new writes to 
those directories and files. If you set compression on a directory, any 
new files and directories will inherit the property, while existing 
files and directories won't.

After mounting your disks you can use find to set compression recursively:

# find /media/btrfs/ -exec btrfs prop set {} compression zstd \;

This will enable the compresison flag, but not re-compress existing 
data. In order to recompress any existing data you have to rewrite it or 
use `btrfs filesystem defragment`[2] with the '-c' flag to compress the 
files, however this does not guarantee that all of the data will be 
recompressed.

In addition to btrfs propterty set, it is possible to use setfattr, 
chattr or mount options to set compression [3]

[1] https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-property
[2] 
https://btrfs.wiki.kernel.org/index.php/Manpage/btrfs-filesystem#SUBCOMMAND
[3] https://wiki.tnonline.net/w/Btrfs/Compression

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Settings compression for a filesystem
  2021-11-04 15:14 ` Forza
@ 2021-11-04 17:23   ` Martin Steigerwald
  0 siblings, 0 replies; 3+ messages in thread
From: Martin Steigerwald @ 2021-11-04 17:23 UTC (permalink / raw)
  To: linux-btrfs, Forza

Forza - 04.11.21, 16:14:31 CET:
> You can use `btrfs property set <file> compression zstd`[1] on
> directories and files. This enables compression for any new writes to
> those directories and files. If you set compression on a directory,
> any new files and directories will inherit the property, while
> existing files and directories won't.
> 
> After mounting your disks you can use find to set compression
> recursively:
> 
> # find /media/btrfs/ -exec btrfs prop set {} compression zstd \;

So it just inherits to the newly created files and directories in that 
directory directly.

Ah, I see… then in case I set it on the root inode of a new empty 
filesystem it just works, otherwise… I'd need to use find unless I choose 
to add an entry for each of the disks.

Thanks,
-- 
Martin



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-11-04 17:24 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-04 14:56 Settings compression for a filesystem Martin Steigerwald
2021-11-04 15:14 ` Forza
2021-11-04 17:23   ` Martin Steigerwald

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox