Reduce the disk space taken up during bootup and runtime.
1. Remove python package cache from the base image and from the containers.
2. During bootup, if logs are to be stored in memory, then don't create the `var-log.ext4` file just to delete it later during bootup.
3. For the partition containing `/host`, don't reserve any blocks for just the root user. This just makes sure all disk space is available for all users, if needed during upgrades (for example).
* Remove pip2 and pip3 caches from some containers
Only containers which appeared to have a significant pip cache size are
included here.
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
* Don't create var-log.ext4 if we're storing logs in memory
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
* Run tune2fs on the device containing /host to not reserve any blocks for just the root user
Signed-off-by: Saikrishna Arcot <sarcot@microsoft.com>
(cherry picked from commit 5617b1ae3e
)
This commit is contained in:
parent
308ecbb89c
commit
e9db38594d
@ -121,7 +121,7 @@ RUN apt-get -y purge \
|
||||
RUN apt-get clean -y && \
|
||||
apt-get autoclean -y && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf /var/lib/apt/lists/* /tmp/*
|
||||
rm -rf /var/lib/apt/lists/* /tmp/* ~/.cache/
|
||||
|
||||
COPY ["etc/rsyslog.conf", "/etc/rsyslog.conf"]
|
||||
COPY ["etc/rsyslog.d/*", "/etc/rsyslog.d/"]
|
||||
|
@ -49,4 +49,4 @@ RUN apt-get purge -y \
|
||||
apt-get clean -y && \
|
||||
apt-get autoclean -y && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf /debs /python-wheels
|
||||
rm -rf /debs /python-wheels ~/.cache
|
||||
|
@ -63,7 +63,7 @@ RUN apt-get purge -y \
|
||||
apt-get clean -y && \
|
||||
apt-get autoclean -y && \
|
||||
apt-get autoremove -y && \
|
||||
rm -rf /debs
|
||||
rm -rf /debs ~/.cache
|
||||
|
||||
COPY ["files/arp_update", "/usr/bin"]
|
||||
COPY ["arp_update.conf", "files/arp_update_vars.j2", "/usr/share/sonic/templates/"]
|
||||
|
@ -51,6 +51,6 @@ RUN apt-get purge -y python-dev
|
||||
|
||||
RUN apt-get remove -y g++ python3-dev
|
||||
RUN apt-get clean -y; apt-get autoclean -y; apt-get autoremove -y
|
||||
RUN rm -rf /debs
|
||||
RUN rm -rf /debs ~/.cache
|
||||
|
||||
ENTRYPOINT ["/usr/local/bin/supervisord"]
|
||||
|
@ -351,7 +351,12 @@ extract_image() {
|
||||
unzip -oq "$swipath" -x boot0 "$dockerfs" -d "$image_path"
|
||||
|
||||
## detect rootfs type
|
||||
rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3`
|
||||
local mountstr="$(grep " $target_path " /proc/mounts)"
|
||||
local rootdev="$(echo $mountstr | cut -f1 -d' ')"
|
||||
rootfs_type="$(echo $mountstr | cut -d' ' -f3)"
|
||||
|
||||
## Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $rootdev
|
||||
|
||||
info "Extracting $dockerfs from swi"
|
||||
## Unpacking dockerfs delayed
|
||||
|
@ -11,17 +11,27 @@ case $1 in
|
||||
;;
|
||||
esac
|
||||
|
||||
logs_inram=false
|
||||
|
||||
# Extract kernel parameters
|
||||
set -- $(cat /proc/cmdline)
|
||||
for x in "$@"; do
|
||||
case "$x" in
|
||||
varlog_size=*)
|
||||
varlog_size="${x#varlog_size=}"
|
||||
;;
|
||||
logs_inram=on)
|
||||
logs_inram=true
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
[ -z "$varlog_size" ] && exit 0
|
||||
|
||||
# If logs are being stored in memory, then don't bother
|
||||
# creating the log file just to have it deleted afterwards.
|
||||
$logs_inram && exit 0
|
||||
|
||||
# exit when the var_log.ext4 exists and the size matches
|
||||
if [ -e "${rootmnt}/host/disk-img/var-log.ext4" ]; then
|
||||
cur_varlog_size=$(ls -l ${rootmnt}/host/disk-img/var-log.ext4 | awk '{print $5}')
|
||||
|
@ -117,6 +117,11 @@ elif [ "$install_env" = "sonic" ]; then
|
||||
rm -rf $f
|
||||
fi
|
||||
done
|
||||
|
||||
demo_dev=$(findmnt -n -o SOURCE --target /host)
|
||||
|
||||
# Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $demo_dev
|
||||
fi
|
||||
|
||||
# Create target directory or clean it up if exists
|
||||
|
@ -117,6 +117,11 @@ elif [ "$install_env" = "sonic" ]; then
|
||||
rm -rf $f
|
||||
fi
|
||||
done
|
||||
|
||||
demo_dev=$(findmnt -n -o SOURCE --target /host)
|
||||
|
||||
# Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $demo_dev
|
||||
fi
|
||||
|
||||
# Create target directory or clean it up if exists
|
||||
|
@ -434,6 +434,9 @@ if [ "$install_env" = "onie" ]; then
|
||||
# Make filesystem
|
||||
mkfs.ext4 -L $demo_volume_label $demo_dev
|
||||
|
||||
# Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $demo_dev
|
||||
|
||||
# Mount demo filesystem
|
||||
demo_mnt=$(${onie_bin} mktemp -d) || {
|
||||
echo "Error: Unable to create file system mount point"
|
||||
@ -466,12 +469,20 @@ elif [ "$install_env" = "sonic" ]; then
|
||||
rm -rf $f
|
||||
fi
|
||||
done
|
||||
|
||||
demo_dev=$(findmnt -n -o SOURCE --target /host)
|
||||
|
||||
# Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $demo_dev
|
||||
else
|
||||
demo_mnt="build_raw_image_mnt"
|
||||
demo_dev=$cur_wd/"%%OUTPUT_RAW_IMAGE%%"
|
||||
|
||||
mkfs.ext4 -L $demo_volume_label $demo_dev
|
||||
|
||||
# Don't reserve any blocks just for root
|
||||
tune2fs -m 0 -r 0 $demo_dev
|
||||
|
||||
echo "Mounting $demo_dev on $demo_mnt..."
|
||||
mkdir $demo_mnt
|
||||
mount -t auto -o loop $demo_dev $demo_mnt
|
||||
|
Loading…
Reference in New Issue
Block a user