[arch-releng] [PATCH] archiso_loop_mnt - cleaner boot from loopmounted iso file

Gerardo Exequiel Pozzi vmlinuz386 at gmail.com
Sat Jul 18 17:29:25 UTC 2015


On 07/18/2015 09:18 AM, Adam Purkrt wrote:
> On 07/13/2015 04:19 AM, Gerardo Exequiel Pozzi wrote:
>> On 07/12/2015 09:19 AM, Adam Purkrt wrote:
>>> On 07/12/2015 02:29 AM, Gerardo Exequiel Pozzi wrote:
>>>> On 07/11/2015 04:00 PM, Adam Purkrt wrote:
>>>>> I would like to suggest the patch below, to archiso_loop_mnt hook.
>>>>>
>>>>> Currently, when booting loopmounted iso file, it is necessary to
>>>>> specify not only img_dev and img_loop (which should be sufficient),
>>>>> but also archisolabel or archisodevice. With the patch, archisodevice
>>>>> is directly populated with the correct loop device, and it is not
>>>>> necessary to specify the label when booting from loopmounted iso,
>>>>> which makes for leaner and cleaner grub.cfg.
>>>>>
>>>>> The kernel command line in grub.cfg currently needed:
>>>>>
>>>>> linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=ARCH_201507
>>>>> img_dev=$imgdevpath img_loop=$isofile earlymodules=loop
>>>>>
>>>>> after the patch:
>>>>>
>>>>> linux (loop)/arch/boot/x86_64/vmlinuz img_dev=$imgdevpath
>>>>> img_loop=$isofile earlymodules=loop
>>>>>
>>>> You are right!
>>>>
>>>> Please also update the README.altbootmethods ;)
>>>>
>>>> PS: "earlymodules=loop": Is like a copy&paste hurricane from old age.
>>>> It was a temporal workaround (2011.08.19), but spread across all places.
>>>>
>>>> Thanks.
>>>>
>>>
>>> It's good that "earlymodules=loop" is not necessary, thanks for pointing it out.
>>>
>>> Updated the README.altbootmethods, using uuid over label. Overall the patch is:
>>>
>>> diff --git a/archiso/initcpio/hooks/archiso_loop_mnt b/archiso/initcpio/hooks/archiso_loop_mnt
>>> index 46338e5..f95a47d 100644
>>> --- a/archiso/initcpio/hooks/archiso_loop_mnt
>>> +++ b/archiso/initcpio/hooks/archiso_loop_mnt
>>> @@ -18,7 +18,9 @@ archiso_loop_mount_handler () {
>>>          echo $(readlink -f ${img_dev}) >> /run/archiso/used_block_devices
>>>      fi
>>>  
>>> -    if ! _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then
>>> +    if _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then
>>> +        archisodevice="${_dev_loop}"
>>> +    else
>>>          echo "ERROR: Setting loopback device for file '/run/archiso/img_dev/${img_loop}'"
>>>          launch_interactive_shell
>>>      fi
>>> diff --git a/docs/README.altbootmethods b/docs/README.altbootmethods
>>> index 3c07e03..cbfada4 100644
>>> --- a/docs/README.altbootmethods
>>> +++ b/docs/README.altbootmethods
>>> @@ -25,20 +25,23 @@ Where:
>>>  
>>>  Note: Described method is for using with GRUB2.
>>>        GRUB2 is installed on target media and archlinux-<YYYY>.<MM>.<DD>-dual.iso
>>> -      is at path <TARGET-PATH> on disk <D> and partition <P>,
>>> -      where filesystem is labeled as <TARGET-FS-LABEL>.
>>> +      is at path <TARGET-PATH> on disk <D> and partition <P>.
>>>  
>>>  menuentry "Arch Linux (x86_64)" {
>>> +    set isopartition=hd<D>,<P>
>>>      set isofile="/<TARGET-PATH>/archlinux-<YYYY>.<MM>.<DD>-dual.iso"
>>> -    loopback loop (hd<D>,<P>)$isofile
>>> -    linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=<FS-LABEL> img_label=<TARGET-FS-LABEL> img_loop=$isofile
>>> +    loopback loop ($isopartition)$isofile
>>> +    probe -u $isopartition --set=isouuid
>>> +    linux (loop)/arch/boot/x86_64/vmlinuz img_dev=/dev/disk/by-uuid/$isouuid img_loop=$isofile
>>>      initrd (loop)/arch/boot/x86_64/archiso.img
>>>  }
>>>  
>>>  menuentry "Arch Linux (i686)" {
>>> +    set isopartition=hd<D>,<P>
>>>      set isofile="/<TARGET-PATH>/archlinux-<YYYY>.<MM>.<DD>-dual.iso"
>>> -    loopback loop (hd<D>,<P>)$isofile
>>> -    linux (loop)/arch/boot/i686/vmlinuz archisolabel=<FS-LABEL> img_label=<TARGET-FS-LABEL> img_loop=$isofile
>>> +    loopback loop ($isopartition)$isofile
>>> +    probe -u $isopartition --set=isouuid
>>> +    linux (loop)/arch/boot/i686/vmlinuz img_dev=/dev/disk/by-uuid/$isouuid img_loop=$isofile
>>>      initrd (loop)/arch/boot/i686/archiso.img
>>>  }
>>>  
>>>
>>>
>>>
>>>
>>>
>>> One more thing - I would vote for deprecating "img_label" parameter and (sooner or later) removing it, i.e.
>>>
>>> /archiso/initcpio/hooks/archiso_loop_mnt
>>> -    [[ -n "${img_label}" ]] && img_dev="/dev/disk/by-label/${img_label}"
>>>
>>> /docs/README.bootparams
>>> -* img_label=        Set the filesystem label where archiso-image.iso.
>>> -                    Default: (unset)
>>>  * img_dev=          Device where archiso-image.iso reside.
>>> -                    Default: (unset) or "/dev/disk/by-label/${img_label}"
>>> +                    Default: (unset)
>>>
>>> since: 1) it is more reliable to refer to a partition by uuid
>>> 2) there is no "img_uuid" - and I don't think there should be, "img_dev=/dev/disk/by-uuid/[uuid]" is perfectly fine
>>> 3) it would be still possible to address by label using "img_dev=/dev/disk/by-label/[label]"
>>>
>>> Not sure how much upheaval the abolition of img_label would cause, though.
>>>
>>
>> Please do one logic change at time.
>> Wheel, I never used loopback method other than just for test it per user
>> request when it was implemented.
>> Why remove img_label= it does look good for keep thing easy to
>> reference, sure archisolabel= can also be removed...
>>
>>
>>
> 
> Perhaps the following change is more acceptable. Admittedly, in many situations,
> using label can be quite practical.

