[build]: enable docker in ram option for small disk device (#3279)
when device disk is small, do not unzip dockerfs.tar.gz on disk. keep the tar file on the disk, unzip to tmpfs in the initrd phase. enabled this for 7050-qx32 Signed-off-by: Guohan Lu <gulv@microsoft.com>
This commit is contained in:
parent
629688b487
commit
2b28d55853
@ -164,8 +164,10 @@ extract_image() {
|
||||
rootfs_type=`grep " $target_path " /proc/mounts | cut -d' ' -f3`
|
||||
|
||||
info "Extracting $dockerfs from swi"
|
||||
## vfat does not support symbol link
|
||||
if [ "$rootfs_type" != "vfat" ]; then
|
||||
## Unpacking dockerfs delayed
|
||||
## 1. when disk is vfat as it does not support symbolic link
|
||||
## 2. when disk is small, expand it into ramfs during initrd
|
||||
if [ "$rootfs_type" != "vfat" -a x"$docker_inram" != x"on" ]; then
|
||||
mkdir -p "$image_path/{{ DOCKERFS_DIR }}"
|
||||
|
||||
if [ -n "$install" ]; then
|
||||
@ -177,7 +179,7 @@ extract_image() {
|
||||
else
|
||||
## save dockerfs archive in the image directory
|
||||
unzip -oq "$swipath" "$dockerfs" -d "$image_path"
|
||||
info "Unpacking $dockerfs delayed to initrd because $target_path is $rootfs_type"
|
||||
info "Unpacking $dockerfs delayed to initrd because $target_path is $rootfs_type or docker_inram is on"
|
||||
fi
|
||||
|
||||
## remove installer since it's not needed anymore
|
||||
@ -225,7 +227,8 @@ platform_specific() {
|
||||
if [ "$platform" = "raven" ]; then
|
||||
aboot_machine=arista_7050_qx32
|
||||
flash_size=2000
|
||||
echo "modprobe.blacklist=radeon,sp5100_tco acpi=off" >>/tmp/append
|
||||
docker_inram=on
|
||||
echo "modprobe.blacklist=radeon,sp5100_tco acpi=off docker_inram=on" >>/tmp/append
|
||||
fi
|
||||
if [ "$platform" = "crow" ]; then
|
||||
aboot_machine=arista_7050_qx32s
|
||||
@ -343,6 +346,7 @@ write_boot_configs() {
|
||||
fi
|
||||
fi
|
||||
|
||||
mkdir -p "$image_path"
|
||||
cat /tmp/append > $cmdline_image
|
||||
[ -e ${target_path}/machine.conf ] || write_machine_config
|
||||
}
|
||||
@ -441,12 +445,12 @@ if $do_install; then
|
||||
clean_flash
|
||||
fi
|
||||
|
||||
info "Installing image under $image_path"
|
||||
extract_image
|
||||
|
||||
info "Generating boot-config, machine.conf and cmdline"
|
||||
write_boot_configs
|
||||
|
||||
info "Installing image under $image_path"
|
||||
extract_image
|
||||
|
||||
run_hooks post-install
|
||||
else
|
||||
info "Using previously installed image"
|
||||
|
@ -130,6 +130,9 @@ for x in "$@"; do
|
||||
x1="${x#loop=}"
|
||||
image_dir="${x1%/*}"
|
||||
;;
|
||||
docker_inram=*)
|
||||
docker_inram="${x#docker_inram=}"
|
||||
;;
|
||||
SONIC_BOOT_TYPE=warm*|SONIC_BOOT_TYPE=fast*)
|
||||
# Skip this script for warm-reboot and fast-reboot
|
||||
exit 0
|
||||
@ -221,9 +224,11 @@ err_msg="Error: mounting $root_dev to $root_mnt failed"
|
||||
cmd="mount -t ext4 $root_dev $root_mnt"
|
||||
run_cmd "$cmd" "$err_msg"
|
||||
|
||||
err_msg="Error: extract docker directory"
|
||||
cmd="[ -f $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }} ] && rm -rf $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && mkdir -p $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && tar xzf $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }} -C $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && rm -f $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }}"
|
||||
run_cmd "$cmd" "$err_msg"
|
||||
if [ x"$docker_inram" != x"on" ]; then
|
||||
err_msg="Error: extract docker directory"
|
||||
cmd="[ -f $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }} ] && rm -rf $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && mkdir -p $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && tar xzf $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }} -C $root_mnt/$image_dir/{{ DOCKERFS_DIR }} && rm -f $tmp_mnt/$image_dir/{{ FILESYSTEM_DOCKERFS }}"
|
||||
run_cmd "$cmd" "$err_msg"
|
||||
fi
|
||||
|
||||
err_msg="Error: copying files form $tmp_mnt to $root_mnt failed"
|
||||
cmd="cp -a $tmp_mnt/. $root_mnt/"
|
||||
|
@ -47,9 +47,17 @@ mount -n -o lowerdir=${rootmnt},upperdir=${rootmnt}/host/$image_dir/rw,workdir=$
|
||||
[ -b ${ROOT} ] || mdev -s
|
||||
## Mount the raw partition again
|
||||
mount ${ROOT} ${rootmnt}/host
|
||||
## Mount the working directory of docker engine in the raw partition, bypass the overlay
|
||||
|
||||
mkdir -p ${rootmnt}/var/lib/docker
|
||||
mount --bind ${rootmnt}/host/$image_dir/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker
|
||||
if [ -f ${rootmnt}/host/$image_dir/{{ FILESYSTEM_DOCKERFS }} ]; then
|
||||
## mount tmpfs and extract docker into it
|
||||
mount -t tmpfs -o rw,nodev,size={{ DOCKER_RAMFS_SIZE }} tmpfs ${rootmnt}/var/lib/docker
|
||||
tar xz --numeric-owner -f ${rootmnt}/host/$image_dir/{{ FILESYSTEM_DOCKERFS }} -C ${rootmnt}/var/lib/docker
|
||||
else
|
||||
## Mount the working directory of docker engine in the raw partition, bypass the overlay
|
||||
mount --bind ${rootmnt}/host/$image_dir/{{ DOCKERFS_DIR }} ${rootmnt}/var/lib/docker
|
||||
fi
|
||||
|
||||
## Mount the boot directory in the raw partition, bypass the overlay
|
||||
mkdir -p ${rootmnt}/boot
|
||||
mount --bind ${rootmnt}/host/$image_dir/boot ${rootmnt}/boot
|
||||
|
@ -479,15 +479,20 @@ else
|
||||
fi
|
||||
|
||||
# Decompress the file for the file system directly to the partition
|
||||
unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mnt/$image_dir
|
||||
|
||||
if [ "$install_env" = "onie" ]; then
|
||||
TAR_EXTRA_OPTION="--numeric-owner"
|
||||
if [ x"$docker_inram" = x"on" ]; then
|
||||
# when disk is small, keep dockerfs.tar.gz in disk, expand it into ramfs during initrd
|
||||
unzip -o $ONIE_INSTALLER_PAYLOAD -d $demo_mnt/$image_dir
|
||||
else
|
||||
TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp"
|
||||
unzip -o $ONIE_INSTALLER_PAYLOAD -x "$FILESYSTEM_DOCKERFS" -d $demo_mnt/$image_dir
|
||||
|
||||
if [ "$install_env" = "onie" ]; then
|
||||
TAR_EXTRA_OPTION="--numeric-owner"
|
||||
else
|
||||
TAR_EXTRA_OPTION="--numeric-owner --warning=no-timestamp"
|
||||
fi
|
||||
mkdir -p $demo_mnt/$image_dir/$DOCKERFS_DIR
|
||||
unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar xz $TAR_EXTRA_OPTION -f - -C $demo_mnt/$image_dir/$DOCKERFS_DIR
|
||||
fi
|
||||
mkdir -p $demo_mnt/$image_dir/$DOCKERFS_DIR
|
||||
unzip -op $ONIE_INSTALLER_PAYLOAD "$FILESYSTEM_DOCKERFS" | tar xz $TAR_EXTRA_OPTION -f - -C $demo_mnt/$image_dir/$DOCKERFS_DIR
|
||||
|
||||
if [ "$install_env" = "onie" ]; then
|
||||
# Store machine description in target file system
|
||||
|
@ -24,6 +24,9 @@ FILESYSTEM_DOCKERFS=dockerfs.tar.gz
|
||||
## docker directory on the root filesystem
|
||||
DOCKERFS_DIR=docker
|
||||
|
||||
## docker ramfs disk space
|
||||
DOCKER_RAMFS_SIZE=800M
|
||||
|
||||
## Output file name for onie installer
|
||||
OUTPUT_ONIE_IMAGE=target/sonic-$TARGET_MACHINE.bin
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user