RogerBW's Blog

Building a File Server 4: maintenance 18 October 2017

In this (probably final) part of the series on building a file server, I'll talk about keeping the thing running once you've got it. This is specific to the ZFS approach.

Scrub once a week or so (this reads every piece of data to make sure they're still legible). I think Debian zfs packages now come with a once-a-month crontab; that could work too.

zpool scrub storage

Take snapshots at least every day, quite possibly more often. This is your backup in case you accidentally delete or overwrite a file. I keep seven days of snapshots, deleting the oldest one just after the latest one's been added. You can do this on the entire pool, recursing down the individual filesystems on it (which is what these commands do), or to individual filesystems. Snapshot data are accessible within the filesystem under .zfs/snapshots/NAME.

zfs snapshot -r storage@NEWNAME
zfs destroy -r storage@OLDNAME

If you have a second server also running ZFS, you can do incremental backups (e.g. from the previous day's snapshot to the one you've just taken). Look into zfs send and zfs receive for that; the syntax will vary based on your needs. I end up doing


Check the health of the pool every so often (use a Nagios plugin, or look at the output of zpool status). When you need to replace a disc, in theory hot-swap bays let you do this without downtime, but in practice it's always easier to shut the machine down for the hardware swap.

Use your list of disc serial numbers (see, that's why I told you to make it) to confirm that you're pulling the right disc. Drop in the new one, reboot, and:

zpool replace -o ashift=12 storage pci-0000…

where the last parameter is the disc ID shown by zpool status as having failed. ZFS will start resilvering at once (copying data back onto that disc).

When it's time to expand your array, put in another slab of discs, get the new path IDs, and:

zpool add -o ashift=12 storage raidz2 /dev/disk/by-path/pci-0000…

When doing a replace or add with new discs, you may get a warning that a disc "does not contain an EFI label but it may contain partition information in the MBR". The easiest way round this is to use the -f flag, though the usual provisos apply; make sure you're not overwriting a disc with data on it.

Tags: computing

See also:
Building a File Server 1: planning
Building a File Server 2: hardware
Building a File Server 3: software

Comments on this post are now closed. If you have particular grounds for adding a late comment, comment on a more recent post quoting the URL of this one.

Tags 1920s 1930s 1940s 1950s 1960s 1970s 1980s 1990s 2000s 2010s 3d printing action advent of code aeronautics aikakirja anecdote animation anime army astronomy audio audio tech aviation base commerce battletech beer boardgaming book of the week bookmonth chain of command children chris chronicle church of no redeeming virtues cold war comedy computing contemporary cornish smuggler cosmic encounter coup covid-19 crime cthulhu eternal cycling dead of winter doctor who documentary drama driving drone ecchi economics en garde espionage essen 2015 essen 2016 essen 2017 essen 2018 essen 2019 essen 2022 essen 2023 existential risk falklands war fandom fanfic fantasy feminism film firefly first world war flash point flight simulation food garmin drive gazebo genesys geocaching geodata gin gkp gurps gurps 101 gus harpoon historical history horror hugo 2014 hugo 2015 hugo 2016 hugo 2017 hugo 2018 hugo 2019 hugo 2020 hugo 2022 hugo-nebula reread in brief avoid instrumented life javascript julian simpson julie enfield kickstarter kotlin learn to play leaving earth linux liquor lovecraftiana lua mecha men with beards mpd museum music mystery naval noir non-fiction one for the brow opera parody paul temple perl perl weekly challenge photography podcast politics postscript powers prediction privacy project woolsack pyracantha python quantum rail raku ranting raspberry pi reading reading boardgames social real life restaurant reviews romance rpg a day rpgs ruby rust scala science fiction scythe second world war security shipwreck simutrans smartphone south atlantic war squaddies stationery steampunk stuarts suburbia superheroes suspense television the resistance the weekly challenge thirsty meeples thriller tin soldier torg toys trailers travel type 26 type 31 type 45 vietnam war war wargaming weather wives and sweethearts writing about writing x-wing young adult
Special All book reviews, All film reviews
Produced by aikakirja v0.1