Sure.

> 
> Booting from iso, in general, comes in handy; you don't need to overwrite a whole flash.

There is no need to do such thing. The ISO is made in a way to just copy
one directory, all is self contained in "arch". (minus  bootloader)

> On efi systems it is sufficient to simply copy /EFI/ and /boot/ directory from some
> distro with grub, then copy the iso file to /boot/iso/, tailor /boot/grub/grub.cfg
> and you have an (efi) bootable flash, without a need to overwrite the flashdrive.
> 
> 
> diff --git a/archiso/initcpio/hooks/archiso_loop_mnt b/archiso/initcpio/hooks/archiso_loop_mnt
> index 46338e5..f95a47d 100644
> --- a/archiso/initcpio/hooks/archiso_loop_mnt
> +++ b/archiso/initcpio/hooks/archiso_loop_mnt
> @@ -18,7 +18,9 @@ archiso_loop_mount_handler () {
>          echo $(readlink -f ${img_dev}) >> /run/archiso/used_block_devices
>      fi
>  
> -    if ! _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then
> +    if _dev_loop=$(losetup --find --show --read-only "/run/archiso/img_dev/${img_loop}"); then
> +        archisodevice="${_dev_loop}"
> +    else
>          echo "ERROR: Setting loopback device for file '/run/archiso/img_dev/${img_loop}'"
>          launch_interactive_shell
>      fi

OK

> diff --git a/docs/README.altbootmethods b/docs/README.altbootmethods
> index 3c07e03..9df20ef 100644
> --- a/docs/README.altbootmethods
> +++ b/docs/README.altbootmethods
> @@ -31,14 +31,14 @@ Note: Described method is for using with GRUB2.
>  menuentry "Arch Linux (x86_64)" {
>      set isofile="/<TARGET-PATH>/archlinux-<YYYY>.<MM>.<DD>-dual.iso"
>      loopback loop (hd<D>,<P>)$isofile
> -    linux (loop)/arch/boot/x86_64/vmlinuz archisolabel=<FS-LABEL> img_label=<TARGET-FS-LABEL> img_loop=$isofile
> +    linux (loop)/arch/boot/x86_64/vmlinuz img_label=<TARGET-FS-LABEL> img_loop=$isofile
>      initrd (loop)/arch/boot/x86_64/archiso.img
>  }
>  
>  menuentry "Arch Linux (i686)" {
>      set isofile="/<TARGET-PATH>/archlinux-<YYYY>.<MM>.<DD>-dual.iso"
>      loopback loop (hd<D>,<P>)$isofile
> -    linux (loop)/arch/boot/i686/vmlinuz archisolabel=<FS-LABEL> img_label=<TARGET-FS-LABEL> img_loop=$isofile
> +    linux (loop)/arch/boot/i686/vmlinuz img_label=<TARGET-FS-LABEL> img_loop=$isofile
>      initrd (loop)/arch/boot/i686/archiso.img
>  }
>  

OK

> diff --git a/docs/README.bootparams b/docs/README.bootparams
> index 356375d..48a1c3a 100644
> --- a/docs/README.bootparams
> +++ b/docs/README.bootparams
> @@ -20,6 +20,9 @@ INDEX
>  * archisolabel=     Set the filesystem label where archiso files reside.
>                      Default: (unset)
>  * archisodevice=    Set the device node where archiso medium is located.
> +                    Upon successful mount of the iso image specified by
> +                    img_dev and img_loop, it is automatically set to the
> +                    appropriate loop device.
>                      Default: "/dev/disk/by-label/${archisolabel}"
>  * archisobasedir=   Set the base directory where all files reside.
>                      Default: "arch"
> 

Discard. Is "like" when boot via PXE.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: OpenPGP digital signature
URL: <https://lists.archlinux.org/pipermail/arch-releng/attachments/20150718/50de3f96/attachment.asc>


More information about the arch-releng mailing list