meta data for this page
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| linux:fs:btrfs [2017/03/06 07:07] – niziak | linux:fs:btrfs [2021/05/02 11:34] (current) – niziak | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== BTRFS ====== | ||
| + | |||
| ===== References ===== | ===== References ===== | ||
| [[https:// | [[https:// | ||
| Line 26: | Line 28: | ||
| or | or | ||
| < | < | ||
| + | |||
| + | ===== Swap support ===== | ||
| + | |||
| + | **Current state:** Do not create SWAP files on BTRFS! | ||
| + | |||
| + | Swap support was restored with Kernel 4.21 | ||
| + | |||
| ===== Add/remove block devices ===== | ===== Add/remove block devices ===== | ||
| Line 36: | 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. | ||
| - | ===== Compression ===== | ||
| - | ==== mount options ==== | ||
| - | Can be enabled during mount time: | ||
| - | < | ||
| - | "if the first portion of data being compressed is not smaller than the original, the compression of the file is disabled -- unless the filesystem is mounted with compress-force" | ||
| - | Test data of size 651MB takes 371MB after compression. | ||
| - | ==== chattr +c ==== | + | ====== |
| - | Also single file compression possible using '' | + | |
| - | + | ||
| - | To recompress exisitng files, start defragmentation with -c param: | + | |
| - | < | + | |
| - | < | + | |
| - | + | ||
| - | It is not possible to get compression ratio of file. | + | |
| - | + | ||
| - | Internals: | + | |
| - | * In compressed extents, individual blocks are not compressed separately; rather, the compression stream spans the entire extent. | + | |
| - | * BTRFS: There is a simple decision logic: if the first portion of data being compressed is not smaller than the original, the compression of the file is disabled -- unless the filesystem is mounted with compress-force | + | |
| - | + | ||
| - | + | ||
| - | ===== Deduplication ===== | + | |
| - | External tool to find duplicated extens available | + | |
| - | [[https:// | + | |
| - | + | ||
| - | Simply do ' | + | |
| - | Following binaries will be installed: | + | |
| - | * btrfs-extent-same | + | |
| - | * csum-test | + | |
| - | * duperemove | + | |
| - | * hashstats | + | |
| - | * show-shared-extents | + | |
| - | + | ||
| - | Recursively find duplicates in < | + | |
| - | < | + | |
| - | + | ||
| - | The same as above, but make real deduplication (on BTRFS only) | + | |
| - | < | + | |
| - | + | ||
| - | Increase deduplication chance by reducing block size to 4k: | + | |
| - | < | + | |
| - | + | ||
| - | This deduplication works nice, it can find some shared parts inside Maildir. | + | |
| - | + | ||
| - | + | ||
| - | ===== Subvolumes ===== | + | |
| - | + | ||
| - | < | + | |
| - | btrfs subvolume create / | + | |
| - | btrfs subvolume create / | + | |
| - | btrfs subvolume create / | + | |
| - | </ | + | |
| - | + | ||
| - | < | + | |
| - | 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 | + | |
| - | </ | + | |
| - | + | ||
| - | Mount subvolume | + | |
| - | < | + | |
| - | + | ||
| - | Getting data size on each subcvolume: | + | |
| - | * Enable quota on btrfs '' | + | |
| - | * Install script [[https:// | + | |
| - | + | ||
| - | + | ||
| - | ==== Different mount options ==== | + | |
| - | NOT SUPPORTED YET: | + | |
| - | In general, btrfs doesn' | + | |
| - | per-subvolume mount options. | + | |
| - | 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 | + | |
| - | | + | |
| + | Start foreground, readonly scrub, print statistics at end: | ||
| <code bash> | <code bash> | ||
| - | cp -pr --reflink=always srcDirectory dstDirectory/ | + | btrfs scrub start -B -d -r / |
| - | rm -r srcDirectory | + | |
| - | </code> | + | |
| - | ====== Scrub ====== | + | scrub device /dev/sda3 (id 1) done |
| + | scrub started at Mon Mar 6 07:02:56 2017 and finished after 00:04:06 | ||
| + | total bytes scrubbed: 18.50GiB with 0 errors | ||
| + | scrub device /dev/sdc5 (id 2) done | ||
| + | scrub started at Mon Mar 6 07:02:56 2017 and finished after 00:06:52 | ||
| + | total bytes scrubbed: 18.47GiB with 0 errors | ||
| - | Start foreground, readonly scrub: | ||
| - | <code bash> | ||
| - | btrfs scrub start -B -d -r / | ||
| </ | </ | ||
| Get currently running scrub status: | Get currently running scrub status: | ||
| <code bash> | <code bash> | ||
| + | |||
| ====== migration to BTRFS ====== | ====== migration to BTRFS ====== | ||
| Line 140: | Line 70: | ||
| ====== Issues ====== | ====== Issues ====== | ||
| + | |||
| + | ===== Compression type 0x3 not supported ===== | ||
| + | |||
| + | GRUB 2.02 doesn' | ||
| + | Solution is to exlude ''/ | ||
| + | <code bash> | ||
| + | sudo btrfs filesystem defragment -v -r -czlib /boot | ||
| + | sudo btrfs property set /boot compression zlib | ||
| + | # disable compression for newly created files | ||
| + | chattr -Rc /boot | ||
| + | </ | ||
| ===== error inheriting props for ino 3336468 (root 264): -28 ===== | ===== error inheriting props for ino 3336468 (root 264): -28 ===== | ||