From 8db3c7731a3f611a61db56bfcf8f359bbcbbf2c9 Mon Sep 17 00:00:00 2001 From: Vasilito Date: Sat, 18 Apr 2026 00:48:58 +0100 Subject: [PATCH] Update installer patch for GRUB bootloader and ext4 filesystem support Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- local/patches/installer/redox.patch | 40 ++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/local/patches/installer/redox.patch b/local/patches/installer/redox.patch index 94af0f31..250fcd87 100644 --- a/local/patches/installer/redox.patch +++ b/local/patches/installer/redox.patch @@ -163,9 +163,18 @@ index 2739983..0d2d6f3 100644 let res = with_whole_disk(&disk_path, &disk_option, |mut fs| { // Fast install method via filesystem clone diff --git a/src/config/general.rs b/src/config/general.rs -index 417ff2d..4ad2202 100644 +index 417ff2d..fab677c 100644 --- a/src/config/general.rs +++ b/src/config/general.rs +@@ -6,7 +6,7 @@ pub struct GeneralConfig { + pub prompt: Option, + /// Total filesystem size in MB + pub filesystem_size: Option, +- /// EFI partition size in MB, default to 2MB ++ /// EFI partition size in MiB, defaults to 1 MiB when not set + pub efi_partition_size: Option, + /// Skip disk partitioning, assume whole disk is a partition + pub skip_partitions: Option, @@ -19,6 +19,11 @@ pub struct GeneralConfig { /// Use AR to write files instead of FUSE-based mount /// (bypasses FUSE, but slower and requires namespaced context such as "podman unshare") @@ -191,7 +200,7 @@ index 417ff2d..4ad2202 100644 } } diff --git a/src/installer.rs b/src/installer.rs -index 4e077a9..654f6fb 100644 +index 4e077a9..ba3f9dd 100644 --- a/src/installer.rs +++ b/src/installer.rs @@ -3,6 +3,13 @@ use anyhow::{bail, Result}; @@ -478,7 +487,7 @@ index 4e077a9..654f6fb 100644 let bootloader_dir = PathBuf::from(format!("/tmp/redox_installer_bootloader_{}", process::id())); -@@ -491,36 +739,75 @@ pub fn fetch_bootloaders( +@@ -491,39 +739,78 @@ pub fn fetch_bootloaders( fs::create_dir(&bootloader_dir)?; @@ -579,7 +588,20 @@ index 4e077a9..654f6fb 100644 + result } - //TODO: make bootloaders use Option, dynamically create BIOS and EFI partitions +-//TODO: make bootloaders use Option, dynamically create BIOS and EFI partitions ++//TODO: dynamically create BIOS and EFI partitions instead of always creating both + pub fn with_whole_disk(disk_path: P, disk_option: &DiskOption, callback: F) -> Result + where + P: AsRef, +@@ -570,7 +857,7 @@ where + let gpt_reserved = 34 * 512; // GPT always reserves 34 512-byte sectors + let mibi = 1024 * 1024; + +- // First megabyte of the disk is reserved for BIOS partition, wich includes GPT tables ++ // First megabyte of the disk is reserved for BIOS partition, which includes GPT tables + let bios_start = gpt_reserved / block_size; + let bios_end = (mibi / block_size) - 1; + @@ -672,10 +959,13 @@ where fscommon::StreamSlice::new(&mut disk_file, disk_efi_start, disk_efi_end)?; @@ -893,7 +915,7 @@ index 4e077a9..654f6fb 100644 #[cfg(not(target_os = "redox"))] pub fn try_fast_install( _fs: &mut redoxfs::FileSystem, -@@ -801,6 +1348,24 @@ pub fn try_fast_install( +@@ -801,6 +1348,27 @@ pub fn try_fast_install( fn install_inner(config: Config, output: &Path) -> Result<()> { println!("Installing to {}:\n{}", output.display(), config); @@ -912,13 +934,16 @@ index 4e077a9..654f6fb 100644 + if efi_size < 8 { + bail!("GRUB bootloader requires efi_partition_size >= 8 MiB (got {} MiB). Add efi_partition_size = 16 to your config.", efi_size); + } ++ if config.general.skip_partitions.unwrap_or(false) { ++ bail!("GRUB bootloader is incompatible with skip_partitions = true. GRUB requires GPT partition layout with ESP for chainloading."); ++ } + } + } + let cookbook = config.general.cookbook.clone(); let cookbook = cookbook.as_ref().map(|p| p.as_str()); if output.is_dir() { -@@ -823,28 +1388,42 @@ fn install_inner(config: Config, output: &Path) -> Result<()> { +@@ -823,28 +1391,45 @@ fn install_inner(config: Config, output: &Path) -> Result<()> { let live = config.general.live_disk.unwrap_or(false); let password_opt = config.general.encrypt_disk.clone(); let password_opt = password_opt.as_ref().map(|p| p.as_bytes()); @@ -928,6 +953,9 @@ index 4e077a9..654f6fb 100644 if let Some(write_bootloader) = &config.general.write_bootloader { - std::fs::write(write_bootloader, &bootloader_efi)?; + let primary_efi = grub_efi.as_deref().unwrap_or(&bootloader_efi); ++ if primary_efi.is_empty() { ++ bail!("Cannot write bootloader to {:?}: EFI binary is empty (0 bytes). The recipe may have failed to produce a valid image.", write_bootloader); ++ } + std::fs::write(write_bootloader, primary_efi)?; } + let filesystem_type = match config.general.filesystem.as_deref() {