Btrfs: Difference between revisions
replace manual bees with NixOS module |
m →Scrubbing: Copyedit for grammar & missing small words |
||
Line 84: | Line 84: | ||
=== Scrubbing === | === Scrubbing === | ||
Btrfs | Btrfs filesystems by default keep checksums for all files, to monitor if the file has changed due to hardware malfunctions or other external effects. | ||
Scrubbing | Scrubbing is the process of checking file consistency, which may use checksums and/or duplicated copies of data, from raid for example. Scrubbing may be done "online", meaning you don't need to unmount a subvolume to scrub it. | ||
You can enable automatic scrubbing | You can enable automatic scrubbing withː | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.btrfs.autoScrub.enable = true; | services.btrfs.autoScrub.enable = true; | ||
</syntaxhighlight> | </syntaxhighlight> | ||
Automatic scrubbing by default is performed once a month, but you can change that | Automatic scrubbing by default is performed once a month, but you can change that withː | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.btrfs.autoScrub.interval = "weekly"; | services.btrfs.autoScrub.interval = "weekly"; | ||
Line 99: | Line 99: | ||
<code>interval</code> syntax is defined by [https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events systemd.timer's Calendar Events] | <code>interval</code> syntax is defined by [https://www.freedesktop.org/software/systemd/man/systemd.time.html#Calendar%20Events systemd.timer's Calendar Events] | ||
By default, autoscrub will scrub all detected btrfs mount points. However, in case of mounted nested subvolumes ( | By default, autoscrub will scrub all detected btrfs mount points. However, in case of mounted nested subvolumes (e.g. the example above where <code>/nix</code> and <code>/home</code> are nested subvolumes under <code>/</code>), you only need to scrub the topmost one. So an example configuration may look like this: | ||
<syntaxhighlight lang="nix"> | <syntaxhighlight lang="nix"> | ||
services.btrfs.autoScrub = { | services.btrfs.autoScrub = { | ||
Line 108: | Line 108: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
The result of periodic auto scrub will be | The result of the periodic auto scrub will be saved to the system journal, and you can check the status of the last scrubː | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
btrfs scrub status / | btrfs scrub status / | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can also start a | You can also start a scrub in the background manuallyː | ||
<syntaxhighlight lang="bash"> | <syntaxhighlight lang="bash"> | ||
btrfs scrub start / | btrfs scrub start / | ||
</syntaxhighlight> | </syntaxhighlight> | ||
You can check the status of the ongoing scrubbing process with the same <code>status</code> command | You can check the status of the ongoing scrubbing process with the same <code>status</code> command as above. | ||
=== Deduplication === | === Deduplication === | ||
Files with (partially) equal contents can be deduplicated using [https://github.com/Zygo/bees bees] or [https://github.com/markfasheh/duperemove duperemove]. | Files with (partially) equal contents can be deduplicated using [https://github.com/Zygo/bees bees] or [https://github.com/markfasheh/duperemove duperemove]. | ||
bees can be configured in <code>configuration.nix</code>: | bees can be configured in <code>configuration.nix</code>: | ||