-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[tmpfs var/log] mount /var/log as tmpfs for some platforms #2780
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,6 +11,31 @@ case $1 in | |
;; | ||
esac | ||
|
||
set_tmpfs_log_partition_size() | ||
{ | ||
varlogsize=128 | ||
|
||
# NOTE: certain 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 | ||
[ X"$aboot_platform" = X"x86_64-arista_7050_qx32" ] && return | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
the best way to do this is to move the configuration part in device/platform/ , but this may requires more work. |
||
|
||
# set varlogsize to existing var-log.ext4 size | ||
if [ -f ${rootmnt}/host/disk-img/var-log.ext4 ]; then | ||
varlogsize=$(ls -l ${rootmnt}/host/disk-img/var-log.ext4 | awk '{print $5}') | ||
varlogsize=$(($varlogsize/1024/1024)) | ||
fi | ||
|
||
# make sure varlogsize is between 5% to 10% of total memory size | ||
memkb=$(grep MemTotal /proc/meminfo | awk '{print $2}') | ||
memmb=$(($memkb/1024)) | ||
minsize=$(($memmb*5/100)) | ||
maxsize=$(($memmb*10/100)) | ||
|
||
[ $minsize -ge $varlogsize ] && varlogsize=$minsize | ||
[ $maxsize -le $varlogsize ] && varlogsize=$maxsize | ||
} | ||
|
||
## Mount the overlay file system: rw layer over squashfs | ||
image_dir=$(cat /proc/cmdline | sed -e 's/.*loop=\(\S*\)\/.*/\1/') | ||
mkdir -p ${rootmnt}/host/$image_dir/rw | ||
|
@@ -26,5 +51,16 @@ mount --bind ${rootmnt}/host/$image_dir/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/do | |
## Mount the boot directory in the raw partition, bypass the overlay | ||
mkdir -p ${rootmnt}/boot | ||
mount --bind ${rootmnt}/host/$image_dir/boot ${rootmnt}/boot | ||
## Mount loop device for /var/log | ||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log | ||
## Mount loop device or tmpfs for /var/log | ||
onie_platform="" | ||
aboot_platform="" | ||
. ${rootmnt}/host/machine.conf | ||
if [ X"$aboot_platform" = X"x86_64-arista_7050_qx32" ] || | ||
[ X"$aboot_platform" = X"x86_64-arista_7050_qx32s" ] | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same comment as above: Can we extend this to the 7060-CX32 and CX32S as well? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we need more time for this change, because:
That doesn't mean that we won't add 7060 to the list. It just mean that we would like to have a discussion, if we decide to proceed, then we need to test it before putting up change for review. Are you ok with this change go in as infrastructural change first and improve later? :-) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, do the merge I can contribute the change later. both platforms come from the same lineage, I have both in my network and both show the same symptoms There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @MichelMoriniaux ! |
||
then | ||
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 | ||
else | ||
[ -f ${rootmnt}/host/disk-img/var-log.ext4 ] && mount -t ext4 -o loop,rw ${rootmnt}/host/disk-img/var-log.ext4 ${rootmnt}/var/log | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we extend this to the 7060-CX32 and CX32s as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Return here would cause small /var/log partition of 128M, are you sure you want 7060 here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
128M is already large IMHO so OK for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
:-)
I looked at a device. I think we currently mount /var/log for 380M in loop file system. With the 5% to 10% adjustment will mount tmpfs of 512M. That doesn't sound too bad to me.