[elbe-devel] [PATCH] Update device mapping on losetup

Bastian Germann bage at linutronix.de
Mon Feb 20 13:31:04 CET 2023


The mkfs.fat sanity check revealed a problem with outdated partition mapping
info in elbe:

[CMD] mkfs.vfat  -n uefi /dev/loop0
mkfs.fat 4.2 (2021-01-31)
mkfs.vfat: Partitions or virtual mappings on device '/dev/loop0', not making
filesystem (use -I to override)

The kernel retains information about previously created partitions on a loop
device with the same name. Update that info with kpartx -u.

Link: https://github.com/dosfstools/dosfstools/issues/40
Signed-off-by: Bastian Germann <bage at linutronix.de>
---
 elbepack/hdimg.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index deeedce2e6..6ac259e702 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -145,6 +145,8 @@ class grubinstaller_base:
     @staticmethod
     def losetup(f):
         loopdev = get_command_out(f'losetup --find --show "{f}"')
+        # old, removed loop devices' kernel structures might be reused, so update the mapping
+        do(f'kpartx -u "{f}"')
         return loopdev.decode().rstrip('\n')
 
 
-- 
2.30.2



More information about the elbe-devel mailing list