-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
overlay/live: support booting from live ISO without networking #326
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
@@KERNEL-ARGS@@ rd.neednet=1 ip=dhcp ignition.firstboot ignition.platform.id=metal | ||
@@KERNEL-ARGS@@ ignition.firstboot ignition.platform.id=metal |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This unit will run very early before the dracut-cmdline | ||
# service and detect if we want to request dracut bring up | ||
# networking or not. We do want to request networking if: | ||
# | ||
# - the user is booting the live ISO | ||
# - the user didn't already request networking via rd.neednet | ||
# - the user provided a ignition.config.url karg, implying | ||
# the need for networking | ||
# - there is an embedded ignition config | ||
# | ||
# For the case of the embedded Ignition config there could be a | ||
# case where the user embeds an Ignition config (via coreos-installer | ||
# iso embed) but doesn't want networking. In that case we'll have | ||
# smarter detection in the future (https://github.com/coreos/fedora-coreos-tracker/issues/443) | ||
# but the user can override with `rd.neednet=0` now if needed. | ||
# | ||
# If we do determine we need network and there are no other | ||
# `ip=` kargs then we'll use `ip=dhcp,dhcp6` by default. | ||
# | ||
# The requesting of network will be done by writing relevant | ||
# dracut networking args into /etc/cmdline.d/coreos-live-network-kargs.conf | ||
# so that it gets picked up by the dracut networking scripts later | ||
# on in boot. | ||
# | ||
# This is all done because we want to support a mode where | ||
# the user can boot the live ISO and get to an interactive | ||
# prompt without requiring networking on boot. The user can | ||
# then configure the networking interactively. | ||
# | ||
[Unit] | ||
Description=Request live ISO networking | ||
DefaultDependencies=no | ||
Before=dracut-cmdline.service | ||
|
||
# Make sure we are in the initramfs. We are booted to the live | ||
# ISO and rd.neednet wasn't already passed somewhere else | ||
ConditionPathExists=/usr/lib/initrd-release | ||
ConditionKernelCommandLine=!rd.neednet | ||
ConditionKernelCommandLine=coreos.liveiso | ||
ConditionPathExists=/run/ostree-live | ||
|
||
# We'll assume we need network in either of these two following | ||
# cases (see description from above) | ||
ConditionKernelCommandLine=|ignition.config.url | ||
ConditionPathExists=|/config.ign | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
ExecStart=/usr/sbin/coreos-liveiso-network-kargs |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/usr/bin/bash | ||
|
||
# For a description of how this is used see coreos-liveiso-network-kargs.service | ||
|
||
# Load the dracut library for getarg | ||
source /usr/lib/dracut-lib.sh | ||
|
||
main() { | ||
|
||
# If we're running this script we already know we need networking | ||
# (determined by conditionals in the systemd unit). | ||
echo 'info: Requesting networking in the initramfs' | ||
echo 'rd.neednet=1' > /etc/cmdline.d/10-coreos-liveiso-network-kargs.conf | ||
|
||
# If there is not already a ip= CLI arg use ip=dhcp,dhcp6 as default. | ||
if ! getarg 'ip' &>/dev/null; then | ||
echo 'info: using ip=dhcp,dhcp6 default networking configuration' | ||
echo 'ip=dhcp,dhcp6' >> /etc/cmdline.d/10-coreos-liveiso-network-kargs.conf | ||
else | ||
echo 'info: using already set karg ip= information' | ||
fi | ||
} | ||
|
||
main |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Configure NetworkManager-wait-online in the real root for the | ||
# Live ISO to timeout quicker and also not explicitly fail since | ||
# booting the Live ISO without network is a valid use case. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we should support an explicit API to turn off networking instead of this. Basically all we need is something like:
Then we'd just have a:
in the other service above. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note this configures the service in the real root, not in the initrd. I think we should match what the Fedora live ISO does here, which is to opportunistically set up networking if available, but otherwise not fail. Was playing around with that in the Fedora 32 Workstation live ISO in both a VM without any network adapters and one connected to an isolated network and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Oh, right.
Hmm. OK yeah I guess so. |
||
# | ||
# Doing this improves the user experience when booting the | ||
# Live ISO without network. | ||
|
||
[Unit] | ||
Description=Reconfigure NetworkManager-wait-online service | ||
DefaultDependencies=no | ||
# Make sure we are in the initramfs and we are booted to the live ISO | ||
ConditionPathExists=/usr/lib/initrd-release | ||
ConditionKernelCommandLine=coreos.liveiso | ||
ConditionPathExists=/run/ostree-live | ||
|
||
[Service] | ||
Type=oneshot | ||
RemainAfterExit=yes | ||
# Note keep this in sync with NetworkManager-wait-online.service | ||
# Right now we are keeping the same ExecStart but we are making it | ||
# OK to fail (`-`) and timeout sooner (5 seconds vs 30). | ||
ExecStartPre=/usr/bin/mkdir -p /run/systemd/system/NetworkManager-wait-online.service.d | ||
ExecStart=/bin/bash -c 'echo -e "[Service]\nExecStart=\nExecStart=-/usr/bin/nm-online -s -q --timeout=5" > /run/systemd/system/NetworkManager-wait-online.service.d/liveiso.conf' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome documentation!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks :)