Goal
Create a streamlined process to generate a bootable USB stick or physical device image, enabling MeniOS to run on real x86-64 hardware for testing and validation.
Context
MeniOS currently runs in QEMU using a disk image (menios.hdd) created via dd with GPT partitioning and Limine bootloader. The long-term objective is reliable boots on real hardware (README.md:5,20).
The current build system already creates a bootable disk image with:
- GPT partition table (BIOS boot partition + EFI system partition)
- Limine bootloader (both BIOS and UEFI support)
- FAT32 filesystem with kernel and userland tools
- All necessary boot files (
limine.conf, BOOTX64.EFI)
However, there's no documented or automated way to transfer this image to a physical USB device for real hardware testing.
Current Image Creation (Makefile:794-851)
The build system creates menios.hdd with:
# Create 128MB disk image
dd if=/dev/zero bs=1M count=0 seek=128 of=menios.hdd
# Create GPT partitions
sgdisk menios.hdd -n 1:2048:4095 -t 1:ef02 # BIOS boot partition
sgdisk menios.hdd -n 2:4096 -t 2:ef00 # EFI system partition
# Format FAT32 filesystem
mformat -F -i menios.hdd@@2M
# Install Limine bootloader
limine bios-install menios.hdd
This image should theoretically be bootable on real hardware via:
sudo dd if=menios.hdd of=/dev/sdX bs=4M status=progress
Proposed Solution
1. Add make usb Target
Create a new Makefile target that:
- Verifies the disk image exists (
menios.hdd)
- Lists available USB devices (safely)
- Prompts for confirmation before writing
- Uses
dd to write the image to the specified device
- Syncs and safely unmounts
Example implementation:
.PHONY: usb
usb: build
@echo "=== MeniOS USB Creator ==="
@echo ""
@if [ ! -f $(IMAGE_NAME).hdd ]; then \
echo "Error: $(IMAGE_NAME).hdd not found. Run 'make build' first."; \
exit 1; \
fi
@echo "Available USB devices:"
@lsblk -d -o NAME,SIZE,TYPE,TRAN | grep usb || echo "No USB devices detected"
@echo ""
@echo "WARNING: This will DESTROY all data on the target device!"
@read -p "Enter device name (e.g., sdb): " DEVICE; \
read -p "Write to /dev/$$DEVICE? [y/N]: " CONFIRM; \
if [ "$$CONFIRM" = "y" ] || [ "$$CONFIRM" = "Y" ]; then \
echo "Writing $(IMAGE_NAME).hdd to /dev/$$DEVICE..."; \
sudo dd if=$(IMAGE_NAME).hdd of=/dev/$$DEVICE bs=4M status=progress conv=fsync; \
sudo sync; \
echo "Done! USB device is ready."; \
else \
echo "Aborted."; \
fi
2. Documentation
Create docs/hardware/usb_boot.md with:
Creating a Bootable USB
# Build the disk image
make build
# Write to USB device (Linux)
make usb
# Or manually:
sudo dd if=menios.hdd of=/dev/sdX bs=4M status=progress
sudo sync
macOS Instructions
# Find USB device
diskutil list
# Unmount (don't eject)
diskutil unmountDisk /dev/diskN
# Write image
sudo dd if=menios.hdd of=/dev/rdiskN bs=4m
sudo sync
# Eject
diskutil eject /dev/diskN
Boot on Real Hardware
- Insert USB drive
- Boot into BIOS/UEFI settings (usually F2, Del, or F12)
- Enable USB boot
- Select the USB drive as boot device
- Save and reboot
Troubleshooting
- Secure Boot: May need to disable in UEFI settings
- BIOS vs UEFI: Limine supports both; try toggling boot mode
- Legacy Boot: Ensure BIOS boot partition is present
- Serial Output: Connect serial cable to see kernel logs (default: COM1, 115200 baud)
3. Testing Checklist
Hardware to test on:
Boot validation:
4. Known Limitations & Future Work
Current constraints:
- Single CPU core: SMP may need tuning for real hardware
- Limited drivers: No AHCI/SATA yet (uses Limine-loaded RAM disk)
- Framebuffer only: No GPU acceleration
- PS/2 keyboard: USB keyboard requires USB HID driver
- Serial debugging: Easiest way to debug boot issues
Future enhancements:
Implementation Plan
- Phase 1: Add basic
make usb target with safety checks
- Phase 2: Create documentation with step-by-step instructions
- Phase 3: Test on multiple hardware configurations
- Phase 4: Document hardware compatibility matrix
- Phase 5: Add troubleshooting guide based on real issues
Success Criteria
Related Issues
Priority
High - This is the current long-term objective according to the README. Real hardware testing is essential for validating:
- Boot process robustness
- Driver compatibility
- Performance characteristics
- Hardware initialization edge cases
Safety Considerations
CRITICAL: The dd command can destroy data if misused. The implementation MUST:
- ✅ Require explicit device name (no defaults)
- ✅ Show clear warnings before writing
- ✅ Require confirmation prompt
- ✅ Validate device exists and is a block device
- ✅ Prevent writing to system disk (detect mounted partitions)
- ✅ Use
sync after writing to ensure data integrity
Goal
Create a streamlined process to generate a bootable USB stick or physical device image, enabling MeniOS to run on real x86-64 hardware for testing and validation.
Context
MeniOS currently runs in QEMU using a disk image (
menios.hdd) created viaddwith GPT partitioning and Limine bootloader. The long-term objective is reliable boots on real hardware (README.md:5,20).The current build system already creates a bootable disk image with:
limine.conf,BOOTX64.EFI)However, there's no documented or automated way to transfer this image to a physical USB device for real hardware testing.
Current Image Creation (Makefile:794-851)
The build system creates
menios.hddwith:This image should theoretically be bootable on real hardware via:
Proposed Solution
1. Add
make usbTargetCreate a new Makefile target that:
menios.hdd)ddto write the image to the specified deviceExample implementation:
2. Documentation
Create
docs/hardware/usb_boot.mdwith:Creating a Bootable USB
macOS Instructions
Boot on Real Hardware
Troubleshooting
3. Testing Checklist
Hardware to test on:
Boot validation:
4. Known Limitations & Future Work
Current constraints:
Future enhancements:
Implementation Plan
make usbtarget with safety checksSuccess Criteria
make usbsuccessfully creates bootable USB drivesRelated Issues
mk/runtime/run.mkor newmk/hardware/usb.mk)Priority
High - This is the current long-term objective according to the README. Real hardware testing is essential for validating:
Safety Considerations
CRITICAL: The
ddcommand can destroy data if misused. The implementation MUST:syncafter writing to ensure data integrity