Fix the fsck script that does filesystem repair (#17424) (#17621)

This commit is contained in:
mssonicbld 2023-12-26 19:58:48 +08:00 committed by GitHub
parent 8dc43a6c72
commit 690c4c5d36
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -11,15 +11,19 @@ root_val=""
set -- $(cat /proc/cmdline)
for x in "$@"; do
case "$x" in
root=UUID=*)
root_val="${x#root=UUID=}"
blkdev=$(blkid --uuid $root_val)
;;
root=*)
root_val="${x#root=}"
blkdev="${x#root=}"
;;
esac
done
# Check the filesystem we are using
if [ ! -z $root_val ]; then
fstype=$(blkid -o value -s TYPE $root_val)
if [ ! -z $blkdev ]; then
fstype=$(blkid -o value -s TYPE $blkdev)
case "$fstype" in
ext4)
cmd="fsck.ext4 -v -p"
@ -29,6 +33,6 @@ if [ ! -z $root_val ]; then
;;
esac
if [ ! -z "$cmd" ]; then
$cmd $root_val 2>&1 | gzip -c > /tmp/fsck.log.gz
$cmd $blkdev 2>&1 | gzip -c > /tmp/fsck.log.gz
fi
fi