From: Luis Chamberlain <mcgrof@kernel.org>
To: Chuck Lever <cel@kernel.org>, Daniel Gomez <da.gomez@kruces.com>,
kdevops@lists.linux.dev
Cc: Luis Chamberlain <mcgrof@kernel.org>
Subject: [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize
Date: Tue, 26 Aug 2025 20:57:44 -0700 [thread overview]
Message-ID: <20250827035747.3314144-2-mcgrof@kernel.org> (raw)
In-Reply-To: <20250827035747.3314144-1-mcgrof@kernel.org>
The commit e46bf3cd54de ("guestfs: add unified LIBVIRT_IMAGE_SIZE
configuration") added disk resizing for custom images but only resized
the disk image file, not the partition inside. This resulted in VMs
having a 20GB disk but only a 2.9GB root filesystem partition, causing
out-of-space errors during kernel installation.
Add virt-resize step after qemu-img resize to expand the root partition
(/dev/sda1) to use the full disk space. This ensures VMs get the full
20GB root filesystem as intended.
Without this fix, VMs show:
/dev/vda1 2.8G (despite 20GB disk)
With this fix, VMs will have:
/dev/vda1 20G (using full disk)
Fixes: e46bf3cd54de ("guestfs: add unified LIBVIRT_IMAGE_SIZE configuration")
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
.../roles/base_image/tasks/custom-image.yml | 31 ++++++++++++++++++-
1 file changed, 30 insertions(+), 1 deletion(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 46701e75..207a5fa1 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -53,7 +53,36 @@
cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
changed_when: true
when:
- - custom_image_download is changed or custom_image_stat.stat.exists
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Create temporary file for partition-expanded image
+ ansible.builtin.tempfile:
+ state: file
+ suffix: .raw
+ register: temp_resized_image
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Expand root partition to use full disk
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "virt-resize --expand /dev/sda1 {{ custom_image }} {{ temp_resized_image.path }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+
+- name: Replace original image with partition-expanded one
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "mv -f {{ temp_resized_image.path }} {{ custom_image }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
- guestfs_has_custom_raw_image_url|bool
- name: Check if the custom image sentinel file already exists
--
2.50.1
next prev parent reply other threads:[~2025-08-27 3:57 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-27 3:57 [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
2025-08-27 3:57 ` Luis Chamberlain [this message]
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
2025-08-27 3:57 ` [RFT 3/4] guestfs: fix virt-resize failure for custom images Luis Chamberlain
2025-08-27 3:57 ` [RFT 4/4] guestfs: fix checksum verification for resized " Luis Chamberlain
2025-08-29 2:01 ` [RFT 0/4] guestfs: few custom image fixes Luis Chamberlain
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250827035747.3314144-2-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=cel@kernel.org \
--cc=da.gomez@kruces.com \
--cc=kdevops@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox