.
This commit is contained in:
@@ -112,8 +112,6 @@ def install_minimal_os(mount_root, releasever="43"):
|
||||
"kernel",
|
||||
"systemd",
|
||||
"dnf",
|
||||
"grub2-efi-x64",
|
||||
"shim-x64",
|
||||
"efibootmgr",
|
||||
"passwd",
|
||||
"rootfiles",
|
||||
@@ -140,7 +138,7 @@ def install_minimal_os(mount_root, releasever="43"):
|
||||
|
||||
def configure_system(mount_root, partition_info):
|
||||
"""
|
||||
Basic configuration: fstab and grub.
|
||||
Basic configuration: fstab and systemd-boot.
|
||||
"""
|
||||
logger.info("Configuring system...")
|
||||
log_os_install("CONFIGURE", "start", f"Configuring system in {mount_root}")
|
||||
@@ -160,24 +158,44 @@ def configure_system(mount_root, partition_info):
|
||||
|
||||
fstab_content = f"""
|
||||
UUID={root_uuid} / ext4 defaults 1 1
|
||||
UUID={efi_uuid} /boot/efi vfat defaults 0 2
|
||||
UUID={efi_uuid} /boot vfat defaults 0 2
|
||||
{swap_entry}
|
||||
"""
|
||||
os.makedirs(os.path.join(mount_root, "etc"), exist_ok=True)
|
||||
with open(os.path.join(mount_root, "etc/fstab"), "w") as f:
|
||||
f.write(fstab_content)
|
||||
|
||||
# 2. Configure GRUB
|
||||
# 2. Configure systemd-boot
|
||||
with mount_pseudo_fs(mount_root):
|
||||
# grub2-mkconfig -o /boot/grub2/grub.cfg
|
||||
chroot_cmd = [
|
||||
"chroot",
|
||||
mount_root,
|
||||
"grub2-mkconfig",
|
||||
"-o",
|
||||
"/boot/grub2/grub.cfg",
|
||||
]
|
||||
run_command(chroot_cmd)
|
||||
# Ensure machine-id exists for kernel-install
|
||||
if not os.path.exists(os.path.join(mount_root, "etc/machine-id")):
|
||||
run_command(["chroot", mount_root, "systemd-machine-id-setup"])
|
||||
|
||||
# Set kernel command line
|
||||
os.makedirs(os.path.join(mount_root, "etc/kernel"), exist_ok=True)
|
||||
with open(os.path.join(mount_root, "etc/kernel/cmdline"), "w") as f:
|
||||
f.write(f"root=UUID={root_uuid} rw quiet\n")
|
||||
|
||||
# Install systemd-boot to the ESP (mounted at /boot)
|
||||
run_command(["chroot", mount_root, "bootctl", "install"])
|
||||
|
||||
# Add kernel entries
|
||||
modules_dir = os.path.join(mount_root, "lib/modules")
|
||||
if os.path.exists(modules_dir):
|
||||
kvers = [d for d in os.listdir(modules_dir) if os.path.isdir(os.path.join(modules_dir, d))]
|
||||
for kver in kvers:
|
||||
logger.info(f"Adding kernel entry for {kver}...")
|
||||
kernel_image = f"/lib/modules/{kver}/vmlinuz"
|
||||
|
||||
# In Fedora, the initrd is usually created in /boot/initramfs-<version>.img
|
||||
# During installation, dnf should have triggered dracut.
|
||||
initrd_path = f"/boot/initramfs-{kver}.img"
|
||||
|
||||
cmd = ["chroot", mount_root, "kernel-install", "add", kver, kernel_image]
|
||||
if os.path.exists(os.path.join(mount_root, initrd_path.lstrip("/"))):
|
||||
cmd.append(initrd_path)
|
||||
|
||||
run_command(cmd)
|
||||
|
||||
logger.info("System configuration complete.")
|
||||
log_os_install("CONFIGURE", "complete", "GRUB configured successfully")
|
||||
log_os_install("CONFIGURE", "complete", "systemd-boot configured successfully")
|
||||
|
||||
Reference in New Issue
Block a user