Skip to content

Commit 3e6b60f

Browse files
committed
guestfs: fix virt-resize failure for custom images
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 <[email protected]>
1 parent b02a309 commit 3e6b60f

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

playbooks/roles/base_image/tasks/custom-image.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
become: true
5151
become_method: ansible.builtin.sudo
5252
ansible.builtin.command:
53-
cmd: "qemu-img resize {{ custom_image }} {{ libvirt_image_size }}"
53+
cmd: "qemu-img resize -f raw {{ custom_image }} {{ libvirt_image_size }}"
5454
changed_when: true
5555
when:
5656
- custom_image_download is changed
@@ -65,6 +65,17 @@
6565
- custom_image_download is changed
6666
- guestfs_has_custom_raw_image_url|bool
6767

68+
- name: Pre-allocate space for the resized image
69+
become: true
70+
become_method: ansible.builtin.sudo
71+
ansible.builtin.command:
72+
cmd: "qemu-img create -f raw {{ temp_resized_image.path }} {{ libvirt_image_size }}"
73+
changed_when: true
74+
when:
75+
- custom_image_download is changed
76+
- guestfs_has_custom_raw_image_url|bool
77+
- temp_resized_image.path is defined
78+
6879
- name: Expand root partition to use full disk
6980
become: true
7081
become_method: ansible.builtin.sudo

0 commit comments

Comments
 (0)