Skip to content

Commit

Permalink
Merge pull request warewulf#822 from elfurbe/init-rootfs-fixes
Browse files Browse the repository at this point in the history
Init rootfs fixes
  • Loading branch information
mslacken authored Sep 18, 2024
2 parents 43b298f + 771fbd3 commit cd39a76
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).

- Return an error during `wwctl container import` if archive filename includes a colon. #1371
- Correctly extract smbios asset key during Grub boot. #1291
- Refactor of `wwinit/init` to more properly address rootfs options. #1098

## v4.5.7, 2024-09-11

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,3 +38,4 @@
* Tobias Poschwatta <[email protected]>
* Josh Burks <[email protected]>
* Elmar Pruesse <[email protected]> @epruesse
* Adam Michel <[email protected]> [@elfurbe](https://github.com/elfurbe)
45 changes: 26 additions & 19 deletions overlays/wwinit/rootfs/init
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@
# Edit at your own risk! DANGER DANGER.


if test -f "/warewulf/config"; then
if [ -f "/warewulf/config" ]; then
. /warewulf/config
else
echo "ERROR: Warewulf configuration file not found... rebooting in 1 minute"
sleep 60
echo b > /proc/sysrq-trigger || /sbin/reboot
fi

echo "Warewulf v4 is now booting: $WWHOSTNAME"
echo "Warewulf v4 is now booting: ${WWHOSTNAME}"
echo

echo "Mounting up kernel file systems"
Expand All @@ -26,31 +26,38 @@ mount -t tmpfs tmpfs /run

chmod 755 /warewulf/wwinit

echo "Checking Rootfs type"
echo -n "Checking Rootfs type..."
ROOTFSTYPE=`stat -f -c "%T" /`
echo "${ROOTFSTYPE}"

if test "$WWROOT" = "initramfs"; then
echo "Provisioned to default initramfs file system: $ROOTFSTYPE"
echo "Calling WW Init"
exec /warewulf/wwinit
elif test "$WWROOT" = "tmpfs"; then
if test "$ROOTFSTYPE" = "tmpfs"; then
echo "ERROR: Switching the root file system requires the kernel argument: 'rootfstype=ramfs'"
else
echo "Setting up tmpfs root file system"

if [ -n "${WWROOT}" ] && [ "${WWROOT}" != "${ROOTFSTYPE}" ]; then
echo "Requested rootfs type does not match current rootfs type. Pivoting to new rootfs..."
if [ "${WWROOT}" == "ramfs" ] || [ "${WWROOT}" == "tmpfs" ]; then
mkdir /newroot
mount wwroot /newroot -t tmpfs -o mpol=interleave
echo "Moving RAMFS to TMPFS"
tar -cf - --exclude ./proc --exclude ./sys --exclude ./dev --exclude ./newroot . | tar -xf - -C /newroot
mount wwroot /newroot -t ${WWROOT} -o mpol=interleave
tar cf - --exclude ./proc --exclude ./sys --exclude ./dev --exclude ./run --exclude ./newroot . | tar xf - -C /newroot
mkdir /newroot/proc /newroot/dev /newroot/sys /newroot/run 2>/dev/null
echo "Calling switch_root and invoking WW Init"
echo "Switching to new rootfs and invoking /warewulf/wwinit..."
exec /sbin/switch_root /newroot /warewulf/wwinit
elif [ "${WWROOT}" == "initramfs" ]; then
echo ">>> Deprecated option \"initramfs\" chosen."
echo ">>> The 'initramfs' can be either a ramfs or a tmpfs natively, depending on kernel configuration."
echo ">>> If you wish to use whatever this kernel chooses by default, remove the 'root' setting from your nodes/profiles."
echo "Invoking /warewulf/wwinit..."
exec /warewulf/wwinit
else
echo "Unrecognized rootfs type requested: ${WWROOT}"
echo "Rebooting in 1 minute..."
sleep 60
/sbin/reboot -f
fi
else
echo "ERROR: Unknown Warewulf Root file system: $WWROOT"
echo "Invoking /warewulf/wwinit..."
exec /warewulf/wwinit
fi

echo
echo "There was a problem with the provisioning process, rebooting in 1 minute..."
echo "There was a problem with the initial provisioning process, rebooting in 1 minute..."
sleep 60
echo b > /proc/sysrq-trigger || /sbin/reboot
echo b > /proc/sysrq-trigger || /sbin/reboot -f

0 comments on commit cd39a76

Please sign in to comment.