[arch-releng] [archiso] keep name resolver settings
Hello everybody, I am not shure if this is the correct place to report or if there is any better one... If so - please let me know. Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host. Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost. I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached. -- Best regards, Chris O< ascii ribbon campaign stop html mail - www.asciiribbon.org
On 04/19/2012 10:50 PM, Christian Hesse wrote:
Hello everybody,
I am not shure if this is the correct place to report or if there is any better one... If so - please let me know.
Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host.
Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost.
I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached.
Please send the patch inline since our mailing list filters regular attachments. -- Ionuț
Ionut Biru <ibiru@archlinux.org> on Thu, 2012/04/19 23:56:
On 04/19/2012 10:50 PM, Christian Hesse wrote:
Hello everybody,
I am not shure if this is the correct place to report or if there is any better one... If so - please let me know.
Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host.
Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost.
I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached.
Please send the patch inline since our mailing list filters regular attachments.
Sorry, did not know that. Here we go: --- archiso/archiso/hooks/archiso 2012-04-19 18:39:24.381454201 +0200 +++ archiso/archiso/hooks/archiso 2012-04-19 18:40:58.095839569 +0200 @@ -193,6 +193,13 @@ archiso_mount_handler() { if [[ "${copytoram}" == "y" ]]; then umount /run/archiso/bootmnt fi + + if [[ -s "/etc/resolv.conf" ]]; then + echo "# These settings have been generated within initrd and moved" \ + > /etc/resolv.conf + echo "# to main system by hook archiso." >> /etc/resolv.conf + cat "/etc/resolv.conf" >> "${newroot}/etc/resolv.conf" + fi } # vim:ft=sh:ts=4:sw=4:et: -- Best regards, Chris O< ascii ribbon campaign stop html mail - www.asciiribbon.org
Christian Hesse <list@eworm.de> on Thu, 2012/04/19 23:08:
Ionut Biru <ibiru@archlinux.org> on Thu, 2012/04/19 23:56:
On 04/19/2012 10:50 PM, Christian Hesse wrote:
Hello everybody,
I am not shure if this is the correct place to report or if there is any better one... If so - please let me know.
Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host.
Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost.
I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached.
Please send the patch inline since our mailing list filters regular attachments.
Sorry, did not know that.
Here we go: [snip]
Stupid me... I messed it up. Here is a working one: --- archiso/archiso/hooks/archiso 2012-04-19 18:39:24.381454201 +0200 +++ archiso/archiso/hooks/archiso 2012-04-19 18:40:58.095839569 +0200 @@ -193,6 +193,13 @@ archiso_mount_handler() { if [[ "${copytoram}" == "y" ]]; then umount /run/archiso/bootmnt fi + + if [[ -s "/etc/resolv.conf" ]]; then + echo "# These settings have been generated within inird and moved" \ + > ${newroot}/etc/resolv.conf + echo "# to main system by hook archiso." >> ${newroot}/etc/resolv.conf + cat /etc/resolv.conf >> ${newroot}/etc/resolv.conf + fi } # vim:ft=sh:ts=4:sw=4:et: -- Best regards, Chris O< ascii ribbon campaign stop html mail - www.asciiribbon.org
On 04/19/2012 06:16 PM, Christian Hesse wrote:
Christian Hesse<list@eworm.de> on Thu, 2012/04/19 23:08:
Ionut Biru<ibiru@archlinux.org> on Thu, 2012/04/19 23:56:
On 04/19/2012 10:50 PM, Christian Hesse wrote:
Hello everybody,
I am not shure if this is the correct place to report or if there is any better one... If so - please let me know.
Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host.
Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost.
I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached. Please send the patch inline since our mailing list filters regular attachments.
Sorry, did not know that.
Here we go: [snip] Stupid me... I messed it up. Here is a working one:
--- archiso/archiso/hooks/archiso 2012-04-19 18:39:24.381454201 +0200 +++ archiso/archiso/hooks/archiso 2012-04-19 18:40:58.095839569 +0200 @@ -193,6 +193,13 @@ archiso_mount_handler() { if [[ "${copytoram}" == "y" ]]; then umount /run/archiso/bootmnt fi + + if [[ -s "/etc/resolv.conf" ]]; then + echo "# These settings have been generated within inird and moved" \ +> ${newroot}/etc/resolv.conf + echo "# to main system by hook archiso.">> ${newroot}/etc/resolv.conf + cat /etc/resolv.conf>> ${newroot}/etc/resolv.conf + fi }
# vim:ft=sh:ts=4:sw=4:et:
Thanks. Yes I know about this. archiso hook is not the most right place for this (it does not know about "network" things), but at least is the most simple way for now, to implement/workaround this. I am currently waiting support on mkinitcpio for running hooks just before the end of init script, in this way I can attach a function from archiso_pxe_common hook, that will be executed. PS: initrd is not initramfs (what is used on Arch) -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
Gerardo Exequiel Pozzi <vmlinuz386@yahoo.com.ar> on Thu, 2012/04/19 21:50:
On 04/19/2012 06:16 PM, Christian Hesse wrote:
Christian Hesse<list@eworm.de> on Thu, 2012/04/19 23:08:
Ionut Biru<ibiru@archlinux.org> on Thu, 2012/04/19 23:56:
On 04/19/2012 10:50 PM, Christian Hesse wrote:
Hello everybody,
I am not shure if this is the correct place to report or if there is any better one... If so - please let me know.
Ok, the initrd hooks from archiso support PXE booting. In this case the initrd is responsible for setting up the network. All these setting are persistent, so are still valid after changing to the real system. With one exception: name resolver settings (namely file /etc/resolv.conf) are lost, which ends up in a system with network connectivity that can not resolve a single host.
Even worse: When launching a dhcp client you may get a new address and end up with something completely useless as nbd connection is lost.
I would like to write the final /etc/resolv.conf from within initrd. For me this completely solves the problem. Patch is attached. Please send the patch inline since our mailing list filters regular attachments.
Sorry, did not know that.
Here we go: [snip] Stupid me... I messed it up. Here is a working one:
--- archiso/archiso/hooks/archiso 2012-04-19 18:39:24.381454201 +0200 +++ archiso/archiso/hooks/archiso 2012-04-19 18:40:58.095839569 +0200 @@ -193,6 +193,13 @@ archiso_mount_handler() { if [[ "${copytoram}" == "y" ]]; then umount /run/archiso/bootmnt fi + + if [[ -s "/etc/resolv.conf" ]]; then + echo "# These settings have been generated within inird and moved" \ +> ${newroot}/etc/resolv.conf + echo "# to main system by hook archiso.">> ${newroot}/etc/resolv.conf + cat /etc/resolv.conf>> ${newroot}/etc/resolv.conf + fi }
# vim:ft=sh:ts=4:sw=4:et:
Thanks. Yes I know about this.
archiso hook is not the most right place for this (it does not know about "network" things), but at least is the most simple way for now, to implement/workaround this.
No, it's not the right place... But I think it is the only way without implementing this in mkinitcpio:
I am currently waiting support on mkinitcpio for running hooks just before the end of init script, in this way I can attach a function from archiso_pxe_common hook, that will be executed.
Good to know a "real" fix is on the TODO list. I will use my workaround for my self and wait for a proper solution. Thanks! -- Best regards, Chris O< ascii ribbon campaign stop html mail - www.asciiribbon.org
--- README | 3 +++ archiso/hooks/archiso_pxe_common | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/README b/README index 07bc019..cfcff39 100644 --- a/README +++ b/README @@ -90,6 +90,9 @@ INDEX when option "IPAPPEND" is set to 2 or 3 in config. BOOTIF=<hardware-address-of-boot-interface> Default: (set via PXELINUX) +* copy_resolvconf= Copy /etc/resolv.conf from initramfs to live-enviroment. + Set to "n" to skip them. + Default: "y" ** hooks/archiso_pxe_nbd diff --git a/archiso/hooks/archiso_pxe_common b/archiso/hooks/archiso_pxe_common index febb503..eddc7ea 100644 --- a/archiso/hooks/archiso_pxe_common +++ b/archiso/hooks/archiso_pxe_common @@ -40,3 +40,11 @@ run_hook () { fi fi } + +run_latehook () { + [[ -z "${copy_resolvconf}" ]] && copy_resolvconf="y" + + if [[ "${copy_resolvconf}" != "n" ]]; then + cp /etc/resolv.conf /new_root/etc/resolv.conf + fi +} -- 1.7.9.6
On Sat, May 19, 2012 at 04:17:23PM -0300, Gerardo Exequiel Pozzi wrote:
--- README | 3 +++ archiso/hooks/archiso_pxe_common | 8 ++++++++ 2 files changed, 11 insertions(+)
diff --git a/README b/README index 07bc019..cfcff39 100644 --- a/README +++ b/README @@ -90,6 +90,9 @@ INDEX when option "IPAPPEND" is set to 2 or 3 in config. BOOTIF=<hardware-address-of-boot-interface> Default: (set via PXELINUX) +* copy_resolvconf= Copy /etc/resolv.conf from initramfs to live-enviroment. + Set to "n" to skip them. + Default: "y"
** hooks/archiso_pxe_nbd diff --git a/archiso/hooks/archiso_pxe_common b/archiso/hooks/archiso_pxe_common index febb503..eddc7ea 100644 --- a/archiso/hooks/archiso_pxe_common +++ b/archiso/hooks/archiso_pxe_common @@ -40,3 +40,11 @@ run_hook () { fi fi } + +run_latehook () { + [[ -z "${copy_resolvconf}" ]] && copy_resolvconf="y"
busybox won't complain about this, but you should be using single square braces here for "clarity".
+ + if [[ "${copy_resolvconf}" != "n" ]]; then + cp /etc/resolv.conf /new_root/etc/resolv.conf + fi
Wouldn't this entire hook be better stated as simply: if [ "$copy_resolveconf" != 'n' ]; then cp /etc/resolv.conf /new_root/etc/resolv.conf fi
+} -- 1.7.9.6
On 05/19/2012 04:27 PM, Dave Reisner wrote:
On Sat, May 19, 2012 at 04:17:23PM -0300, Gerardo Exequiel Pozzi wrote:
--- README | 3 +++ archiso/hooks/archiso_pxe_common | 8 ++++++++ 2 files changed, 11 insertions(+)
diff --git a/README b/README index 07bc019..cfcff39 100644 --- a/README +++ b/README @@ -90,6 +90,9 @@ INDEX when option "IPAPPEND" is set to 2 or 3 in config. BOOTIF=<hardware-address-of-boot-interface> Default: (set via PXELINUX) +* copy_resolvconf= Copy /etc/resolv.conf from initramfs to live-enviroment. + Set to "n" to skip them. + Default: "y"
** hooks/archiso_pxe_nbd diff --git a/archiso/hooks/archiso_pxe_common b/archiso/hooks/archiso_pxe_common index febb503..eddc7ea 100644 --- a/archiso/hooks/archiso_pxe_common +++ b/archiso/hooks/archiso_pxe_common @@ -40,3 +40,11 @@ run_hook () { fi fi } + +run_latehook () { + [[ -z "${copy_resolvconf}" ]]&& copy_resolvconf="y" busybox won't complain about this, but you should be using single square braces here for "clarity".
mmm I use double sqaure braces in all places on archiso, since busybox is compiled with bash compatible support (of course does not work in the same way) Also I like to add/test for all "boot vars" on each hook. To keep more visible.
+ + if [[ "${copy_resolvconf}" != "n" ]]; then + cp /etc/resolv.conf /new_root/etc/resolv.conf + fi Wouldn't this entire hook be better stated as simply:
if [ "$copy_resolveconf" != 'n' ]; then cp /etc/resolv.conf /new_root/etc/resolv.conf fi
Its just a "coding style" that I am following on archiso.
+} -- 1.7.9.6
Thanks for the feedback. -- Gerardo Exequiel Pozzi \cos^2\alpha + \sin^2\alpha = 1
participants (4)
-
Christian Hesse
-
Dave Reisner
-
Gerardo Exequiel Pozzi
-
Ionut Biru