[elbe-devel] [PATCH v2 2/2] hdimg: Find loop device instead of providing it
Olivier Dion
dion at linutronix.de
Thu Mar 26 20:54:57 CET 2020
Since we might not be able to acquire /dev/loop0, we let losetup
find a free device for us and use it.
Signed-off-by: Olivier Dion <dion at linutronix.de>
---
elbepack/hdimg.py | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/elbepack/hdimg.py b/elbepack/hdimg.py
index 22522821..a9d2666c 100644
--- a/elbepack/hdimg.py
+++ b/elbepack/hdimg.py
@@ -331,20 +331,21 @@ def create_label(disk, part, ppart, fslabel, target, grub):
grub.add_fs_entry(entry)
- entry.losetup("loop0")
- do('mkfs.%s %s %s /dev/loop0' %
+ loopdev = entry.losetup()
+ do('mkfs.%s %s %s %s' %
(entry.fstype,
entry.mkfsopt,
- entry.get_label_opt()))
+ entry.get_label_opt(),
+ loopdev))
- do('mount /dev/loop0 %s' % os.path.join(target, "imagemnt"))
+ do('mount %s %s' % (loopdev, os.path.join(target, "imagemnt")))
do('cp -a "%s/." "%s/"' %
(os.path.join(target, "filesystems", entry.id),
os.path.join(target, "imagemnt")),
allow_fail=True)
- entry.tuning("/dev/loop0")
- do('umount /dev/loop0')
- do('losetup -d /dev/loop0')
+ entry.tuning(loopdev)
+ do('umount %s' % loopdev)
+ do('losetup -d %s' % loopdev)
return ppart
--
2.26.0
More information about the elbe-devel
mailing list