meta data for this page
Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
linux:fs:btrfs [2021/03/02 09:43] niziak |
linux:fs:btrfs [2021/05/02 11:34] (current) niziak |
||
---|---|---|---|
Line 45: | Line 45: | ||
!!! It is possible to remove any device if there is free space to which data can be moved during removal. | !!! It is possible to remove any device if there is free space to which data can be moved during removal. | ||
- | |||
- | ==== btrfs property ==== | ||
- | <code bash> | ||
- | btrfs property set <file> compression <zlib|lzo|zstd> | ||
- | </code> | ||
- | ===== Deduplication ===== | ||
- | External tool to find duplicated extens available | ||
- | [[https://github.com/markfasheh/duperemove]] | ||
- | |||
- | Simply do 'make' and 'make install' | ||
- | Following binaries will be installed: | ||
- | * btrfs-extent-same | ||
- | * csum-test | ||
- | * duperemove | ||
- | * hashstats | ||
- | * show-shared-extents | ||
- | |||
- | Recursively find duplicates in <dir> | ||
- | <code>duperemove -r <dir></code> | ||
- | |||
- | The same as above, but make real deduplication (on BTRFS only) | ||
- | <code>duperemove -rd <dir></code> | ||
- | |||
- | Increase deduplication chance by reducing block size to 4k: | ||
- | <code>duperemove -b 4k -rd <dir></code> | ||
- | |||
- | This deduplication works nice, it can find some shared parts inside Maildir. | ||
- | |||
- | |||
- | ===== Subvolumes ===== | ||
- | |||
- | <code> | ||
- | btrfs subvolume create /BTRFS/sub1 | ||
- | btrfs subvolume create /BTRFS/sub2 | ||
- | btrfs subvolume create /BTRFS/sub3 | ||
- | </code> | ||
- | |||
- | <code> | ||
- | btrfs subvolume list /BTRFS | ||
- | ID 256 gen 234 top level 5 path sub1 | ||
- | ID 257 gen 227 top level 5 path sub2 | ||
- | ID 258 gen 228 top level 5 path sub3 | ||
- | </code> | ||
- | |||
- | Mount subvolume | ||
- | <code>mount -o subvol=sv1/sv12 /dev/sdb /mnt</code> | ||
- | |||
- | Getting data size on each subcvolume: | ||
- | * Enable quota on btrfs ''btrfs quota enable /'' | ||
- | * Install script [[https://github.com/agronick/btrfs-size]] | ||
- | |||
- | |||
- | ==== Different mount options ==== | ||
- | NOT SUPPORTED YET: | ||
- | In general, btrfs doesn't _yet_ have the runtime infrastructure to handle | ||
- | per-subvolume mount options. The on-device format and general approach | ||
- | in the kernel was designed to allow it, and it's on the roadmap, it just | ||
- | hasn't been done... yet. | ||
- | |||
- | To make workaround it is possible to use attributes on files or directories: | ||
- | * C disable COW feature (for newly created directories or zero sized files). New files in directores with C attributes will be created with C attrib. But not subdirectories. | ||
- | * c enable compression | ||
- | |||
- | ==== Move data between subvolumes ==== | ||
- | See `cp` command arg: | ||
- | When --reflink[=always] is specified, perform a lightweight copy, where the data blocks are copied only when modified. If this is not possible the copy fails, or if | ||
- | --reflink=auto is specified, fall back to a standard copy. | ||
- | |||
- | <code bash> | ||
- | cp -pr --reflink=always srcDirectory dstDirectory/ | ||
- | rm -r srcDirectory | ||
- | </code> | ||
====== Scrub ====== | ====== Scrub ====== | ||
Line 142: | Line 70: | ||
====== Issues ====== | ====== Issues ====== | ||
+ | |||
===== Compression type 0x3 not supported ===== | ===== Compression type 0x3 not supported ===== | ||
GRUB 2.02 doesn't support ZSTD compression. | GRUB 2.02 doesn't support ZSTD compression. | ||
- | Solution is to exlude `/boot` from ZSTD compression (below) or install more recent Grub (from Debian Bullseye) | + | Solution is to exlude ''/boot'' from ZSTD compression (below) or install more recent Grub (from Debian Bullseye) |
<code bash> | <code bash> | ||
sudo btrfs filesystem defragment -v -r -czlib /boot | sudo btrfs filesystem defragment -v -r -czlib /boot | ||
sudo btrfs property set /boot compression zlib | sudo btrfs property set /boot compression zlib | ||
+ | # disable compression for newly created files | ||
+ | chattr -Rc /boot | ||
</code> | </code> | ||