[aboot] use ram partition for /var/log for devices with 3.7G disks (#8400)
Master/202012 image size grew quite a bit. 3.7G harddrive can no longer hold one image and safely upgrade to another image. Every bit of harddrive space is precious to save now. Also sh syntax seemingly changed, [ condition ] && action was a legit syntax in 201911 branch but it is an error when condition not met with 202012 or later images. Change the syntax to if statement to avoid the issue. Signed-off-by: Ying Xie ying.xie@microsoft.com
This commit is contained in:
parent
5ed6b64c99
commit
92fb9c94bd
@ -591,12 +591,16 @@ write_platform_specific_cmdline() {
|
||||
|
||||
if [ $flash_size -ge 28000 ]; then
|
||||
varlog_size=4096
|
||||
elif [ $flash_size -ge 3700 ]; then
|
||||
elif [ $flash_size -gt 3700 ]; then
|
||||
varlog_size=400
|
||||
elif [ $flash_size -le 2000 ]; then
|
||||
# enable docker_inram for switches with less than 2G of flash
|
||||
cmdline_add docker_inram=on
|
||||
else
|
||||
varlog_size=256
|
||||
cmdline_add logs_inram=on
|
||||
if [ $flash_size -le 2000 ]; then
|
||||
# enable docker_inram for switches with less than 2G of flash
|
||||
varlog_size=128
|
||||
cmdline_add docker_inram=on
|
||||
fi
|
||||
fi
|
||||
|
||||
cmdline_add "varlog_size=$varlog_size"
|
||||
|
@ -15,6 +15,7 @@ docker_inram=false
|
||||
logs_inram=false
|
||||
secureboot=false
|
||||
bootloader=generic
|
||||
varlog_size=0
|
||||
|
||||
# Extract kernel parameters
|
||||
for x in $(cat /proc/cmdline); do
|
||||
@ -28,6 +29,9 @@ for x in $(cat /proc/cmdline); do
|
||||
logs_inram=on)
|
||||
logs_inram=true
|
||||
;;
|
||||
varlog_size=*)
|
||||
varlog_size="${x#varlog_size=}"
|
||||
;;
|
||||
secure_boot_enable=[y1])
|
||||
secureboot=true
|
||||
docker_inram=true
|
||||
@ -40,6 +44,10 @@ done
|
||||
|
||||
set_tmpfs_log_partition_size()
|
||||
{
|
||||
if [ $varlog_size -gt 0 ]; then
|
||||
# Use the varlog_size passed in from command line
|
||||
varlogsize=$varlog_size
|
||||
else
|
||||
varlogsize=128
|
||||
|
||||
# set varlogsize to existing var-log.ext4 size
|
||||
@ -47,6 +55,7 @@ set_tmpfs_log_partition_size()
|
||||
varlogsize=$(ls -l ${rootmnt}/host/disk-img/var-log.ext4 | awk '{print $5}')
|
||||
varlogsize=$(($varlogsize/1024/1024))
|
||||
fi
|
||||
fi
|
||||
|
||||
# make sure varlogsize is between 5% to 10% of total memory size
|
||||
memkb=$(grep MemTotal /proc/meminfo | awk '{print $2}')
|
||||
@ -54,8 +63,12 @@ set_tmpfs_log_partition_size()
|
||||
minsize=$(($memmb*5/100))
|
||||
maxsize=$(($memmb*10/100))
|
||||
|
||||
[ $minsize -ge $varlogsize ] && varlogsize=$minsize
|
||||
[ $maxsize -le $varlogsize ] && varlogsize=$maxsize
|
||||
if [ $minsize -ge $varlogsize ]; then
|
||||
varlogsize=$minsize
|
||||
fi
|
||||
if [ $maxsize -le $varlogsize ]; then
|
||||
varlogsize=$maxsize
|
||||
fi
|
||||
}
|
||||
|
||||
remove_not_in_allowlist_files()
|
||||
@ -147,14 +160,23 @@ mount --bind ${rootmnt}/host/$image_dir/boot ${rootmnt}/boot
|
||||
if $logs_inram; then
|
||||
# NOTE: some platforms, when reaching initramfs stage, have a small
|
||||
# limit of mounting tmpfs partition, potentially due to amount
|
||||
# of RAM available in this stage. e.g. Arista 7050-qx32[s] and 7060-cx32s
|
||||
# of RAM available in this stage. Therefore limiting the size
|
||||
# set for tmpfs partitions.
|
||||
#
|
||||
# Another reason for using tmpfs /var/log partition is:
|
||||
# Some platforms have a small flash and therefore the log partition takes valuable space.
|
||||
# To improve the longevity of these devices storing the logs in memory will permit more
|
||||
# SONiC image growth before being bottlenecked.
|
||||
set_tmpfs_log_partition_size
|
||||
mount -t tmpfs -o rw,nosuid,nodev,size=${varlogsize}M tmpfs ${rootmnt}/var/log
|
||||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && rm -rf ${rootmnt}/host/disk-img/var-log.ext4
|
||||
if [ -f ${rootmnt}/host/disk-img/var-log.ext4 ]; then
|
||||
rm -rf ${rootmnt}/host/disk-img/var-log.ext4
|
||||
fi
|
||||
else
|
||||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && fsck.ext4 -v -p ${rootmnt}/host/disk-img/var-log.ext4 2>&1 \
|
||||
| gzip -c >> /tmp/fsck.log.gz
|
||||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log
|
||||
if [ -f ${rootmnt}/host/disk-img/var-log.ext4 ]; then
|
||||
fsck.ext4 -v -p ${rootmnt}/host/disk-img/var-log.ext4 2>&1 | gzip -c >> /tmp/fsck.log.gz
|
||||
mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log
|
||||
fi
|
||||
fi
|
||||
|
||||
## fscklog file: /tmp will be lost when overlayfs is mounted
|
||||
|
Loading…
Reference in New Issue
Block a user