Partitioning and Boot Scenarios - FlyGoat/csmwrap GitHub Wiki

Partitioning and Boot Scenarios for CSMWrap

This page outlines various methods and considerations for partitioning your storage and setting up CSMWrap to boot legacy operating systems. It is sourced from user-contributed methods with general best practices, particularly drawing from scenarios involving MBR-formatted disks and BIOS/GPT booting for Linux.

Key UEFI Settings (Recap):

  • Secure Boot: MUST be DISABLED.
  • Above 4G Decoding / Resizable BAR / Smart Access Memory: MUST be DISABLED. This is critical for legacy VBIOS compatibility as it ensures PCI resources (like VRAM) are mapped below the 4GB address space.
  • Native CSM: Try with it DISABLED first. CSMWrap aims to be its own CSM.
    • If issues occur, try enabling the native CSM as some motherboards might require it for initial low-level hardware setup. This can sometimes cause conflicts, so experimentation is key.
  • SATA Mode: Consider IDE/Compatible for very old OSes like Windows XP if AHCI drivers are an issue.
  • USB Legacy Support: ENABLED.

Understanding MBR vs. GPT with CSMWrap

CSMWrap aims to create a legacy BIOS environment. Legacy BIOS traditionally boots from disks formatted with a Master Boot Record (MBR).

  • MBR (Master Boot Record):

    • The first 512 bytes of the disk contain the bootloader code and the partition table.
    • Limited to 4 primary partitions, or 3 primary and 1 extended partition (which can contain multiple logical partitions).
    • Maximum addressable disk size is typically 2TiB.
    • CSMWrap generally expects to boot legacy OSes from MBR-formatted disks. The methods below primarily focus on this for OSes like DOS/Windows.
  • GPT (GUID Partition Table):

    • Modern standard, part of UEFI. Uses GUIDs for disks and partitions.
    • Supports a much larger number of partitions and larger disk sizes.
    • Includes a "protective MBR" for compatibility with MBR-only tools.
    • BIOS/GPT Booting: It's possible to boot a legacy BIOS system (or an emulated one like CSMWrap provides) from a GPT disk if the bootloader (like GRUB) supports it. This requires a special BIOS Boot Partition.

Recommendation:

  • For DOS/Windows legacy OSes with CSMWrap: Use an MBR-formatted hard drive for the OS installation for simplicity.
  • For Linux distributions in legacy BIOS mode with CSMWrap: You can use a GPT-formatted disk, but it requires specific setup for GRUB (see Scenario 5).

Booting Scenarios

The following methods describe how to set up CSMWrap and the target OS. Most involve an initial step of launching csmwrap<ARCH>.efi (renamed to BOOT<ARCH>.EFI) from a FAT32 partition accessible by UEFI. CSMWrap then creates the legacy environment for the actual OS boot.

Important General Notes:

  • Install Legacy OS First (Generally): For MBR-based OSes like DOS/Windows, install your target legacy OS in Legacy Boot Mode to the MBR disk first.
  • EFI/BOOT Folder for CSMWrap: This folder needs to be on a partition that the UEFI firmware can read (typically FAT16/FAT32) to launch CSMWrap.
    • If your legacy OS partition is NTFS/ext2/etc., you might need a small, separate FAT32 "boot" partition (or USB) to hold BOOTX64.EFI (CSMWrap).
  • Windows Considerations: If installing Windows 7 or later, and it created its own EFI folder during a previous UEFI attempt, you might need to delete or rename it on the Windows partition before creating your EFI/BOOT folder for CSMWrap.

Scenario 1: Single Hard Drive, Single Partition (OS Partition is FAT32, MBR Disk)

  • Applies to: OS like FreeDOS on a single FAT32 partition.
  • Disk Format: MBR.
  • Steps:
    1. Install the legacy OS in Legacy Boot Mode.
    2. On the OS partition (which is FAT32), create EFI\BOOT.
    3. Copy csmwrapx64.efi (or csmwrapia32.efi) to EFI\BOOT and rename it to BOOTX64.EFI (or BOOTIA32.EFI).
    4. Configure UEFI to boot from the hard drive. It should find BOOTX64.EFI.

Scenario 2: Single Hard Drive, Single Partition (Using EFI Shell, MBR Disk)

  • Applies to: Useful for complex boot sequences. Assumes OS partition is FAT32 or a separate FAT32 partition for the EFI shell.
  • Disk Format: MBR.
  • Steps:
    1. Install legacy OS in Legacy Boot Mode.
    2. On a FAT32 partition:
      • Create EFI\BOOT.
      • Copy UEFI Shell (e.g., Shellx64.efi) to EFI\BOOT and rename to BOOTX64.EFI.
      • Copy csmwrapx64.efi to the same folder (or root).
    3. Create startup.nsh in the root of the FAT32 partition to launch csmwrapx64.efi. (See Usage Guide for startup.nsh examples).
    4. Configure UEFI to boot from the partition with the EFI Shell.

Scenario 3: Single/Multiple Hard Drives, Multiple Partitions (OS Partition not FAT32, MBR Disk)

  • Applies to: Common for Windows (NTFS) or non-boot Linux (ext4) installations.
  • Disk Format: OS disk is MBR.
  • Requires a separate small FAT32 partition (or USB) for CSMWrap's EFI launcher.
  • Steps (Dedicated FAT32 Partition):
    1. Install legacy OS in Legacy Boot Mode to its MBR partition.
    2. Create a small (e.g., 100-500MB) FAT32 partition.
    3. On this FAT32 partition, create EFI\BOOT.
    4. Copy csmwrapx64.efi to EFI\BOOT and rename to BOOTX64.EFI.
    5. Configure UEFI to boot from this FAT32 partition. CSMWrap launches, then boots the legacy OS.
  • Steps (EFI Shell on Dedicated FAT32 Partition): As above, but place EFI Shell as BOOTX64.EFI and use startup.nsh to launch csmwrapx64.efi.

