software:linux:btrfs
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| software:linux:btrfs [2015/06/22 00:23] – superwizard | software:linux:btrfs [2016/11/17 03:26] (current) – superwizard | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Scripts for btrfs maintenance tasks like periodic scrub ====== | ||
| + | |||
| + | |||
| + | From: https:// | ||
| + | |||
| + | < | ||
| + | Great Documentation | ||
| + | |||
| + | Scripts for btrfs maintenance tasks like periodic scrub, balance, trim or defrag on selected | ||
| + | mountpoints or directories. | ||
| + | </ | ||
| + | |||
| + | ====== btrfs check ====== | ||
| + | |||
| + | From: https:// | ||
| + | |||
| + | < | ||
| + | btrfs check /dev/sb2 | ||
| + | btrfs check --repair \dev\sb2 | ||
| + | </ | ||
| + | |||
| + | ====== btrfs scrub ====== | ||
| + | |||
| + | From: http:// | ||
| + | |||
| + | From: https:// | ||
| + | |||
| + | |||
| + | |||
| + | < | ||
| + | btrfs scrub start -Bd $mountpoint | ||
| + | |||
| + | btrfs scrub is used to scrub a btrfs filesystem, which will read all data and metadata blocks from | ||
| + | all devices and verify checksums. Automatically repair corrupted blocks if there’s a correct copy | ||
| + | available. | ||
| + | |||
| + | start [-BdqrRf] [-c < | ||
| + | Start a scrub on all devices of the filesystem identified by path or on a single device. If a scrub is already running, the new one fails. | ||
| + | Without options, scrub is started as a background process. | ||
| + | The default IO priority of scrub is the idle class. The priority can be configured similar to the ionice(1) syntax using -c and -n options. | ||
| + | Options | ||
| + | -B | ||
| + | do not background and print scrub statistics when finished | ||
| + | -d | ||
| + | print separate statistics for each device of the filesystem (-B only) at the end | ||
| + | -q | ||
| + | be quiet, omit error messages and statistics | ||
| + | -r | ||
| + | run in read-only mode, do not attempt to correct anything, can be run on a read-only filesystem | ||
| + | -R | ||
| + | print raw statistics per-device instead of a summary | ||
| + | -c < | ||
| + | set IO priority class (see ionice(1) manpage) | ||
| + | -n < | ||
| + | set IO priority classdata (see ionice(1) manpage) | ||
| + | -f | ||
| + | force starting new scrub even if a scrub is already running, this can useful when scrub status | ||
| + | file is damaged and reports a running scrub although it is not, but should not normally be necessary | ||
| + | status [-d] < | ||
| + | </ | ||
| + | |||
| + | ====== resize partition ====== | ||
| + | |||
| + | From: http:// | ||
| + | |||
| + | < | ||
| + | Fix | ||
| + | |||
| + | First, a live system was booted to reduce the risk of damage while the system is running on a | ||
| + | filesystem that's bigger than the partition it's on. | ||
| + | |||
| + | Mount the filesystem: | ||
| + | |||
| + | mount /dev/sda2 /mnt/tmp | ||
| + | First shrink the second device to 50 GB - 1 GB = 49 GB to avoid rounding errors: | ||
| + | |||
| + | btrfs filesystem resize 2:49g /mnt/tmp | ||
| + | Resize it to fill the 50 GB partition: | ||
| + | |||
| + | btrfs filesystem resize 2:max /mnt/tmp | ||
| + | Check btrfs filesystem show, both devices should have the right size: | ||
| + | |||
| + | devid 1 size 50.00GiB used 43.03GiB path /dev/sda2 | ||
| + | devid 2 size 50.00GiB used 43.03GiB path /dev/sdb2 | ||
| + | Unmount, reboot, the error should be gone. | ||
| + | </ | ||
| + | |||
| + | ====== BTRFS restoring a corrupt filesystem from another “tree location” ====== | ||
| + | |||
| + | From: http:// | ||
| + | |||
| + | < | ||
| + | Here is how you restore a really corrupt btrfs filesystem using btrfs restore. | ||
| + | |||
| + | PRE STEPS (realizing the filesystem is really corrupt by trying simple mounts and | ||
| + | restores): | ||
| + | |||
| + | * assume your volume name is /dev/md127 and that you have an available /root folder | ||
| + | to dump temp data to and that you will be dumping your restore to /USB | ||
| + | * you can change any of those variable if thats not the case | ||
| + | |||
| + | Here we assume the filesystem is so corrupt that its not mounting regulary: | ||
| + | |||
| + | # mount /dev/md127 /data | ||
| + | mount: wrong fs type, bad option, bad superblock on /dev/md127, | ||
| + | | ||
| + | In some cases useful info is found in syslog - try | ||
| + | dmesg | tail or so | ||
| + | </ | ||
| + | |||
| ====== btrfs file system ====== | ====== btrfs file system ====== | ||
software/linux/btrfs.1434932609.txt.gz · Last modified: by superwizard
