Skip to content

Commit

Permalink
Support for updating tmpfs size according to Image size (#7484)
Browse files Browse the repository at this point in the history
#### Why I did it
while sonic upgrade, Image will be extracted to tmpfs for installation so tmpfs size should be larger than image size. Image installation will fail if image size is larger than tmpfs size.

we are facing below error while installing debug image with size greater than tmpfs which is 1.5g in marvell armhf platform.

sonic-installer install <url>
New image will be installed, continue? [y/N]: y
Downloading image...
...99%, 1744 MB, 708 KB/s, 0 seconds left...
Installing image SONiC-OS-202012.0-dirty-20210311.224845 and setting it as default...
Command: bash /tmp/sonic_image
tar: installer/fs.zip: Wrote only 7680 of 10240 bytes
tar: installer/onie-image-arm64.conf: Cannot write: No space left on device
tar: Exiting with failure status due to previous errors
Verifying image checksum ... OK.
Preparing image archive ...

#### How I did it
compare downloaded image size with tmpfs size, if size less than image size update the tmpfs size according to image size.

#### How to verify it
Install an Image with size larger than tmpfs. we verified by installing debug image with size 1.9gb which is larger than tmpfs size 1.5gb.
  • Loading branch information
lkunjumon authored and qiluo-msft committed Sep 13, 2021
1 parent 70b9ea5 commit 75cc701
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions installer/sharch_body.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,23 @@ fi

echo " OK."

image_size_in_kb=$((($(sed -e '1,/^exit_marker$/d' "$0" | tar --to-stdout -xf - | wc -c) + 1023 ) / 1024))
# 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_in_kb=$(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_in_kb" -le "$((image_size_in_kb + padding))" ]; then
image_size_in_mb=$(((image_size_in_kb + 1023) / 1024))
#Adding extra 32MB free space for image extraction.
mount_size_in_mb=$((((image_size_in_mb + 31) / 32) * 32))
mount -o remount,size="${mount_size_in_mb}M" -t tmpfs tmpfs-installer $tmp_dir || exit 1
fi
fi
cd $tmp_dir
echo -n "Preparing image archive ..."
Expand Down

0 comments on commit 75cc701

Please sign in to comment.