-
Notifications
You must be signed in to change notification settings - Fork 7
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
Adding mount size #48
base: master
Are you sure you want to change the base?
Conversation
Below command will give the avialbale size of block root@localhost:/home/admin# df /tmp/tmp.C4jZJkN3bo | tail -1 | tr -s ' ' | cut -d' ' -f4 root@localhost:/home/admin# df |
installer/sharch_body.sh
Outdated
@@ -31,7 +31,8 @@ export cur_wd | |||
archive_path=$(realpath "$0") | |||
tmp_dir=$(mktemp -d) | |||
if [ "$(id -u)" = "0" ] ; then | |||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | |||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) |
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.
What is this logic for? Are you trying to take available space from tmpfs??
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.
@antony-rheneus
yes
mktemp -d
/tmp/tmp.yWbDbATGf2
root@localhost:/home/admin# df /tmp/tmp.yWbDbATGf2
Filesystem 1K-blocks Used Available Use% Mounted on
root-overlay 12147768 3606788 7900860 32% /
root@localhost:/home/admin#
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.
@antony-rheneus Updated mount size depends on image size.
[dataset] Add dataset "system uptime" into non-db client. (Marvell-OpenNOS#52) Adding new data set to query Sonic OS version. (Marvell-OpenNOS#50) [gnmi_server] Disregard EOF status for STREAM subs (Marvell-OpenNOS#48) Signed-off-by: Yong Zhao <[email protected]>
installer/sharch_body.sh
Outdated
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | ||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
if [ "$mount_size" -lt "$((image_size*3))" ]; then | ||
mount_size=$((image_size*3)) |
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.
mount size should be aligned in power of 2.
try to ceil the image_size*3 to next aligned multiple of page size.
installer/sharch_body.sh
Outdated
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
if [ "$mount_size" -lt "$((image_size*3))" ]; then | ||
#align mount_size to next power of two | ||
mount_size=$(echo $((image_size*3)) | awk '{ print 2^int(((log($1)/log(2))+ 1)) }') |
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.
Dont complicate with math logic.
Use dictionry/array, to select numbers 8,16,32,64,128
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 u change logic to
image_size=du target/sonic-marvell-armhf.bin | awk '{print $1}'
mount_size=$((((image_size*3)/1000/1000)+1))
mount -o remount,size="${mount_size}G" -t tmpfs tmpfs-installer $tmp_dir || exit 1
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.
okay
installer/sharch_body.sh
Outdated
@@ -25,13 +25,20 @@ fi | |||
|
|||
echo " OK." | |||
|
|||
image_size=$(du "$0" | awk '{print $1}') |
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 you check du returns aligned size like 8,16,32,... this would ease in getting mount size
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.
@antony-rheneus du return without aligned .
installer/sharch_body.sh
Outdated
if [ "$mount_size" -lt "$((image_size*3))" ]; then | ||
#align mount_size to next power of two | ||
mount_size=$(echo $((image_size*3)) | awk '{ print 2^int(((log($1)/log(2))+ 1)) }') | ||
mount -o remount,size="${mount_size}K" -t tmpfs tmpfs-installer $tmp_dir || exit 1 |
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.
Instead K, use G, so that calculation wud be easier
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.
@antony-rheneus changing mount_size to Gb is enough right? after mounting size is aligned .below is the mout_size in K when 4G is mounted
tmpfs-installer 4194304 0 4194304 0% /tmp/tmp.vHn5rFZYE1
installer/sharch_body.sh
Outdated
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | ||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
if [ "$mount_size" -lt "$((image_size*3))" ]; then |
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.
Does mount size is in 'KB' and as well as image_size in 'KB'?
@antony-rheneus updated the command to get actual size of compressed image. |
@radha-danda @antony-rheneus updated image_size check, can we add this check "$mount_size" -eq "$((image_size))" . |
installer/sharch_body.sh
Outdated
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | ||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
if [ "$mount_size" -lt "$((image_size))" ] || [ "$mount_size" -eq "$((image_size))" ]; then |
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.
use -le
Also
do extra padding like plus 100K free
@antony-rheneus Added padding to image size. |
installer/sharch_body.sh
Outdated
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | ||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
if [ "$mount_size" -le "$((image_size + $padding))" ]; then |
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.
declare padding before this line.
also add comment as extra space for tmp
@antony-rheneus Updated the comments. |
@antony-rheneus can use tmp_dir insted of tmp? |
# Untar and launch install script in a tmpfs | ||
cur_wd=$(pwd) | ||
export cur_wd | ||
archive_path=$(realpath "$0") | ||
tmp_dir=$(mktemp -d) | ||
if [ "$(id -u)" = "0" ] ; then | ||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | ||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
# Extra space for tmp | ||
padding=102400 |
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.
write the size value, also in the comment in KBs or MBs
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.
not adding, only checking extra space after extraction
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.
@antony-rheneus pls review the comments
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.
@antony-rheneus Please review updated commit.
installer/sharch_body.sh
Outdated
# Adding extra 100K free space for tmp_dir | ||
padding=102400 | ||
if [ "$mount_size" -le "$((image_size + padding))" ]; then | ||
mount_size=$((((image_size + padding)/1024/1024)+1)) |
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.
Here, you dont need to add at all, as already we add up 1G extra
@radha-danda pls review |
installer/sharch_body.sh
Outdated
@@ -24,6 +24,10 @@ if [ "$sha1" != "$payload_sha1" ] ; then | |||
fi | |||
|
|||
echo " OK." | |||
#Image size in KB | |||
bytes=$((($(sed -e '1,/^exit_marker$/d' "$0" | tar --to-stdout -xf - | wc -c) + 1023 ) / 1024)) |
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.
see QiLuo's change... no need to converto to KB
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.
Below is his comments,
Here it is dividing one time only with 1024, and mouting size in MB
bytes =
image_size=$((bytes + 1023) / 1024)
mount_size=$((image_size + 31) / 32) * 32
mount -o remount,size="${mount_size}M"
installer/sharch_body.sh
Outdated
@@ -24,6 +24,10 @@ if [ "$sha1" != "$payload_sha1" ] ; then | |||
fi | |||
|
|||
echo " OK." | |||
#Image size in KB | |||
bytes=$((($(sed -e '1,/^exit_marker$/d' "$0" | tar --to-stdout -xf - | wc -c) + 1023 ) / 1024)) |
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.
change variable name bytes to "image_size_in_kb"
installer/sharch_body.sh
Outdated
@@ -32,6 +36,13 @@ archive_path=$(realpath "$0") | |||
tmp_dir=$(mktemp -d) | |||
if [ "$(id -u)" = "0" ] ; then | |||
mount -t tmpfs tmpfs-installer $tmp_dir || exit 1 | |||
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) |
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.
mount_size is in KB
installer/sharch_body.sh
Outdated
mount_size=$(df $tmp_dir | tail -1 | tr -s ' ' | cut -d' ' -f4) | ||
#checking extra 100KB space in tmp_dir, after image extraction | ||
padding=102400 | ||
if [ "$mount_size" -le "$((image_size + padding))" ]; then |
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.
comparing KB and MB
No description provided.