From da00200e9783a20a975ca62e3450fd7db316f877 Mon Sep 17 00:00:00 2001 From: Praveen Kumar Date: Wed, 13 Nov 2019 12:19:06 +0530 Subject: [PATCH] Issue #129 Workaround for virt-sparsify to work with immutable partition 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 --- createdisk.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/createdisk.sh b/createdisk.sh index 7a7406d9..b57b3be9 100755 --- a/createdisk.sh +++ b/createdisk.sh @@ -61,6 +61,9 @@ 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 @@ -68,6 +71,9 @@ function create_qemu_image { 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