From a787fab0ea19c24b150b2d04dbbc3095caa7e004 Mon Sep 17 00:00:00 2001 From: caleb Date: Wed, 17 Jul 2024 10:52:08 -0400 Subject: [PATCH] try to help partition detection --- truenas_installer/utils.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/truenas_installer/utils.py b/truenas_installer/utils.py index 5a7ae14..ecdc371 100644 --- a/truenas_installer/utils.py +++ b/truenas_installer/utils.py @@ -25,6 +25,15 @@ async def get_partitions( else: tries = min(tries, MAX_PARTITION_WAIT_TIME_SECS) + # by the time this function is called, partitions should have been + # written to the disk. However, it doesn't mean the kernel/udev has + # updated the various symlinks in sysfs. We'll open the block device + # in write mode. This should send a kernel and udev change event for + # the device and any partitions as well. Ideally, this will help bubble + # up the events so sysfs is populated before the logic below kicks in + with open(device, 'w'): + pass + disk_partitions = {i: None for i in partitions} device = device.removeprefix('/dev/') for _try in range(tries):