sonic-buildimage/files/initramfs-tools/resize-rootfs
padmanarayana 0d0752e099 Reduce SONiC migration partition from 8G to 1G. (#1343)
* Reduce SONiC migration partition from 8G to 1G.

* Changes to create 1G partition with ability to resize post migration.

* Remove redundant changes in varlog

* Use findfs to interpret root. Move resize in case cmdline params are reordered
2018-02-07 22:07:01 +08:00

40 lines
796 B
Bash

#!/bin/sh
case $1 in
prereqs)
exit 0
;;
esac
# Extract kernel parameters
set -- $(cat /proc/cmdline)
for x in "$@"; do
case "$x" in
root=*)
root_val="${x#root=}"
;;
resize-rootfs)
need_resize=1
;;
esac
done
if [ -n "$need_resize" ]; then
if [ -z "$root_val" ]; then
echo "ERROR: resize required but unable to get root location from command line"
exit 1
fi
root_dev=$(findfs $root_val)
if [ $? != 0 ]; then
echo "ERROR: resize required but findfs failed"
exit 1
fi
resize2fs -f $root_dev
if [ $? != 0 ]; then
echo "ERROR: Unable to resize the root file system. Manual intervention needed to fix the issue."
exit 1
fi
fi