/
snap
/
core20
/
2769
/
usr
/
sbin
/
/snap/core20/2769/usr/sbin
mkdir
upload
Name
Size
Mode
Actions
aa-remove-unknown
3068
0755
edit
dl
rm
aa-status
8839
0755
edit
dl
rm
aa-teardown
139
0755
edit
dl
rm
add-shell
860
0755
edit
dl
rm
addgroup
37785
0755
edit
dl
rm
adduser
37785
0755
edit
dl
rm
agetty
69000
0755
edit
dl
rm
apparmor_parser
1526368
0755
edit
dl
rm
apparmor_status
8839
0755
edit
dl
rm
arpd
80144
0755
edit
dl
rm
arptables
220488
0755
edit
dl
rm
arptables-nft
220488
0755
edit
dl
rm
arptables-nft-restore
220488
0755
edit
dl
rm
arptables-nft-save
220488
0755
edit
dl
rm
arptables-restore
220488
0755
edit
dl
rm
arptables-save
220488
0755
edit
dl
rm
badblocks
35144
0755
edit
dl
rm
blkdeactivate
14837
0755
edit
dl
rm
blkdiscard
35048
0755
edit
dl
rm
blkid
121096
0755
edit
dl
rm
blkzone
71912
0755
edit
dl
rm
blockdev
67816
0755
edit
dl
rm
bridge
104760
0755
edit
dl
rm
capsh
31032
0755
edit
dl
rm
cfdisk
105048
0755
edit
dl
rm
chcpu
47336
0755
edit
dl
rm
chgpasswd
67792
0755
edit
dl
rm
chmem
63720
0755
edit
dl
rm
chpasswd
59600
0755
edit
dl
rm
chroot
43352
0755
edit
dl
rm
cpgr
61784
0755
edit
dl
rm
cppw
61784
0755
edit
dl
rm
cryptdisks_start
1544
0755
edit
dl
rm
cryptdisks_stop
844
0755
edit
dl
rm
cryptsetup
138792
0755
edit
dl
rm
cryptsetup-reencrypt
107848
0755
edit
dl
rm
ctrlaltdel
39144
0755
edit
dl
rm
debugfs
231224
0755
edit
dl
rm
delgroup
16495
0755
edit
dl
rm
deluser
16495
0755
edit
dl
rm
depmod
170352
0755
edit
dl
rm
devlink
154080
0755
edit
dl
rm
dhclient
521200
0755
edit
dl
rm
dhclient-script
16304
0755
edit
dl
rm
dmsetup
175128
0755
edit
dl
rm
dmstats
175128
0755
edit
dl
rm
dosfsck
59472
0755
edit
dl
rm
dosfslabel
55376
0755
edit
dl
rm
dumpe2fs
31112
0755
edit
dl
rm
e2freefrag
18816
0755
edit
dl
rm
e2fsck
335064
0755
edit
dl
rm
e2image
43400
0755
edit
dl
rm
e2label
109112
0755
edit
dl
rm
e2mmpstatus
31112
0755
edit
dl
rm
e2scrub
7296
0755
edit
dl
rm
e2scrub_all
5395
0755
edit
dl
rm
e2undo
22912
0755
edit
dl
rm
e4crypt
31104
0755
edit
dl
rm
e4defrag
35128
0755
edit
dl
rm
ebtables
220488
0755
edit
dl
rm
ebtables-nft
220488
0755
edit
dl
rm
ebtables-nft-restore
220488
0755
edit
dl
rm
ebtables-nft-save
220488
0755
edit
dl
rm
ebtables-restore
220488
0755
edit
dl
rm
ebtables-save
220488
0755
edit
dl
rm
faillock
14488
0755
edit
dl
rm
fatlabel
55376
0755
edit
dl
rm
fdformat
35048
0755
edit
dl
rm
fdisk
153880
0755
edit
dl
rm
filefrag
18768
0755
edit
dl
rm
findfs
14568
0755
edit
dl
rm
fsck
55576
0755
edit
dl
rm
fsck.cramfs
39176
0755
edit
dl
rm
fsck.ext2
335064
0755
edit
dl
rm
fsck.ext3
335064
0755
edit
dl
rm
fsck.ext4
335064
0755
edit
dl
rm
fsck.fat
59472
0755
edit
dl
rm
fsck.minix
125184
0755
edit
dl
rm
fsck.msdos
59472
0755
edit
dl
rm
fsck.vfat
59472
0755
edit
dl
rm
fsfreeze
14568
0755
edit
dl
rm
fstab-decode
14648
0755
edit
dl
rm
fstrim
71912
0755
edit
dl
rm
genl
84264
0755
edit
dl
rm
getcap
14648
0755
edit
dl
rm
getpcaps
14648
0755
edit
dl
rm
getty
69000
0755
edit
dl
rm
groupadd
93136
0755
edit
dl
rm
groupdel
88848
0755
edit
dl
rm
groupmems
63736
0755
edit
dl
rm
groupmod
97136
0755
edit
dl
rm
grpck
63672
0755
edit
dl
rm
grpconv
59448
0755
edit
dl
rm
grpunconv
59448
0755
edit
dl
rm
halt
1119856
0755
edit
dl
rm
hwclock
104808
0755
edit
dl
rm
iconvconfig
31128
0755
edit
dl
rm
init
1849992
0755
edit
dl
rm
insmod
170352
0755
edit
dl
rm
installkernel
2638
0755
edit
dl
rm
integritysetup
61672
0755
edit
dl
rm
invoke-rc.d
17042
0755
edit
dl
rm
ip
718896
0755
edit
dl
rm
ip6tables
99296
0755
edit
dl
rm
ip6tables-apply
7057
0755
edit
dl
rm
ip6tables-legacy
99296
0755
edit
dl
rm
ip6tables-legacy-restore
99296
0755
edit
dl
rm
ip6tables-legacy-save
99296
0755
edit
dl
rm
ip6tables-nft
220488
0755
edit
dl
rm
ip6tables-nft-restore
220488
0755
edit
dl
rm
ip6tables-nft-save
220488
0755
edit
dl
rm
ip6tables-restore
99296
0755
edit
dl
rm
ip6tables-restore-translate
220488
0755
edit
dl
rm
ip6tables-save
99296
0755
edit
dl
rm
ip6tables-translate
220488
0755
edit
dl
rm
iptables
99296
0755
edit
dl
rm
iptables-apply
7057
0755
edit
dl
rm
iptables-legacy
99296
0755
edit
dl
rm
iptables-legacy-restore
99296
0755
edit
dl
rm
iptables-legacy-save
99296
0755
edit
dl
rm
iptables-nft
220488
0755
edit
dl
rm
iptables-nft-restore
220488
0755
edit
dl
rm
iptables-nft-save
220488
0755
edit
dl
rm
iptables-restore
99296
0755
edit
dl
rm
iptables-restore-translate
220488
0755
edit
dl
rm
iptables-save
99296
0755
edit
dl
rm
iptables-translate
220488
0755
edit
dl
rm
isosize
30952
0755
edit
dl
rm
killall5
27016
0755
edit
dl
rm
ldattach
35048
0755
edit
dl
rm
ldconfig
387
0755
edit
dl
rm
ldconfig.real
1053768
0755
edit
dl
rm
logsave
14496
0755
edit
dl
rm
losetup
112992
0755
edit
dl
rm
lsmod
170352
0755
edit
dl
rm
luksformat
3401
0755
edit
dl
rm
mkdosfs
35328
0755
edit
dl
rm
mke2fs
137848
0755
edit
dl
rm
mkfs
14568
0755
edit
dl
rm
mkfs.bfs
35048
0755
edit
dl
rm
mkfs.cramfs
43168
0755
edit
dl
rm
mkfs.ext2
137848
0755
edit
dl
rm
mkfs.ext3
137848
0755
edit
dl
rm
mkfs.ext4
137848
0755
edit
dl
rm
mkfs.fat
35328
0755
edit
dl
rm
mkfs.minix
108784
0755
edit
dl
rm
mkfs.msdos
35328
0755
edit
dl
rm
mkfs.vfat
35328
0755
edit
dl
rm
mkhomedir_helper
22704
0755
edit
dl
rm
mklost+found
14648
0755
edit
dl
rm
mkswap
108784
0755
edit
dl
rm
modinfo
170352
0755
edit
dl
rm
modprobe
170352
0755
edit
dl
rm
netplan
798
0755
edit
dl
rm
newusers
101168
0755
edit
dl
rm
nfnl_osf
18736
0755
edit
dl
rm
nologin
14640
0755
edit
dl
rm
pam-auth-update
20335
0755
edit
dl
rm
pam_extrausers_chkpwd
43168
2755
edit
dl
rm
pam_extrausers_update
43168
0755
edit
dl
rm
pam_getenv
2890
0755
edit
dl
rm
pam_tally
14504
0755
edit
dl
rm
pam_tally2
18600
0755
edit
dl
rm
pam_timestamp_check
14488
0755
edit
dl
rm
pivot_root
14568
0755
edit
dl
rm
poweroff
1119856
0755
edit
dl
rm
pwck
59568
0755
edit
dl
rm
pwconv
55344
0755
edit
dl
rm
pwunconv
55352
0755
edit
dl
rm
raw
14568
0755
edit
dl
rm
readprofile
22792
0755
edit
dl
rm
reboot
1119856
0755
edit
dl
rm
remove-shell
904
0755
edit
dl
rm
resize2fs
67968
0755
edit
dl
rm
rfkill
51432
0755
edit
dl
rm
rmmod
170352
0755
edit
dl
rm
rmt
59952
0755
edit
dl
rm
rmt-tar
59952
0755
edit
dl
rm
rtacct
49448
0755
edit
dl
rm
rtcwake
47336
0755
edit
dl
rm
rtmon
80120
0755
edit
dl
rm
runlevel
1119856
0755
edit
dl
rm
runuser
67816
0755
edit
dl
rm
service
9262
0755
edit
dl
rm
setcap
14648
0755
edit
dl
rm
sfdisk
141544
0755
edit
dl
rm
shadowconfig
885
0755
edit
dl
rm
shutdown
1119856
0755
edit
dl
rm
sshd
884520
0755
edit
dl
rm
start-stop-daemon
48456
0755
edit
dl
rm
sulogin
51432
0755
edit
dl
rm
swaplabel
18664
0755
edit
dl
rm
swapoff
22760
0755
edit
dl
rm
swapon
51432
0755
edit
dl
rm
switch_root
14568
0755
edit
dl
rm
sysctl
30960
0755
edit
dl
rm
tarcat
936
0755
edit
dl
rm
tc
542160
0755
edit
dl
rm
telinit
1119856
0755
edit
dl
rm
tipc
129264
0755
edit
dl
rm
tune2fs
109112
0755
edit
dl
rm
tzconfig
106
0755
edit
dl
rm
unix_chkpwd
43160
2755
edit
dl
rm
unix_update
43160
0755
edit
dl
rm
update-ca-certificates
5418
0755
edit
dl
rm
update-mime
9402
0755
edit
dl
rm
update-passwd
35392
0755
edit
dl
rm
update-rc.d
17161
0755
edit
dl
rm
useradd
147160
0755
edit
dl
rm
userdel
101264
0755
edit
dl
rm
usermod
142840
0755
edit
dl
rm
veritysetup
53064
0755
edit
dl
rm
vigr
70200
0755
edit
dl
rm
vipw
70200
0755
edit
dl
rm
visudo
223432
0755
edit
dl
rm
wipefs
47336
0755
edit
dl
rm
wpa_action
1735
0755
edit
dl
rm
wpa_cli
155872
0755
edit
dl
rm
wpa_supplicant
2901328
0755
edit
dl
rm
xtables-legacy-multi
99296
0755
edit
dl
rm
xtables-monitor
220488
0755
edit
dl
rm
xtables-nft-multi
220488
0755
edit
dl
rm
zic
63784
0755
edit
dl
rm
zramctl
117088
0755
edit
dl
rm
Edit:
/snap/core20/2769/usr/sbin/e2scrub
(7296B)
#!/bin/bash # Copyright (C) 2018 Oracle. All Rights Reserved. # # Author: Darrick J. Wong <darrick.wong@oracle.com> # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it would be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write the Free Software Foundation, # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. # Automatically check an LVM-managed filesystem online. # We use lvm snapshots to do this, which means that we can only # check filesystems in VGs that have at least 256MB (or so) of # free space. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin if (( $EUID != 0 )); then echo "e2scrub must be run as root" exit 1 fi snap_size_mb=256 fstrim=0 reap=0 e2fsck_opts="" conffile="/etc/e2scrub.conf" test -f "${conffile}" && . "${conffile}" print_help() { echo "Usage: $0 [OPTIONS] mountpoint | device" echo echo "mountpoint must be on an LVM-managed block device" echo "-n: Show what commands e2scrub would execute." echo "-r: Remove e2scrub snapshot and exit, do not check anything." echo "-t: Run fstrim if successful." echo "-V: Print version information and exit." } print_version() { echo "e2scrub 1.45.5 (07-Jan-2020)" } exitcode() { ret="$1" # If we're being run as a service, the return code must fit the LSB # init script action error guidelines, which is to say that we # compress all errors to 1 ("generic or unspecified error", LSB 5.0 # section 22.2) and hope the admin will scan the log for what # actually happened. # We have to sleep 2 seconds here because journald uses the pid to # connect our log messages to the systemd service. This is critical # for capturing all the log messages if the scrub fails, because the # fail service uses the service name to gather log messages for the # error report. if [ -n "${SERVICE_MODE}" -a "${ret}" -ne 0 ]; then test "${ret}" -ne 0 && ret=1 sleep 2 fi exit "${ret}" } while getopts "nrtV" opt; do case "${opt}" in "n") DBG="echo Would execute: " ;; "r") reap=1;; "t") fstrim=1;; "V") print_version; exitcode 0;; *) print_help; exitcode 2;; esac done shift "$((OPTIND - 1))" arg="$1" if [ -z "${arg}" ]; then print_help exitcode 1 fi if ! type lsblk >& /dev/null ; then echo "e2scrub: can't find lsblk --- is util-linux installed?" exitcode 1 fi if ! type lvcreate >& /dev/null ; then echo "e2scrub: can't find lvcreate --- is lvm2 installed?" exitcode 1 fi # close file descriptor 3 (from cron) since it causes lvm to kvetch exec 3<&- # Find the device for a given mountpoint dev_from_mount() { local mountpt="$(realpath "$1")" lsblk -o NAME,FSTYPE,MOUNTPOINT -p -P -n 2> /dev/null | while read vars; do eval "${vars}" if [ "${mountpt}" != "${MOUNTPOINT}" ]; then continue fi case "${FSTYPE}" in ext[234]) echo "${NAME}" return 0 ;; esac done return 1 } # Check a device argument dev_from_arg() { local dev="$1" local fstype="$(lsblk -o FSTYPE -n "${dev}" 2> /dev/null)" case "${fstype}" in ext[234]) echo "${dev}" return 0 ;; esac return 1 } mnt_from_dev() { local dev="$1" if [ -n "${dev}" ]; then lsblk -o MOUNTPOINT -n "${dev}" fi } # Construct block device path and mountpoint from argument if [ -b "${arg}" ]; then dev="$(dev_from_arg "${arg}")" mnt="$(mnt_from_dev "${dev}")" else dev="$(dev_from_mount "${arg}")" mnt="${arg}" fi if [ ! -e "${dev}" ]; then echo "${arg}: Not an ext[234] filesystem." print_help exitcode 16 fi # Make sure this is an LVM device we can snapshot lvm_vars="$(lvs --nameprefixes -o name,vgname,lv_role --noheadings "${dev}" 2> /dev/null)" eval "${lvm_vars}" if [ -z "${LVM2_VG_NAME}" ] || [ -z "${LVM2_LV_NAME}" ] || echo "${LVM2_LV_ROLE}" | grep -q "snapshot"; then echo "${arg}: Not connnected to an LVM logical volume." print_help exitcode 16 fi start_time="$(date +'%Y%m%d%H%M%S')" snap="${LVM2_LV_NAME}.e2scrub" snap_dev="/dev/${LVM2_VG_NAME}/${snap}" teardown() { # Remove and wait for removal to succeed. ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}" while [ -e "${snap_dev}" ] && [ "$?" -eq "5" ]; do sleep 0.5 ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}" done } check() { # First we recover the journal, then we see if e2fsck tries any # non-optimization repairs. If either of these two returns a # non-zero status (errors fixed or remaining) then this fs is bad. E2FSCK_FIXES_ONLY=1 export E2FSCK_FIXES_ONLY ${DBG} "/sbin/e2fsck" -E journal_only -p ${e2fsck_opts} "${snap_dev}" || return $? ${DBG} "/sbin/e2fsck" -f -y ${e2fsck_opts} "${snap_dev}" } mark_clean() { ${DBG} "/sbin/tune2fs" -C 0 -T "${start_time}" "${dev}" } mark_corrupt() { ${DBG} "/sbin/tune2fs" -E force_fsck "${dev}" } setup() { # Try to remove snapshot for 30s, bail out if we can't remove it. lvremove_deadline="$(( $(date "+%s") + 30))" ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}" 2>/dev/null while [ -e "${snap_dev}" ] && [ "$?" -eq "5" ] && [ "$(date "+%s")" -lt "${lvremove_deadline}" ]; do sleep 0.5 ${DBG} lvremove -f "${LVM2_VG_NAME}/${snap}" done if [ -e "${snap_dev}" ]; then echo "${arg}: e2scrub snapshot is in use, cannot check!" return 1 fi # Create the snapshot, wait for device to appear. ${DBG} lvcreate -s -L "${snap_size_mb}m" -n "${snap}" "${LVM2_VG_NAME}/${LVM2_LV_NAME}" if [ $? -ne 0 ]; then echo "${arg}: e2scrub snapshot FAILED, will not check!" return 1 fi ${DBG} udevadm settle 2> /dev/null return 0 } if [ "${reap}" -gt 0 ]; then if [ -e "${snap_dev}" ]; then teardown 2> /dev/null fi exit 0 fi if ! setup; then exitcode 8 fi trap "teardown; exit 1" EXIT INT QUIT TERM # Check and react check case "$?" in "0") # Clean check! echo "${arg}: Scrub succeeded." mark_clean teardown trap '' EXIT # Trim the free space, which requires the snapshot be deleted. if [ "${fstrim}" -eq 1 ] && [ -d "${mnt}" ] && type fstrim > /dev/null 2>&1; then echo "${arg}: Trimming free space." fstrim -v "${mnt}" fi ret=0 ;; "8") # Operational error, what now? echo "${arg}: e2fsck operational error." teardown trap '' EXIT ret=8 ;; *) # fsck failed. Check if the snapshot is invalid; if so, make a # note of that at the end of the log. This isn't necessarily a # failure because the mounted fs could have overflowed the # snapshot with regular disk writes /or/ our repair process # could have done it by repairing too much. # # If it's really corrupt we ought to fsck at next boot. is_invalid="$(lvs -o lv_snapshot_invalid --noheadings "${snap_dev}" | awk '{print $1}')" if [ -n "${is_invalid}" ]; then echo "${arg}: Scrub FAILED due to invalid snapshot." ret=8 else echo "${arg}: Scrub FAILED due to corruption! Unmount and run e2fsck -y." mark_corrupt ret=6 fi teardown trap '' EXIT ;; esac exitcode "${ret}"
Save
cmd:
run