[elbe-devel] [PATCH v2 2/2] hdimg: Find loop device instead of providing it

Torben Hohn torben.hohn at linutronix.de
Wed Apr 15 17:29:52 CEST 2020


On Fri, Apr 03, 2020 at 08:00:07PM -0400, Olivier Dion wrote:
> On Thu, 02 Apr 2020, Torben Hohn <torben.hohn at linutronix.de> wrote:
> > On Thu, Mar 26, 2020 at 03:54:57PM -0400, Olivier Dion wrote:
> >> 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>
> >
> > Reviewed-by: Torben Hohn <torben.hohn at linutronix.de>
> >
> >
> > But note, that this is not complete.
> > the grubinstaller logic still uses hardcoded /dev/loop0 
> > and /dev/poop0 (this is just code to avoid special treatment for
> > /dev/loop* in the grub installer scripts.
> 
> I was not sure about that part.  I really don't get what's the point of
> the poop device.  Why not working with the /dev/loop* directly?  You
> mentioned 'special treatment'.  What do you mean?

grub behaves differently, when its told to install itself to a loop
device. 

see /etc/grub.d/10_linux on a debian system:

--------------------------------------------------------------------------------------
# loop-AES arranges things so that /dev/loop/X can be our root device, but
# the initrds that Linux uses don't like that.
case ${GRUB_DEVICE} in
  /dev/loop/*|/dev/loop[0-9])
    GRUB_DEVICE=`losetup ${GRUB_DEVICE} | sed -e "s/^[^(]*(\([^)]\+\)).*/\1/"`
    # We can't cope with devices loop-mounted from files here.
    case ${GRUB_DEVICE} in
      /dev/*) ;;
      *) exit 0 ;;
    esac
  ;;
esac
--------------------------------------------------------------------------------------

so the "special" treatment, is ignoring loop devices ;)

> 
> Anyhow, v3 is on its way with dynamics loop*/poop*.
> 
> >
> > so for the grubinstallers you need a way to create /dev/poop10 is
> > losetup returns /dev/loop10 
> >
> > and also make these things dynamic.
> >
> >> ---
> >>  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
> >> 
> >> 
> >> _______________________________________________
> >> elbe-devel mailing list
> >> elbe-devel at linutronix.de
> >> https://lists.linutronix.de/mailman/listinfo/elbe-devel
> >
> > -- 
> > Torben Hohn
> > Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> > Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99
> >
> > Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
> > can be found here): https://linutronix.de/kontakt/Datenschutz.php
> >
> > Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
> > Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
> > 806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner
> -- 
> Olivier Dion
> Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
> 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner



More information about the elbe-devel mailing list