From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 016F0B5F4 for ; Wed, 9 Aug 2023 15:45:13 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id D438C15D5B for ; Wed, 9 Aug 2023 15:45:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS for ; Wed, 9 Aug 2023 15:45:12 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AADC443C70 for ; Wed, 9 Aug 2023 15:45:11 +0200 (CEST) From: Christoph Heiss To: pve-devel@lists.proxmox.com Date: Wed, 9 Aug 2023 15:44:23 +0200 Message-ID: <20230809134426.1009504-5-c.heiss@proxmox.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809134426.1009504-1-c.heiss@proxmox.com> References: <20230809134426.1009504-1-c.heiss@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL -0.045 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH installer 4/6] tui: setup: fix disk size for 4Kn block devices X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Aug 2023 13:45:13 -0000 This can be tested by creating a block device with 4K sectorsize using the following QEMU args: -device virtio-blk,drive=testdrive4k,logical_block_size=4096,physical_block_size=4096 -drive file=/path/to/4k-testdisk.img,if=none,id=testdrive4k The 4k-testdisk.img was created with: qemu-img create -f qcow2 /path/to/4k-testdisk.img 16G Signed-off-by: Christoph Heiss --- proxmox-tui-installer/src/setup.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/proxmox-tui-installer/src/setup.rs b/proxmox-tui-installer/src/setup.rs index e51bb4d..c071b80 100644 --- a/proxmox-tui-installer/src/setup.rs +++ b/proxmox-tui-installer/src/setup.rs @@ -283,7 +283,10 @@ where .map( |(index, device, size_mb, model, logical_bsize, _syspath)| Disk { index: index.to_string(), - size: (size_mb * logical_bsize as f64) / 1024. / 1024. / 1024., + // Linux always reports the size of block devices in sectors, where one sector is + // defined as being 2^9 = 512 bytes in size. + // https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/blk_types.h?h=v6.4#n30 + size: (size_mb * 512.) / 1024. / 1024. / 1024., block_size: logical_bsize, path: device, model: (!model.is_empty()).then_some(model), -- 2.41.0