-
Notifications
You must be signed in to change notification settings - Fork 95
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
Execute wipefs before ignition in live iso environment #947
Comments
You'd do something like this:
|
That would work if I would create a new iso. But how about doing that without creating a new iso? Just using kernel arguments, or even the ignition itself? |
In general, But yes, you can manually emulate what |
It requires me to take extra steps. Its simpler to download an upstream artifact and customize it at runtime. And in this case, it seems that a pre-install hook should be easier to use at runtime.
That sounds interesting. I gave it a shot, but I'm missing something fundamental, as my I've modified my iPXE script to include the suggested cmdline arguments (
The variant: fcos
version: 1.4.0
systemd:
units:
- name: live-pre-install.service
enabled: true
contents: |
[Unit]
Description=live pre install
After=coreos-installer-pre.target
Before=coreos-installer.service
[Service]
Type=oneshot
# TODO get the value of coreos.inst.install_dev kernel cmdline and call wipefs on it.
ExecStart=/usr/bin/bash -c "echo XXX Hello World; sleep 9000; exit 1"
RemainAfterExit=yes
[Install]
WantedBy=multi-user.target Which was converted to {
"ignition": {
"version": "3.3.0"
},
"systemd": {
"units": [
{
"contents": "[Unit]\nDescription=live pre install\nAfter=coreos-installer-pre.target\nBefore=coreos-installer.service\n[Service]\nType=oneshot\n# TODO get the value of coreos.inst.install_dev kernel cmdline and call wipefs on it.\nExecStart=/bin/bash -c \"echo XXX Hello World; sleep 9000; exit 1\"\nRemainAfterExit=yes\n[Install]\nWantedBy=multi-user.target\n",
"enabled": true,
"name": "live-pre-install.service"
}
]
}
} Can you please help me understand what is missing? |
Oh, you're using PXE boot and not the ISO; that makes more sense. Users typically don't want to hand-type a bunch of kernel arguments at the ISO boot prompt. Your unit isn't starting because we don't activate |
Oh, I wanted to write
Thank You! Now its working nicely! And I now understand a bit more about systemd. And indeed, it aborts the boot when the script fails. I need further help thou :-) I need to hook into the post-install phase somehow. I have to create the uefi boot option after the installation is complete successfully. Can you please hint me in what values should I use in the |
For post-install, you'll want |
Thank You! It worked nicely! :-) For future reference, here the full configuration, which wipes the boot disk before installation, then resets the uefi boot options after installation. iPXE partial script:
variant: fcos
version: 1.4.0
storage:
files:
- path: /usr/local/bin/pre-install.sh
mode: 0o555
contents:
inline: |
#!/usr/bin/bash
set -euxo pipefail
boot_device="$(sed -nE 's,.+ coreos\.inst\.install_dev=([^ ]+).*,\1,p' /proc/cmdline)"
# wipe the boot disk.
wipefs --all $boot_device
blkdiscard $boot_device
- path: /usr/local/bin/post-install.sh
mode: 0o555
contents:
inline: |
#!/usr/bin/bash
set -euxo pipefail
boot_device="$(sed -nE 's,.+ coreos\.inst\.install_dev=([^ ]+).*,\1,p' /proc/cmdline)"
firmware="$([ -d /sys/firmware/efi ] && echo 'uefi' || echo 'bios')"
if [ "$firmware" == 'uefi' ]; then
# remove all the boot options.
efibootmgr \
| sed -nE 's,^Boot([0-9A-F]{4}).*,\1,gp' \
| xargs -I% efibootmgr --quiet --delete-bootnum --bootnum %
# create the fedora boot option.
# NB if we do not set any boot option, the firmware will recover/discover
# the boot options at the next boot. unfortunately, in my test HP
# EliteDesk 800 35W G2 Desktop Mini, this requires an extra reboot,
# which messes with the ethernet speed by switching it to 10 Mbps, so
# we also create the boot option.
efibootmgr \
-c \
-d "$boot_device" \
-p 2 \
-L Fedora \
-l '\EFI\fedora\shimx64.efi'
fi
systemd:
units:
- name: live-pre-install.service
enabled: true
contents: |
[Unit]
Description=live pre install
After=coreos-installer-pre.target
Before=coreos-installer.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/pre-install.sh
RemainAfterExit=yes
[Install]
RequiredBy=coreos-installer.service
- name: live-post-install.service
enabled: true
contents: |
[Unit]
Description=live post install
After=coreos-installer.service
Before=coreos-installer.target
[Service]
Type=oneshot
ExecStart=/usr/local/bin/post-install.sh
RemainAfterExit=yes
[Install]
RequiredBy=coreos-installer.target |
It requires an extra reboot if a TPM is present and enabled, since the presence of |
Interesting. That seems to be a different problem that I'm yet to encounter. Here I have to create the uefi boot option because the extra reboot messes with the network interface speed (because this machine uses AMT for remote management, and when Remote Desktop is active, it changes the speed to a crawling 10 Mbps). After I create that uefi boot option, there is no extra reboots, the system boots directly to grub/fedora, without any extra reboots. But, I'm still missing the TPM reset part. Maybe when I do that, I'll get into the problem you've linked. I'll keep an eye on it. Thanks for the heads up! |
I meant that the extra reboot you're seeing is happening because you have a TPM. You can avoid it either by manually adding a boot entry, as you're doing, or by disabling the TPM. |
Oh, I misunderstood what was happening. Its not the firmware that is doing the reboot, its the shim (which is shared across distros). Thanks for clearing that up :-) |
Feature Request
I need a way to wipe the boot disk before installation.
Desired Feature
I need to known how can I execute
wipefs
before ignition takes over the installation.I'm asking this because, on bare metal, the disk has tainted data (e.g. another OS is there before) and I need to wipe everything to make it appear that the disk is really empty.
It seems the installer has a way to define a
--pre-install
install script, but I could not find a way to hook into that from the live iso environment. So, please help :-)The text was updated successfully, but these errors were encountered: