Skip to content

Commit

Permalink
compress image using zstd and decompress during stream disk
Browse files Browse the repository at this point in the history
  • Loading branch information
ibrokethecloud authored and guangbochen committed Jul 6, 2023
1 parent 94bcf3d commit 4412f86
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion package/harvester-os/files/usr/sbin/stream-disk
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ update_boot_args()
}

echo "writing image to disk"
curl --retry 5 --no-buffer -k ${HARVESTER_RAW_DISK_IMAGE_PATH} | dd of=${HARVESTER_DEVICE} bs=1M
curl --retry 5 --no-buffer -k ${HARVESTER_RAW_DISK_IMAGE_PATH} | zstd -d -T4 | dd of=${HARVESTER_DEVICE} bs=1M iflag=fullblock oflag=direct
echo -e "w" | fdisk ${HARVESTER_DEVICE}
partprobe ${HARVESTER_DEVICE}

# if config_url is set then stream this to userdata.yaml as installer will load it on next boot
echo "checking and writing userdata"
Expand Down
4 changes: 2 additions & 2 deletions scripts/package-harvester-os
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ if [ "${BUILD_QCOW}" == "true" ]; then
qemu-img create -f raw -o size=250G ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.raw
qemu-system-x86_64 --enable-kvm -nographic -cpu host -smp cores=2,threads=2,sockets=1 -m 8192 -serial mon:stdio -serial file:harvester-installer.log -nic none -drive file=${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.raw,if=virtio,cache=writeback,discard=ignore,format=raw -boot d -cdrom ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.iso -kernel ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-vmlinuz-amd64 -append "cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.ram=1 rd.live.squashimg=rootfs.squashfs console=ttyS1 rd.cos.disable net.ifnames=1 harvester.install.mode=install harvester.install.device=/dev/vda harvester.install.automatic=true harvester.install.powerOff=true harvester.os.password=rancher harvester.scheme_version=1 harvester.install.persistentPartitionSize=150Gi" -initrd ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-initrd-amd64 -boot once=d
tail -100 harvester-installer.log
echo "converting qcow2 to raw image"
qemu-img convert -f raw -O qcow2 ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.raw ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.qcow2
echo "compressing raw image"
zstd -T4 --rm ${ARTIFACTS_DIR}/${PROJECT_PREFIX}-amd64.raw
fi

# Write checksum
Expand Down

0 comments on commit 4412f86

Please sign in to comment.