[arch-projects] [mkinitcpio][PATCH] shutdown: disassemble devices on shutdown v2

Gerardo Exequiel Pozzi vmlinuz386 at yahoo.com.ar
Fri Mar 30 09:01:01 EDT 2012


On 03/29/2012 10:38 PM, Dave Reisner wrote:
> On Wed, Mar 28, 2012 at 11:30:08AM -0300, Gerardo Exequiel Pozzi wrote:
>> On 03/28/2012 10:44 AM, Dave Reisner wrote:
>>>> Is there any way to make something similar work with loop devices? You
>>>> would need to disable the loop device before umounting the underlying
>>>> file system. If we could solve this as well, then archiso probably
>>>> wouldn't need its special shutdown hook anymore.
>>>>
>>> sure, lsblk loudly declares loop devices to be type loop. Hrmmm, archiso
>>> does a lot of weird stuff... in particular, the squashfs mounts are
>>> confusing me and/or lsblk. I'll get myself a newer image and poke around
>>> at what Gerardo is doing on setup...
>>>
>>> I'm sure it's possible, I just need to understand what's happening.
>>>
>>> d
>>>
>> Hello,
>>
>> The first step on "shutdown" for archiso is a mount --move, since
>> /oldroot depends on things from /oldroot/run/archiso. This make it a
>> bit special.
>>
> So, I need to understand more about this... why is this done?
Are you talk about this "mount --move" ?
Because all things needed for /new_root/ are mounted on /run/archiso on 
initramfs. So all things are visible outside initramfs, nothing is hide 
to user (Thomas wants this some long time ago since AUFS-age).
> The
> current shutdown hook that I have in my tree gets archiso's wacky setup
> torn down properly sans loop devs. Add in a quick loop:
>
>      # assume starting in /sys/class/block
>      for loop in loop*/loop; do
>          losetup -d "${loop%/loop}"
>      done
This can be done in one step: losetup -D
Anyway I am done in a special way because some loops are in used, then
     if ! losetup -d ${_lup} 2> /dev/null; then
         umount -d ${_lup}
     fi


Anyway there are special cases if copytoram is used, or cowdevice for 
persistent data, or iso-loopback mount, and iso via NBD.

http://projects.archlinux.org/archiso.git/tree/archiso/archiso_shutdown
>
> And everything seems to be torn down properly because I'm lazily
> unmounting everything.
>
>    Unmounting all devices.
>    Disassembling stacked devices.
>
>    losetup: /dev/loop0: detach failed: Device or resource busy
>    losetup: /dev/loop3: detach failed: Device or resource busy
>    losetup: /dev/loop6: detach failed: Device or resource busy
>
>    # findmnt
>    TARGET  SOURCE FSTYPE   OPTIONS
>    /       run[/initramfs]
>                   tmpfs    rw,nosuid,nodev,relatime,mode=755
>    |-/sys  sys    sysfs    rw,nosuid,nodev,noexec,relatime
>    |-/proc proc   proc     rw,nosuid,nodev,noexec,relatime
>    |-/dev  /dev   devtmpfs rw,nosuid,relatime,size=503104k,nr_inodes=125776,mode=75
>    `-/run  run    tmpfs    rw,nosuid,nodev,relatime,mode=755
>
>    # lsblk
>    NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
>    vda    254:0    0     5G  0 disk
>    |-vda1 254:1    0   100M  0 part
>    `-vda2 254:2    0   4.9G  0 part
>    sr0     11:0    1   200M  0 rom
>    loop0    7:0    0  92.9M  1 loop
>    loop3    7:3    0  34.3M  1 loop
>    loop6    7:6    0    53M  1 loop
>
>    # losetup -a
>    /dev/loop0: [2816]:1930 (/arch/x86_64/root-image.fs.sfs)
>    /dev/loop3: [2816]:1926 (/arch/x86_64/lib-modules.fs.sfs)
>    /dev/loop6: [2816]:1414 (/arch/any/usr-share.fs.sfs)
>
> Those three errors are something that archiso hides. So, as far as I can
> tell, my hook is equivalent. Is there some serious problem with using
> lazy unmounting that makes this non-desirable? I can't really find any
> evidence of negative effects here.
>
> d
>
>

Anyway using shutdown hook provided by mkinitcpio in archiso can not be 
a good idea archiso initramfs has a looots of kernel modules, shutdown 
hooks will copy all them to ram. (Yes, of course we can just still use 
our install/archiso_shutdown and using initcpio/shutdown script instead 
of initcpio/archiso_shutdown)

-- 
Gerardo Exequiel Pozzi
\cos^2\alpha + \sin^2\alpha = 1



More information about the arch-projects mailing list