[aboot]: add varlog limit file in aboot image (#487)
* [aboot]: add varlog limit file in aboot image
This commit is contained in:
parent
263c1bf852
commit
1458e9ea6b
@ -47,7 +47,6 @@ extract_image() {
|
||||
rm -rf "$target_path/$f"
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
## Unzip the image
|
||||
unzip -oq "$swipath" -x boot0 -d "$target_path"
|
||||
@ -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
|
||||
|
@ -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
|
||||
@ -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"
|
||||
@ -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
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user