Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/cmdlib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,13 @@ prepare_build() {
if ! [ -d builds ]; then
fatal "No $(pwd)/builds found; did you run coreos-assembler init?"
elif ! has_privileges; then
if [ ! -f cache/cache.qcow2 ]; then
qemu-img create -f qcow2 cache/cache.qcow2 10G
LIBGUESTFS_BACKEND=direct virt-format --filesystem=xfs -a cache/cache.qcow2
# "cache2" has an explicit label so we can find it in qemu easily
if [ ! -f cache/cache2.qcow2 ]; then
qemu-img create -f qcow2 cache/cache2.qcow2 10G
LIBGUESTFS_BACKEND=direct virt-format --filesystem=xfs --label=cosa-cache -a cache/cache2.qcow2
fi
# And remove the old one
rm -vf cache/cache.qcow2
fi

workdir="$(pwd)"
Expand Down Expand Up @@ -471,7 +474,7 @@ $(cat "${DIR}"/supermin-init-prelude.sh)
rc=0
sh ${TMPDIR}/cmd.sh || rc=\$?
echo \$rc > ${workdir}/tmp/rc
if [ -b /dev/sdb1 ]; then
if [ -n "\${cachedev}" ]; then
/sbin/fstrim -v ${workdir}/cache
fi
/sbin/reboot -f
Expand All @@ -483,8 +486,8 @@ EOF
echo "$@" > "${TMPDIR}"/cmd.sh

cachedisk=()
if [ -f "${workdir}/cache/cache.qcow2" ]; then
cachedisk=("-drive" "if=none,id=drive-scsi0-0-0-1,discard=unmap,file=${workdir}/cache/cache.qcow2" \
if [ -f "${workdir}/cache/cache2.qcow2" ]; then
cachedisk=("-drive" "if=none,id=drive-scsi0-0-0-1,discard=unmap,file=${workdir}/cache/cache2.qcow2" \
"-device" "scsi-hd,bus=scsi0.0,channel=0,scsi-id=0,lun=1,drive=drive-scsi0-0-0-1,id=scsi0-0-0-1")
fi

Expand Down
7 changes: 5 additions & 2 deletions src/supermin-init-prelude.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ if [ -L "${workdir}"/src/config ]; then
mount -t 9p -o rw,trans=virtio,version=9p2000.L source "${workdir}"/src/config
fi
mkdir -p "${workdir}"/cache /host/container-work
if [ -b /dev/sdb1 ]; then
mount /dev/sdb1 "${workdir}"/cache
cachedev=$(blkid -lt LABEL=cosa-cache -o device)
if [ -n "${cachedev}" ]; then
mount "${cachedev}" "${workdir}"/cache
else
echo "No cosa-cache filesystem found!"
fi

if [ -f "${workdir}/tmp/supermin/supermin.env" ]; then
Expand Down