Skip to content

Commit

Permalink
dom0_kernel_installer: generate initramfs and use PARTUUID
Browse files Browse the repository at this point in the history
Using older initramfs does not work anymore as there are some kernel
module dependencies. Hence, generate a new one. Also, replace UUID with
PARTUUID since initramfs fails to understand the UUID.
  • Loading branch information
pupacha committed Mar 3, 2025
1 parent 2d5d85f commit 3dbd2b3
Showing 1 changed file with 34 additions and 8 deletions.
42 changes: 34 additions & 8 deletions lisa/transformers/dom0_kernel_installer.py
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@
from lisa import schema
from lisa.node import Node
from lisa.operating_system import CBLMariner
from lisa.tools import Cp, Echo, Ln, Ls, Sed, Tar, Uname
from lisa.tools import Cat, Cp, Echo, Ln, Ls, Sed, Tar, Uname
from lisa.util import field_metadata

from .kernel_installer import BaseInstaller, BaseInstallerSchema
@@ -128,19 +128,20 @@ def install(self) -> str:
)
else:
# Mariner 3.0 initrd
target = f"/boot/initramfs-{current_kernel}.img"
link = f"/boot/initramfs-{new_kernel}.img"
initramfs = f"/boot/initramfs-{new_kernel}.img"
dracut_cmd = f"dracut --force {initramfs} {new_kernel}"
node.execute(dracut_cmd, sudo=True, shell=True)

if isinstance(node.os, CBLMariner) and mariner_version == 2:
# Mariner 2.0 initrd
target = f"/boot/initrd.img-{current_kernel}"
link = f"/boot/initrd.img-{new_kernel}"

ln = node.tools[Ln]
ln.create_link(
target=target,
link=link,
)
ln = node.tools[Ln]
ln.create_link(
target=target,
link=link,
)

if kernel_config_path:
# Copy kernel config
@@ -243,6 +244,9 @@ def _update_mariner_config(
initrd_regexp = f"mariner_initrd_mshv=initrd.img-{current_kernel}"
initrd_replacement = f"mariner_initrd_mshv=initrd.img-{new_kernel}"

cat = node.tools[Cat]
cat.read(mariner_config, sudo=True, force_run=True)

# Modify file to point new kernel binary
sed.substitute(
regexp=vmlinuz_regexp,
@@ -258,3 +262,25 @@ def _update_mariner_config(
file=mariner_config,
sudo=True,
)

uuid = node.execute(
"lsblk -o MOUNTPOINT,UUID | grep '/ ' | awk '{print $2}'",
sudo=True,
shell=True,
expected_exit_code=0,
).stdout.strip()
partuuid = node.execute(
"lsblk -o MOUNTPOINT,PARTUUID | grep '/ ' | awk '{print $2}'",
sudo=True,
shell=True,
expected_exit_code=0,
).stdout.strip()

# initramfs can only understand PARTUUID
sed.substitute(
regexp=f"root=UUID={uuid}",
replacement=f"root=PARTUUID={partuuid}",
file=mariner_config,
sudo=True,
)
cat.read(mariner_config, sudo=True, force_run=True)

0 comments on commit 3dbd2b3

Please sign in to comment.