forked from kdave/btrfsmaintenance
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbtrfs-scrub.sh
More file actions
executable file
·59 lines (50 loc) · 1.05 KB
/
btrfs-scrub.sh
File metadata and controls
executable file
·59 lines (50 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/sh
#
# Copyright (c) 2014 SuSE Linux AG, Nuernberg, Germany.
#
# please send bugfixes or comments to http://www.suse.de/feedback.
#
# paranoia settings
#
umask 022
PATH=/sbin:/bin:/usr/sbin:/usr/bin
export PATH
if [ -f /etc/sysconfig/btrfsmaintenance ] ; then
. /etc/sysconfig/btrfsmaintenance
fi
if [ -f /etc/default/btrfsmaintenance ] ; then
. /etc/default/btrfsmaintenance
fi
LOGIDENTIFIER='btrfs-scrub'
readonly=
if [ "$BTRFS_SCRUB_READ_ONLY" = "true" ]; then
readonly=-r
fi
ioprio=
if [ "$BTRFS_SCRUB_PRIORITY" = "normal" ]; then
# ionice(3) best-effort, level 4
ioprio="-c 2 -n 4"
fi
{
OIFS="$IFS"
IFS=:
for MNT in $BTRFS_SCRUB_MOUNTPOINTS; do
IFS="$OIFS"
echo "Running scrub on $MNT"
if [ $(stat -f --format=%T "$MNT") != "btrfs" ]; then
echo "Path $MNT is not btrfs, skipping"
continue
fi
btrfs scrub start -Bd $ioprio $readonly "$MNT"
if [ "$?" != "0" ]; then
echo "Scrub cancelled at $MNT"
exit 1
fi
done
} | \
case "$BTRFS_LOG_OUTPUT" in
stdout) cat;;
journal) systemd-cat -t "$LOGIDENTIFIER";;
*) cat;;
esac
exit 0