live: tweak 50-setup-network regarding resolving

The issue has shown up in regular-*-20130207: /etc/resolv.conf
would suddenly be empty upon successful bootup in virtualbox
with a single DHCP configurable ethernet.

dmesg has some trouble signs:

  aufs au_lkup_neg:267:kworker/0:2[998]:
  I/O Error, resolv.conf should be negative on b0

sem@ tells something like that has been seen before in a different
configuration (multiple aufs overlays with /etc/ and /var sitting
in different ones resulting in broken hardlinks); rescue boot with
a test "echo > /etc/resolv.conf" yields an I/O error either.

The patch is loosely based upon livecd-net-eth and
m-p-d::profiles/live/image-scripts.d/init3-{network,resolve}.

See also #28484 for the (still ongoing) discussion.
This commit is contained in:
Michael Shigorin 2013-02-11 17:17:21 +04:00
parent 28f7f9be27
commit 77f1459f52

View File

@ -23,6 +23,18 @@ DOMAINNAME="localdomain"
verbose "Init /etc/hosts with 127.0.0.1 localhost" verbose "Init /etc/hosts with 127.0.0.1 localhost"
echo "127.0.0.1 localhost localhost.localdomain" > /etc/hosts echo "127.0.0.1 localhost localhost.localdomain" > /etc/hosts
prefix="/etc/net/ifaces"
# seems like aufs bug on O_TRUNC writes:
# aufs au_lkup_neg:267:kworker/0:2[998]:
# I/O Error, resolv.conf should be negative on b0.
# OTOH lo interface is now brought up in initrd
# so this shoudn't really matter
if [ -d "$prefix"/lo ]; then
echo 'nameserver 8.8.8.8' >> "$prefix"/lo/resolv.conf
fi
find /var -name resolv.conf -or -name nsswitch.conf -delete
netcfg="/etc/sysconfig/network" netcfg="/etc/sysconfig/network"
verbose "Enable networking, set hostname to $HOSTNAME, domainname to $DOMAINNAME" verbose "Enable networking, set hostname to $HOSTNAME, domainname to $DOMAINNAME"
@ -30,21 +42,22 @@ shell_config_set "$netcfg" NETWORKING yes
shell_config_set "$netcfg" HOSTNAME "$HOSTNAME" shell_config_set "$netcfg" HOSTNAME "$HOSTNAME"
shell_config_set "$netcfg" DOMAINNAME "$DOMAINNAME" shell_config_set "$netcfg" DOMAINNAME "$DOMAINNAME"
# NB: see also #28484 and livecd-net-eth for runtime configuration
if [ -x /usr/sbin/NetworkManager ] ; then defcfg="$prefix/default/options-eth"
verbose "Setup defaults for NetworkManager" if [ -x /usr/sbin/NetworkManager -o -x /usr/sbin/connmand ] ; then
shell_config_set /etc/net/ifaces/default/options-eth NM_CONTROLLED yes verbose "Setup defaults for NetworkManager/connman"
shell_config_set /etc/net/ifaces/default/options-eth DISABLED yes shell_config_set "$defcfg" NM_CONTROLLED yes
shell_config_set /etc/net/ifaces/default/options-eth BOOTPROTO dhcp shell_config_set "$defcfg" DISABLED yes
shell_config_set "$defcfg" BOOTPROTO dhcp
else else
# attempt to autoconfigure ethernet by etcnet # attempt to autoconfigure ethernet by etcnet
if [ -x /sbin/dhcpcd -o -x /sbin/dhclient ]; then if [ -x /lib/udev/write_net_rules ] &&
[ -x /sbin/dhcpcd -o -x /sbin/dhclient ]; then
verbose "configuring DHCP for eth0" verbose "configuring DHCP for eth0"
mkdir -p "$prefix"/eth0 && {
mkdir -p /etc/net/ifaces/eth0 && {
echo TYPE=eth echo TYPE=eth
echo BOOTPROTO=dhcp echo BOOTPROTO=dhcp
} > /etc/net/ifaces/eth0/options } > "$prefix"/eth0/options
else else
verbose "NOT configuring eth0 for DHCP" verbose "NOT configuring eth0 for DHCP"
fi fi