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 3/4] guestfs: fix virt-resize failure for custom images
Date: Tue, 26 Aug 2025 20:57:46 -0700 [thread overview]
Message-ID: <20250827035747.3314144-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20250827035747.3314144-1-mcgrof@kernel.org>
The virt-resize command was failing because it requires a pre-allocated
output file with the target size, not an empty temporary file.
Fix by:
1. Pre-allocating the temporary image file with qemu-img create before
running virt-resize
2. Adding -f raw flag to qemu-img resize to avoid format detection
warnings
This ensures the partition expansion works correctly when resizing
custom images like Debian 13 daily builds.
Error was:
virt-resize: error: /tmp/ansible.depq5vk0.raw: file is too small to
be a disk image (0 bytes)
Generated-by: Claude AI
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
playbooks/roles/base_image/tasks/custom-image.yml | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/playbooks/roles/base_image/tasks/custom-image.yml b/playbooks/roles/base_image/tasks/custom-image.yml
index 296424bc..a3a8cbbd 100644
--- a/playbooks/roles/base_image/tasks/custom-image.yml
+++ b/playbooks/roles/base_image/tasks/custom-image.yml
@@ -50,7 +50,7 @@
become: true
become_method: ansible.builtin.sudo
ansible.builtin.command:
- cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
+ cmd: "qemu-img resize -f raw {{ custom_image }} {{ libvirt_image_size }}"
changed_when: true
when:
- custom_image_download is changed
@@ -65,6 +65,17 @@
- custom_image_download is changed
- guestfs_has_custom_raw_image_url|bool
+- name: Pre-allocate space for the resized image
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ cmd: "qemu-img create -f raw {{ temp_resized_image.path }} {{ libvirt_image_size }}"
+ changed_when: true
+ when:
+ - custom_image_download is changed
+ - guestfs_has_custom_raw_image_url|bool
+ - temp_resized_image.path is defined
+
- name: Expand root partition to use full disk
become: true
become_method: ansible.builtin.sudo
--
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 ` [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Luis Chamberlain
2025-08-27 3:57 ` [RFT 2/4] guestfs: fix custom image bringup failure for Debian 13 Luis Chamberlain
2025-08-27 3:57 ` Luis Chamberlain [this message]
2025-08-27 3:57 ` [RFT 4/4] guestfs: fix checksum verification for resized custom images 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-4-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