Skip to content

Commit

Permalink
Fix the fsck script that does filesystem repair (#17424)
Browse files Browse the repository at this point in the history
Fix the fsck check which is not working. Potentially fixes #16938
Modified fsck script to run on the ext4.fsck on the appropriate disk where SONiC resides

Microsoft ADO: 26098631
  • Loading branch information
prgeor committed Dec 20, 2023
1 parent 050420f commit 30ff773
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions files/initramfs-tools/fsck-rootfs
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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

0 comments on commit 30ff773

Please sign in to comment.