Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #129 Workaround for virt-sparsify to work with immutable partition #130

Merged
merged 2 commits into from
Nov 14, 2019
Merged
Changes from 1 commit
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
10 changes: 9 additions & 1 deletion createdisk.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ function create_qemu_image {
${QEMU_IMG} rebase -b ${VM_PREFIX}-base $destDir/${VM_PREFIX}-master-0
${QEMU_IMG} commit $destDir/${VM_PREFIX}-master-0

# Check which partition is labeled as `root`
partition=$(${VIRT_FILESYSTEMS} -a $destDir/${VM_PREFIX}-base -l | grep root | cut -f1 -d' ')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awk could be used instead of cut, both are fine with me.


# Resize the image from the default 1+15GB to 1+30GB
${QEMU_IMG} create -o lazy_refcounts=on -f qcow2 $destDir/${CRC_VM_NAME}.qcow2 31G
${VIRT_RESIZE} --expand /dev/sda3 $destDir/${VM_PREFIX}-base $destDir/${CRC_VM_NAME}.qcow2
${VIRT_RESIZE} --expand $partition $destDir/${VM_PREFIX}-base $destDir/${CRC_VM_NAME}.qcow2
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The other commit fixes an issue where /dev/sda4 is immutable with openshift 4.3. Can we write to that partition after the cluster is setup? Otherwise, it's not really useful to grow it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Misunderstanding on my side of how the 'i' attribute works, it's only set on the 'root' directory of the /dev/sda4 partition, so we cannot write to that dir. However, it's not recursive, so this does not impact any of its subdirectories which do not have that bit set. So this is not going to be an issue.

if [ $? -ne 0 ]; then
echo "${VIRT_RESIZE} call failed, disk image was not properly resized, aborting"
exit 1
Expand Down Expand Up @@ -192,6 +195,7 @@ JQ=${JQ:-jq}
VIRT_RESIZE=${VIRT_RESIZE:-virt-resize}
QEMU_IMG=${QEMU_IMG:-qemu-img}
VIRT_SPARSIFY=${VIRT_SPARSIFY:-virt-sparsify}
VIRT_FILESYSTEMS=${VIRT_FILESYSTEMS:-virt-filesystems}

if [[ $# -ne 1 ]]; then
echo "You need to provide the running cluster directory to copy kubeconfig"
Expand All @@ -206,6 +210,10 @@ if ! which ${VIRT_RESIZE}; then
sudo yum -y install /usr/bin/virt-resize libguestfs-xfs
fi

if ! which ${VIRT_FILESYSTEMS}; then
sudo yum -y install /usr/bin/virt-filesystems
fi

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's in the same package as virt-resize, so most of the time this will be skipped.

# The CoreOS image uses an XFS filesystem
# Beware than if you are running on an el7 system, you won't be able
# to resize the crc VM XFS filesystem as it was created on el8
Expand Down