-
Notifications
You must be signed in to change notification settings - Fork 80
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
Dracut initramfs boot #1191
Merged
Merged
Dracut initramfs boot #1191
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a322061
Add initramfs stage to warewulfd
JasonYangShadow 18cebb8
New warewulf-dracut subpackage
anderbubble 53dae60
New, optional dracut.ipxe configuration
anderbubble cb5146b
User documentation for dracut initramfs booting
anderbubble 48d6b63
Add tests for new iPXE template variables
JasonYangShadow 9500487
Improve the detection of SELinux capable rootfs
anderbubble 05b951d
Support dracut booting with GRUB
anderbubble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
info "Mounting tmpfs at $NEWROOT" | ||
mount -t tmpfs ${wwinit_tmpfs_size_option} tmpfs "$NEWROOT" | ||
|
||
for archive in "${wwinit_container}" "${wwinit_kmods}" "${wwinit_system}" "${wwinit_runtime}" | ||
do | ||
if [ -n "${archive}" ] | ||
then | ||
info "Loading ${archive}" | ||
(curl --silent -L "${archive}" | gzip -d | cpio -im --directory="${NEWROOT}") || die "Unable to load ${archive}" | ||
fi | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#!/bin/bash | ||
|
||
check() { | ||
# Don't include in hostonly mode | ||
[[ $hostonly ]] && return 1 | ||
|
||
# Don't include by default | ||
return 255 | ||
} | ||
|
||
depends() { | ||
echo network | ||
return 0 | ||
} | ||
|
||
install() { | ||
inst_multiple cpio curl | ||
inst_hook cmdline 30 "$moddir/parse-wwinit.sh" | ||
inst_hook pre-mount 30 "$moddir/load-wwinit.sh" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/bin/sh | ||
anderbubble marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# root=wwinit | ||
|
||
[ -z "$root" ] && root=$(getarg root=) | ||
|
||
if [ "${root}" = "wwinit" ] | ||
then | ||
info "root=${root}" | ||
export wwinit_container=$(getarg wwinit.container=); info "wwinit.container=${wwinit_container}" | ||
export wwinit_system=$(getarg wwinit.system=); info "wwinit.system=${wwinit_system}" | ||
export wwinit_runtime=$(getarg wwinit.runtime=); info "wwinit.runtime=${wwinit_runtime}" | ||
export wwinit_kmods=$(getarg wwinit.kmods=); info "wwinit.kmods=${wwinit_kmods}" | ||
|
||
wwinit_tmpfs_size=$(getarg wwinit.tmpfs.size=) | ||
if [ -n "$wwinit_tmpfs_size" ] | ||
then | ||
info "wwinit.tmpfs.size=${wwinit_tmpfs_size}" | ||
export wwinit_tmpfs_size_option="-o size=${wwinit_tmpfs_size}" | ||
fi | ||
|
||
if [ -n "${wwinit_container}" ] | ||
then | ||
info "Found root=${root} and a Warewulf container image. Will boot from Warewulf." | ||
rootok=1 | ||
else | ||
die "Found root=${root} but no container image. Cannot boot from Warewulf." | ||
fi | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#!ipxe | ||
|
||
echo | ||
echo ================================================================================ | ||
echo Warewulf v4 now booting via dracut: {{.Fqdn}} ({{.Hwaddr}}) | ||
echo | ||
echo Container: {{.ContainerName}} | ||
{{if .KernelOverride }} | ||
echo Kernel: {{.KernelOverride}} | ||
{{else}} | ||
echo Kernel: {{.ContainerName}} (container default) | ||
{{end}} | ||
echo KernelArgs: {{.KernelArgs}} | ||
echo | ||
|
||
set uri http://{{.Ipaddr}}:{{.Port}}/provision/{{.Hwaddr}}?assetkey=${asset}&uuid=${uuid} | ||
echo Warewulf Controller: {{.Ipaddr}} | ||
|
||
echo Downloading Kernel Image: | ||
kernel --name kernel ${uri}&stage=kernel || goto reboot | ||
|
||
{{if ne .KernelOverride ""}} | ||
echo Downloading Kernel Modules: | ||
imgextract --name kmods ${uri}&stage=kmods&compress=gz || initrd --name kmods ${uri}&stage=kmods || goto reboot | ||
set kernel_mods initrd=kmods | ||
{{end}} | ||
|
||
echo Downloading initramfs | ||
initrd --name initramfs ${uri}&stage=initramfs || goto reboot | ||
|
||
set dracut_net rd.neednet=1 {{range $devname, $netdev := .NetDevs}}{{if and $netdev.Hwaddr $netdev.Device}} ifname={{$netdev.Device}}:{{$netdev.Hwaddr}} {{end}}{{end}} | ||
set dracut_wwinit root=wwinit wwinit.container=${uri}&stage=container&compress=gz wwinit.system=${uri}&stage=system&compress=gz wwinit.runtime=${uri}&stage=runtime&compress=gz {{if ne .KernelOverride ""}}wwinit.kmods=${uri}&stage=kmods&compress=gz{{end}} init=/init | ||
|
||
echo Booting initramfs | ||
#echo Network KernelArgs: ${dracut_net} | ||
#echo Dracut wwinit KernelArgs: ${dracut_wwinit} | ||
#sleep 15 | ||
boot kernel initrd=initramfs ${kernel_mods} ${dracut_net} ${dracut_wwinit} wwid={{.Hwaddr}} {{.KernelArgs}} | ||
|
||
|
||
:reboot | ||
echo | ||
echo There was an error, rebooting in 15s... | ||
echo | ||
sleep 15 | ||
reboot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package container | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
|
||
"github.com/stretchr/testify/assert" | ||
warewulfconf "github.com/warewulf/warewulf/internal/pkg/config" | ||
) | ||
|
||
func TestInitramfsBootPath(t *testing.T) { | ||
conf := warewulfconf.Get() | ||
temp, err := os.MkdirTemp(os.TempDir(), "ww-conf-*") | ||
assert.NoError(t, err) | ||
defer os.RemoveAll(temp) | ||
conf.Paths.WWChrootdir = temp | ||
|
||
assert.NoError(t, os.MkdirAll(filepath.Join(RootFsDir("image"), "boot"), 0700)) | ||
|
||
tests := []struct { | ||
name string | ||
initramfs []string | ||
ver string | ||
err error | ||
retName string | ||
}{ | ||
{ | ||
name: "ok case 1", | ||
initramfs: []string{"initramfs-1.1.1.aarch64.img"}, | ||
ver: "1.1.1.aarch64", | ||
err: nil, | ||
}, | ||
{ | ||
name: "ok case 2", | ||
initramfs: []string{"initrd-1.1.1.aarch64"}, | ||
ver: "1.1.1.aarch64", | ||
err: nil, | ||
}, | ||
{ | ||
name: "ok case 3", | ||
initramfs: []string{"initramfs-1.1.1.aarch64"}, | ||
ver: "1.1.1.aarch64", | ||
err: nil, | ||
}, | ||
{ | ||
name: "ok case 4", | ||
initramfs: []string{"initrd-1.1.1.aarch64.img"}, | ||
ver: "1.1.1.aarch64", | ||
err: nil, | ||
}, | ||
{ | ||
name: "error case, wrong init name", | ||
initramfs: []string{"initrr-1.1.1.aarch64.img"}, | ||
ver: "1.1.1.aarch64", | ||
err: fmt.Errorf("Failed to find a target kernel version initramfs"), | ||
}, | ||
{ | ||
name: "error case, wrong ver", | ||
initramfs: []string{"initrr-1.1.1.aarch64.img"}, | ||
ver: "1.1.2.aarch64", | ||
err: fmt.Errorf("Failed to find a target kernel version initramfs"), | ||
}, | ||
} | ||
|
||
for _, tt := range tests { | ||
t.Logf("running test: %s", tt.name) | ||
for _, init := range tt.initramfs { | ||
assert.NoError(t, os.WriteFile(filepath.Join(RootFsDir("image"), "boot", init), []byte(""), 0600)) | ||
} | ||
initPath, err := InitramfsBootPath("image", tt.ver) | ||
assert.Equal(t, tt.err, err) | ||
if err == nil { | ||
assert.NotEmpty(t, initPath) | ||
} else { | ||
assert.Empty(t, initPath) | ||
} | ||
|
||
if tt.retName != "" { | ||
assert.Equal(t, filepath.Base(initPath), tt.retName) | ||
} | ||
// remove the file | ||
for _, init := range tt.initramfs { | ||
assert.NoError(t, os.Remove(filepath.Join(RootFsDir("image"), "boot", init))) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
die
isn't a posix shell function, so(echo "Unable to load ${archive}";exit 1)
should do the same.