Skip to content

Commit

Permalink
[aboot]: add varlog limit file in aboot image (#487)
Browse files Browse the repository at this point in the history
* [aboot]: add varlog limit file in aboot image
  • Loading branch information
lguohan authored Apr 7, 2017
1 parent 263c1bf commit 1458e9e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 2 deletions.
3 changes: 2 additions & 1 deletion files/Aboot/boot0.j2
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ extract_image() {
rm -rf "$target_path/$f"
fi
done


## Unzip the image
unzip -oq "$swipath" -x boot0 -d "$target_path"
Expand Down Expand Up @@ -102,6 +101,8 @@ platform_specific() {
if [ "$platform" = "raven" ]; then
aboot_machine=arista_7050_qx32
echo "modprobe.blacklist=radeon" >>/tmp/append
# set varlog size to 100MB
echo "varlog_size=100" >>/tmp/append
fi
if [ "$platform" = "crow" ]; then
aboot_machine=arista_7050_qx32s
Expand Down
30 changes: 29 additions & 1 deletion files/initramfs-tools/arista-convertfs.j2
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,28 @@ run_cmd() {
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
set -- $(cat /proc/cmdline)
for x in "$@"; do
Expand All @@ -91,6 +113,9 @@ for x in "$@"; do
;;
Aboot=*)
aboot_flag="${x#Aboot=}"
;;
varlog_size=*)
varlog_size="${x#varlog_size=}"
esac
done
root_dev="$ROOT"
Expand All @@ -105,8 +130,9 @@ if ! wait_for_root_dev; then
echo "Error: timeout in waiting for $root_dev"
exit 1
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
if [ -z "$block_flash" ]; then
Expand Down Expand Up @@ -171,3 +197,5 @@ run_cmd "$cmd" "$err_msg"
err_msg="Error: copying files form $tmp_mnt to $root_mnt failed"
cmd="cp -a $tmp_mnt/. $root_mnt/"
run_cmd "$cmd" "$err_msg"

create_varlog_file

0 comments on commit 1458e9e

Please sign in to comment.