From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 48C7B224B09 for ; Wed, 27 Aug 2025 03:57:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756267071; cv=none; b=PowvNNLM4x1qw2befrZ4PlvzZ31pykoocmFC1SG3vn3enfFUmZqM+9Es5im5/C+/pW8PoxByJqBEGPpXDBf+r8lUM3sUkIMM89UBiTveSRZoFIpLRLrQvHebor2nwd82A0cuWO9cvKIcMtJ3uQ5LAoQA6dPjg3RyZuiwJsMlEUw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1756267071; c=relaxed/simple; bh=cRrX/JsKJo5T5zHt59HlJFuiEkCtIBWF2345yRaok/g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lYdPUrUZ2oAlgx6hDKvjc/Wr+nQUXlTDO8GbIYjIQsqGQnRBdtIh746k20JqYjX8m9FRdRjmLw6W03D1LnxI08+w/al1oci4iYapDCuPf5z7cXqjJfC2anzQRdwGb5c9lo5AEAuSHNp1IA+OqKeIGpuZq8QToY6y0rlO9wNozF8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=QpcZ8Ayt; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=quarantine dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="QpcZ8Ayt" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=l5hRHILA/oda9ERVmUy6L/u/MDDh0PkV2DfXeY87qf0=; b=QpcZ8AytWE2AJXV/7XtOGigCvP E+CD+WxOGJq3NrrY1FQSBt3Spm/s8103PbjcSpKjJaN9ZSLpgKsrIiL46Z9EX8/l4ldT8BoJSAqZU ykeYP4yImzQ0Ps7Ax/cfJ4whll2cz8cb7xcE1JDF3i7Z0IA3+QOnMPlb/qp5IlrVyZWlZNoQ5Wk38 urbvqt5SjRuwrDt87dDZMnWvgGTBPsp+Ru5Xp2/HYMcawi/Do/NSo8tNG3oUTAmM4FW7t7PUdYPXI OSyTMc9BfaMfyQVYa63xGvq4gEgQ5IvzHc0lvViT2xf7wq0vGdE8A7YIp/RwIqS1kUs/krQ5+cC8g 2sVV1pqw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.98.2 #2 (Red Hat Linux)) id 1ur7IB-0000000DuA7-3lpI; Wed, 27 Aug 2025 03:57:47 +0000 From: Luis Chamberlain To: Chuck Lever , Daniel Gomez , kdevops@lists.linux.dev Cc: Luis Chamberlain Subject: [RFT 1/4] guestfs: fix custom image partition not expanded after disk resize Date: Tue, 26 Aug 2025 20:57:44 -0700 Message-ID: <20250827035747.3314144-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250827035747.3314144-1-mcgrof@kernel.org> References: <20250827035747.3314144-1-mcgrof@kernel.org> Precedence: bulk X-Mailing-List: kdevops@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: Luis Chamberlain 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 --- .../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