Scenario 4: Booting CSMWrap from a FAT16/32 Formatted USB Drive

  • Applies to: Portability, testing. Legacy OS usually on internal MBR HDD.
  • USB Drive Format: FAT16 or FAT32.
  • Steps (Direct Boot of CSMWrap from USB):
    1. On USB, create EFI\BOOT.
    2. Copy csmwrapx64.efi to USB's EFI\BOOT and rename to BOOTX64.EFI.
    3. Configure UEFI to boot from USB first.
    4. When SeaBIOS (via CSMWrap) starts, use its boot menu (often ESC) to select the internal HDD.
  • Steps (EFI Shell on USB): Similar to above, but USB's BOOTX64.EFI is the EFI Shell, and startup.nsh on USB launches csmwrapx64.efi (also on USB).

Scenario 5: Booting Linux (e.g., Arch Linux) in BIOS Mode from a GPT Disk via GRUB

This scenario is for users who want to install a Linux distribution on a GPT disk but need/want to boot it in legacy BIOS mode (which CSMWrap will provide). GRUB is used as the legacy bootloader for Linux.

  • Prerequisites:
    • CSMWrap is set up to launch from UEFI (e.g., from a USB drive as in Scenario 4, or a small FAT32 partition on the GPT disk itself if you create one for BOOTX64.EFI).
    • The target Linux distribution installed on GPT partitions.
  • Disk Format: GPT for the Linux installation disk.
  • Steps:
    1. Create a BIOS Boot Partition:
      • On your GPT disk where Linux is (or will be) installed, create a small partition (typically 1MiB is sufficient, though some recommend up to 2MiB).
      • This partition must not be formatted with a filesystem.
      • Partition Type GUID: 21686148-6449-6E6F-744E-656564454649
      • Using gdisk: Type code ef02.
      • Using fdisk (recent versions): Type BIOS boot.
      • Using parted: Set the bios_grub flag on this partition.
      • This partition can be anywhere but must be within the first 2TiB of the disk.
    2. Install Linux: Install your Linux distribution to its desired GPT partitions (e.g., /, /home, swap).
    3. Install GRUB (for BIOS/GPT):
      • Boot into your Linux installation (you might need to use a live environment and chroot if it's a fresh install).
      • Ensure the grub package is installed.
      • Install GRUB's BIOS bootloader components to the MBR area (which points to the BIOS Boot Partition on GPT disks):
        sudo grub-install --target=i386-pc /dev/sdX
        Replace /dev/sdX with the actual device name of your GPT disk (e.g., /dev/sda, /dev/nvme0n1). Do NOT specify a partition number. This command embeds GRUB's core.img into the BIOS Boot Partition.
    4. Generate GRUB Configuration:
      sudo grub-mkconfig -o /boot/grub/grub.cfg
    5. Boot Process:
      • Boot your system via UEFI into CSMWrap.
      • CSMWrap initializes the legacy BIOS environment.
      • SeaBIOS (within CSMWrap) scans for bootable devices. It should detect the GPT disk with the GRUB MBR/BIOS Boot Partition setup.
      • GRUB (the legacy version installed in step 3) loads from the BIOS Boot Partition, displays its menu, and boots your Linux installation.

Considerations for BIOS/GPT Linux Boot via CSMWrap:

  • CSMWrap as the Enabler: CSMWrap provides the foundational legacy BIOS environment. GRUB then acts as the secondary bootloader specifically for your Linux system within that emulated environment.
  • UEFI Chainload (Alternative for CSMWrap launch): Instead of a USB, you could have a small FAT32 EFI System Partition on your GPT disk. Place csmwrap<ARCH>.efi as BOOT<ARCH>.EFI there. The UEFI firmware boots CSMWrap from this ESP, and then CSMWrap/SeaBIOS boots GRUB from the BIOS Boot Partition on the same disk.

Scenario 6: Chainloading CSMWrap from an Existing UEFI GRUB (Advanced)

If you already use GRUB (for UEFI) as your primary bootloader (e.g., for a modern Linux), you can chainload csmwrap.efi.

  1. Place csmwrap<ARCH>.efi: Copy to your ESP, e.g., esp/EFI/csmwrap/csmwrapx64.efi.
  2. Add GRUB Menu Entry:
    menuentry "Launch CSMWrap for Legacy OS" {
        insmod part_gpt # or part_msdos
        insmod fat
        insmod chain
        search --no-floppy --fs-uuid --set=root YOUR_ESP_UUID
        chainloader /EFI/csmwrap/csmwrapx64.efi
    }
    
    Replace YOUR_ESP_UUID and adjust the path.
  3. Update GRUB Config: sudo grub-mkconfig -o /boot/grub/grub.cfg.
  4. Select the new entry from your UEFI GRUB menu. CSMWrap then boots the legacy OS.

This combination of methods should provide flexibility for various disk layouts and user preferences when setting up CSMWrap. Remember to consult the Troubleshooting page if you encounter issues.

⚠️ **GitHub.com Fallback** ⚠️