[aboot]: add varlog limit file in aboot image (#487)

* [aboot]: add varlog limit file in aboot image
This commit is contained in:
lguohan 2017-04-07 15:28:30 -07:00 committed by GitHub
parent 263c1bf852
commit 1458e9ea6b
2 changed files with 31 additions and 2 deletions

View File

@ -48,7 +48,6 @@ extract_image() {
fi fi
done done
## Unzip the image ## Unzip the image
unzip -oq "$swipath" -x boot0 -d "$target_path" unzip -oq "$swipath" -x boot0 -d "$target_path"
@ -102,6 +101,8 @@ platform_specific() {
if [ "$platform" = "raven" ]; then if [ "$platform" = "raven" ]; then
aboot_machine=arista_7050_qx32 aboot_machine=arista_7050_qx32
echo "modprobe.blacklist=radeon" >>/tmp/append echo "modprobe.blacklist=radeon" >>/tmp/append
# set varlog size to 100MB
echo "varlog_size=100" >>/tmp/append
fi fi
if [ "$platform" = "crow" ]; then if [ "$platform" = "crow" ]; then
aboot_machine=arista_7050_qx32s aboot_machine=arista_7050_qx32s

View File

@ -82,6 +82,28 @@ run_cmd() {
fi fi
} }
create_varlog_file() {
local err_msg="Error: create var-log ext4 file"
local cmd="[ -n $varlog_size ] && mkdir -p $root_mnt/disk-img && dd if=/dev/zero of=$root_mnt/disk-img/var-log.ext4 count=$((2048*$varlog_size)) && mke2fs -t ext4 -q -F $root_mnt/disk-img/var-log.ext4"
run_cmd "$cmd" "$err_msg"
}
mount_and_create_varlog_file() {
[ -z "$varlog_size" ] && exit 0
mkdir -p "$root_mnt"
mount -t ext4 "$root_dev" "$root_mnt"
# exit when the var_log.ext4 exists and the size matches
if [ -e "$root_mnt/disk-img/var-log.ext4" ]; then
cur_varlog_size=$(ls -l $root_mnt/disk-img/var-log.ext4 | awk '{print $5}')
if [ $cur_varlog_size == $((1024*1024*$varlog_size)) ]; then
exit 0
fi
fi
create_varlog_file
umount "$root_mnt"
exit 0
}
# Extract kernel parameters # Extract kernel parameters
set -- $(cat /proc/cmdline) set -- $(cat /proc/cmdline)
for x in "$@"; do for x in "$@"; do
@ -91,6 +113,9 @@ for x in "$@"; do
;; ;;
Aboot=*) Aboot=*)
aboot_flag="${x#Aboot=}" aboot_flag="${x#Aboot=}"
;;
varlog_size=*)
varlog_size="${x#varlog_size=}"
esac esac
done done
root_dev="$ROOT" root_dev="$ROOT"
@ -105,8 +130,9 @@ if ! wait_for_root_dev; then
echo "Error: timeout in waiting for $root_dev" echo "Error: timeout in waiting for $root_dev"
exit 1 exit 1
fi fi
blkid | grep "$root_dev.*vfat" -q || exit 0
# mount, create varlog file and exit when the root is ext4
blkid | grep "$root_dev.*vfat" -q || mount_and_create_varlog_file
# Get flash dev name # Get flash dev name
if [ -z "$block_flash" ]; then if [ -z "$block_flash" ]; then
@ -171,3 +197,5 @@ run_cmd "$cmd" "$err_msg"
err_msg="Error: copying files form $tmp_mnt to $root_mnt failed" err_msg="Error: copying files form $tmp_mnt to $root_mnt failed"
cmd="cp -a $tmp_mnt/. $root_mnt/" cmd="cp -a $tmp_mnt/. $root_mnt/"
run_cmd "$cmd" "$err_msg" run_cmd "$cmd" "$err_msg"
create_varlog_file