auto setup network without netroot
PATCH 1/1 auto setup network without netroot
Current dracut network only will be setup when netroot is used. But there are some cases we need network even without netroot. For example kdump will need copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as a recovery system the network is helpful even root is not a network device.
This implementation is based on the manually bring up method. Here add a kernel cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network with ifup $INTERFACE -m. If netroot is used we still keep original behavior.
--- dracut.cmdline.7.xml | 8 ++++++++ modules.d/40network/net-genrules.sh | 20 ++++++++++++++++---- 2 files changed, 24 insertions(+), 4 deletions(-)
modules.d/40network/net-genrules.sh +16 -4
@@ -14,7 +14,7 @@ fix_bootif() { } # Don't continue if we don't need network -[ -z "$netroot" ] && return; +[ -z "$netroot" ] && ! getargbool 0 rd.neednet && return; # Write udev rules {
@@ -35,17 +35,29 @@ fix_bootif() { BOOTIF=$(getarg 'BOOTIF=') if [ -n "$BOOTIF" ] ; then BOOTIF=$(fix_bootif "$BOOTIF") - printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF" + if [ -n "$netroot" ]; then + printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$BOOTIF" + else + printf 'ACTION=="add", SUBSYSTEM=="net", ATTR{address}=="%s", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$BOOTIF" + fi # If we have to handle multiple interfaces, handle only them. elif [ -n "$IFACES" ] ; then for iface in $IFACES ; do - printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface" + if [ -n "$netroot" ]; then + printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE}"\n' "$iface" + else + printf 'SUBSYSTEM=="net", ENV{INTERFACE}=="%s", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' "$iface" + fi done # Default: We don't know the interface to use, handle all else - printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n' + if [ -n "$netroot" ]; then + printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE}"\n' + else + printf 'SUBSYSTEM=="net", RUN+="/sbin/ifup $env{INTERFACE} -m"\n' + fi fi } > /etc/udev/rules.d/60-net.rules
dracut.cmdline.7.xml +8 -0
@@ -507,6 +507,14 @@ Required if multiple ip= lines are used. <para>turn on/off biosdevname network interface renaming</para> </listitem> </varlistentry> + <varlistentry> + <term> + <envar>rd.neednet=</envar><replaceable><0|1></replaceable> + </term> + <listitem> + <para>boolean, bring up network even without netroot set</para> + </listitem> + </varlistentry> </variablelist> </refsect2> <refsect2>
Quoted 9 lines · Dave Young
Current dracut network only will be setup when netroot is used. But there are some cases we need network even without netroot. For example kdump will need copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as a recovery system the network is helpful even root is not a network device.
This implementation is based on the manually bring up method. Here add a kernel cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network with ifup $INTERFACE -m. If netroot is used we still keep original behavior.
I don't think we really need to introduce a new cmdline, I think we can re-use ip= cmdline. Currently, if ip= is specified but netroot is not, ip= will be ignored. We can change this, let dracut bring up network as long as we have ip=, even we don't have netroot.
Quoted 11 lines · Cong Wang
Quoted 9 lines · Dave Young
Current dracut network only will be setup when netroot is used. But there are some cases we need network even without netroot. For example kdump will need copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as a recovery system the network is helpful even root is not a network device.
This implementation is based on the manually bring up method. Here add a kernel cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network with ifup $INTERFACE -m. If netroot is used we still keep original behavior.
Quoted 4 lines
I don't think we really need to introduce a new cmdline, I think we can re-use ip= cmdline. Currently, if ip= is specified but netroot is not, ip= will be ignored. We can change this, let dracut bring up network as long as we have ip=, even we don't have netroot.
For netroot case it is supported as well for no ip= or other network cmdline, please see the net-genrules.sh code
We will also setup network when rd.neednet=1 in case no special ip= provided for convenience.
Quoted 5 lines
--
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks Dave
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 13 lines · Dave Young
Quoted 11 lines · Cong Wang
Quoted 9 lines · Dave Young
Current dracut network only will be setup when netroot is used. But there are some cases we need network even without netroot. For example kdump will need copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as a recovery system the network is helpful even root is not a network device.
This implementation is based on the manually bring up method. Here add a kernel cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network with ifup $INTERFACE -m. If netroot is used we still keep original behavior.
Quoted 8 lines
Quoted 4 lines
I don't think we really need to introduce a new cmdline, I think we can re-use ip= cmdline. Currently, if ip= is specified but netroot is not, ip= will be ignored. We can change this, let dracut bring up network as long as we have ip=, even we don't have netroot.
For netroot case it is supported as well for no ip= or other network cmdline, please see the
net-genrules.shcode
Irrelevant.
Quoted 4 lines
We will also setup network when rd.neednet=1 in case no special ip= provided for convenience.
With rd.neednet=1 but without ip=, how can you know which nic we need to bring up?
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 34 lines · Cong Wang
Quoted 20 lines · Dave Young
Quoted 18 lines · Cong Wang
Quoted 16 lines · Dave Young
Current dracut network only will be setup when netroot is used. But there are
some cases we need network even without netroot. For example kdump will need
copy vmcore to remote machine via scp or nfs mount. OTOH, if we use dracut as
a recovery system the network is helpful even root is not a network device.This implementation is based on the manually bring up method. Here add a kernel
cmdline argument rd.neednet. If rd.neednet is set dracut will bring up network
with ifup $INTERFACE -m. If netroot is used we still keep original behavior.Quoted 8 lines
Quoted 4 lines
I don't think we really need to introduce a new cmdline, I think we can re-use ip= cmdline. Currently, if ip= is specified but netroot is not, ip= will be ignored. We can change this, let dracut bring up network as long as we have ip=, even we don't have netroot.
For netroot case it is supported as well for no ip= or other network cmdline, please see the
net-genrules.shcodeIrrelevant.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
We will also setup network when rd.neednet=1 in case no special ip= provided for convenience.
With rd.neednet=1 but without ip=, how can you know which nic we need to bring up?
current behavior of net-genrule.sh is below:
# Default: We don't know the interface to use, handle all
It will be ok and convenient at least when we have only one nic
Quoted 4 lines
Signature · 3 lines
To unsubscribe from this list: send the line "unsubscribe initramfs" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 2 lines
Thanks Dave
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 12 lines · Dave Young
Quoted 8 lines · Cong Wang
Quoted 4 lines · Dave Young
We will also setup network when rd.neednet=1 in case no special ip= provided for convenience.
With rd.neednet=1 but without ip=, how can you know which nic we need to bring up?
Quoted 5 lines
current behavior of
net-genrule.shis below:# Default: We don't know the interface to use, handle all
It will be ok and convenient at least when we have only one nic
So, rd.neednet=1 will bring up all when there is no ip=, what kdump needs is a cmdline that tells dracut to bring up only the ones we need.
You still don't tell why re-using ip= doesn't work. So far, I think ip= can be re-used for kdump case, and is better than your rd.neeednet=1.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 17 lines · Cong Wang
Quoted 16 lines · Dave Young
Quoted 8 lines · Cong Wang
Quoted 4 lines · Dave Young
We will also setup network when rd.neednet=1 in case no special ip= provided for convenience.
With rd.neednet=1 but without ip=, how can you know which nic we need to bring up?
current behavior of
net-genrule.shis below:# Default: We don't know the interface to use, handle all
Quoted 7 lines
Quoted 1 line
It will be ok and convenient at least when we have only one nic
So, rd.neednet=1 will bring up all when there is no ip=, what kdump needs is a cmdline that tells dracut to bring up only the ones we need.
You still don't tell why re-using ip= doesn't work. So far, I think ip= can be re-used for kdump case, and is better than your rd.neeednet=1.
How to say...
There's many different configs for network like:
1. ip={dhcp|on|any|dhcp6|auto6|ibft}
2. ip=<interface>:{dhcp|on|any|dhcp6|auto6}
3. ip=<client-IP>:[ <server-id> ]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off}
4. ifname=
5. bootdev=
6. root=nfs:[snip]
They are all possibly be used, IHMO they are not good options for this patch using. For example there's no NIC specified in 1 and 3, we will still have to bring up the default
Also this is a general feature, maybe it will be used by users other than kdump. For kdump I think we can use proper ip= plus rd.neednet=1
Signature · 2 lines
Thanks Dave
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 11 lines · Dave Young
How to say...
There's many different configs for network like:
1. ip={dhcp|on|any|dhcp6|auto6|ibft}
2. ip=<interface>:{dhcp|on|any|dhcp6|auto6}
3. ip=<client-IP>:[<server-id> ]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off}
4. ifname=
5. bootdev=
6. root=nfs:[snip]
Quoted 3 lines
They are all possibly be used, IHMO they are not good options for this patch using. For example there's no NIC specified in 1 and 3, we will still have to bring up the default
Kdump module can make sure that at least one NIC will be specified, if there is ip=.
Quoted 4 lines
Also this is a general feature, maybe it will be used by users other than kdump. For kdump I think we can use proper ip= plus rd.neednet=1
Why? If we can re-use ip=, it will imply rd.neednet=1, so again, rd.neednet is not needed.
Thanks.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 21 lines · Cong Wang
Quoted 11 lines · Dave Young
How to say...
There's many different configs for network like:
1. ip={dhcp|on|any|dhcp6|auto6|ibft}
2. ip=<interface>:{dhcp|on|any|dhcp6|auto6}
3. ip=<client-IP>:[<server-id> ]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off}
4. ifname=
5. bootdev=
6. root=nfs:[snip]Quoted 3 lines
They are all possibly be used, IHMO they are not good options for this patch using. For example there's no NIC specified in 1 and 3, we will still have to bring up the default
Kdump module can make sure that at least one NIC will be specified, if there is ip=.
Quoted 1 line
Quoted 6 lines
Quoted 3 lines
Also this is a general feature, maybe it will be used by users other than kdump. For kdump I think we can use proper ip= plus rd.neednet=1
Why? If we can re-use ip=, it will imply rd.neednet=1, so again, rd.neednet is not needed.
why choose ip=? what if user pass ifname= or bootdev= without ip=? I want to benefit to other user as well, from semantic point of view one global switch like rd.neednet is more clear then reuse the various other options.
Signature · 2 lines
Thanks Dave
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 27 lines · Dave Young
Quoted 25 lines · Cong Wang
Quoted 11 lines · Dave Young
How to say...
There's many different configs for network like:
1. ip={dhcp|on|any|dhcp6|auto6|ibft}
2. ip=<interface>:{dhcp|on|any|dhcp6|auto6}
3. ip=<client-IP>:[<server-id> ]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off}
4. ifname=
5. bootdev=
6. root=nfs:[snip]Quoted 3 lines
They are all possibly be used, IHMO they are not good options for this patch using. For example there's no NIC specified in 1 and 3, we will still have to bring up the default
Kdump module can make sure that at least one NIC will be specified, if there is ip=.
Quoted 4 lines
Also this is a general feature, maybe it will be used by users other than kdump. For kdump I think we can use proper ip= plus rd.neednet=1
Quoted 5 lines
Quoted 2 lines
Why? If we can re-use ip=, it will imply rd.neednet=1, so again, rd.neednet is not needed.
why choose ip=? what if user pass ifname= or bootdev= without ip=? I
For kdump, ip= is the one we need, it has the NIC, and dhcp etc, everything we need to bring up an NIC.
If ifname= or bootdev= is provided but no ip=, we can just bring the NIC up without assigning any IP address.
Quoted 3 lines
want to benefit to other user as well, from semantic point of view one global switch like rd.neednet is more clear then reuse the various other options.
I can't agree, only specifying ip= also means bringing up network apparently.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 40 lines · Cong Wang
Quoted 27 lines · Dave Young
Quoted 25 lines · Cong Wang
Quoted 11 lines · Dave Young
How to say...
There's many different configs for network like:
1. ip={dhcp|on|any|dhcp6|auto6|ibft}
2. ip=<interface>:{dhcp|on|any|dhcp6|auto6}
3. ip=<client-IP>:[<server-id> ]:<gateway-IP>:<netmask>:<client_hostname>:<interface>:{none|off}
4. ifname=
5. bootdev=
6. root=nfs:[snip]Quoted 3 lines
They are all possibly be used, IHMO they are not good options for this patch using. For example there's no NIC specified in 1 and 3, we will still have to bring up the default
Kdump module can make sure that at least one NIC will be specified, if there is ip=.
Quoted 4 lines
Also this is a general feature, maybe it will be used by users other than kdump. For kdump I think we can use proper ip= plus rd.neednet=1
Quoted 5 lines
Quoted 2 lines
Why? If we can re-use ip=, it will imply rd.neednet=1, so again, rd.neednet is not needed.
why choose ip=? what if user pass ifname= or bootdev= without ip=? I
For kdump, ip= is the one we need, it has the NIC, and dhcp etc, everything we need to bring up an NIC.
If ifname= or bootdev= is provided but no ip=, we can just bring the NIC up without assigning any IP address.
Quoted 6 lines
Quoted 3 lines
want to benefit to other user as well, from semantic point of view one global switch like rd.neednet is more clear then reuse the various other options.
I can't agree, only specifying ip= also means bringing up network apparently.
Harald, what's your opnion? especially about the previous patch to allow manually bring up network with like 'ifup eth0 -m'? Can you give comments?
Signature · 2 lines
Thanks Dave