diff --git a/files/Aboot/boot0.j2 b/files/Aboot/boot0.j2 index 64b1414fc187..1d8d3547d7ab 100644 --- a/files/Aboot/boot0.j2 +++ b/files/Aboot/boot0.j2 @@ -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" diff --git a/files/initramfs-tools/arista-convertfs.j2 b/files/initramfs-tools/arista-convertfs.j2 index 2ed51c02203f..535bb441f117 100644 --- a/files/initramfs-tools/arista-convertfs.j2 +++ b/files/initramfs-tools/arista-convertfs.j2 @@ -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/" diff --git a/files/initramfs-tools/union-mount.j2 b/files/initramfs-tools/union-mount.j2 index 4a0863c42a6d..f6f1deff4220 100644 --- a/files/initramfs-tools/union-mount.j2 +++ b/files/initramfs-tools/union-mount.j2 @@ -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 diff --git a/installer/x86_64/install.sh b/installer/x86_64/install.sh index 680e5c5f3297..2cd579e28b29 100755 --- a/installer/x86_64/install.sh +++ b/installer/x86_64/install.sh @@ -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 diff --git a/onie-image.conf b/onie-image.conf index 868a2aa52331..db99c867de04 100644 --- a/onie-image.conf +++ b/onie-image.conf @@ -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