Skip to content

Commit

Permalink
Issue #129 Workaround for virt-sparsify to work with immutable partition
Browse files Browse the repository at this point in the history
With OpenShift-4.3 the rh-coreos image failed during sparsify because of
the immutable attribute set for /dev/sda4 partition. Need to use guestfish
to remove it and run the virt-sparsify and then apply back.

- https://bugzilla.redhat.com/show_bug.cgi?id=1771257
  • Loading branch information
praveenkumar committed Nov 14, 2019
1 parent bfbbee0 commit da00200
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions createdisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,19 @@ function create_qemu_image {
exit 1
fi

# Remove immutable attribute for OpenShift 4.3+
guestfish -a $destDir/${CRC_VM_NAME}.qcow2 -m /dev/sda4 set-e2attrs / i clear:true

# TMPDIR must point at a directory with as much free space as the size of the image we want to sparsify
# Read limitation section of `man virt-sparsify`.
TMPDIR=$(pwd)/$destDir ${VIRT_SPARSIFY} -o lazy_refcounts=on $destDir/${CRC_VM_NAME}.qcow2 $destDir/${CRC_VM_NAME}_sparse.qcow2
rm -f $destDir/${CRC_VM_NAME}.qcow2
mv $destDir/${CRC_VM_NAME}_sparse.qcow2 $destDir/${CRC_VM_NAME}.qcow2
rm -fr $destDir/.guestfs-*

# Set immutable attribute back for /dev/sda4
guestfish -a $destDir/${CRC_VM_NAME}.qcow2 -m /dev/sda4 set-e2attrs / i

# Before using the created qcow2, check if it has lazy_refcounts set to true.
${QEMU_IMG} info ${destDir}/${CRC_VM_NAME}.qcow2 | grep "lazy refcounts: true" 2>&1 >/dev/null
if [ $? -ne 0 ]; then
Expand Down

0 comments on commit da00200

Please sign in to comment.