sonic-buildimage/files/initramfs-tools/fsck-rootfs
Prince George 6b8549c3bb Fix the fsck script that does filesystem repair (#17424)
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
2024-01-30 06:32:12 +08:00

39 lines
726 B
Bash

#!/bin/sh
case $1 in
prereqs)
exit 0
;;
esac
# Extract kernel parameters
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=*)
blkdev="${x#root=}"
;;
esac
done
# Check the filesystem we are using
if [ ! -z $blkdev ]; then
fstype=$(blkid -o value -s TYPE $blkdev)
case "$fstype" in
ext4)
cmd="fsck.ext4 -v -p"
;;
ext3)
cmd="fsck.ext3 -v -p"
;;
esac
if [ ! -z "$cmd" ]; then
$cmd $blkdev 2>&1 | gzip -c > /tmp/fsck.log.gz
fi
fi