Dual Booting Batocera And Windows

[ ]

The Batocera documentation includes instructions for dual booting Batocera and Windows. However, these are aimed at dual booting from a single drive.

In my PC-based arcade cabinet, I wanted the opposite - to keep the OS’s completely separate but avoid the need to use the BIOS boot menu. The answer is to install GRUB on its own USB stick and point the config to the Batocera and Windows bootloaders.

Some way of interacting with the menu is still required. I use a 12-key mini keyboard bought from Amazon, with software-configurable keys and dials. This also helps with interacting with Windows. In theory it should be possible to load the kernel modules needed to use the cabinet’s joysticks and buttons but that’s a challenge for another time.

Note that it takes a fair amount of tinkering with Windows to get it working nicely with an arcade cabinet set-up, though it’s entirely doable. It’s also worth noting that with a bit of knowledge and effort, Windows games can be made to run using WINE and Batocera. Batocera’s user-friendly wrapper around WINE is very solid, meaning Windows is only needed for edge cases.

Get the device for the USB stick using lsblk. Assuing it’s /dev/sda, create the EFI partition:

sudo parted /dev/sda -- mklabel gpt
sudo parted /dev/sda -- mkpart primary fat32 1MiB 100%
sudo parted /dev/sda -- set 1 esp on
sudo mkfs.vfat -F 32 /dev/sda1

Mount the ESP partition:

mkdir -p ~/usb_mnt
sudo mount /dev/sda1 ~/usb_mnt

Install GRUB:

sudo grub-install --target=x86_64-efi --efi-directory=$HOME/usb_mnt --boot-directory=$HOME/usb_mnt/boot --removable --recheck

Create and edit the GRUB config file:

sudo mkdir -p ~/usb_mnt/boot/grub
sudo nano ~/usb_mnt/boot/grub/grub.cfg

Get the UUID (not PARTUUID) of the Windows EFI partition by running sudo blkid on the target machine.

set timeout=10
set quiet=1
set default=0

menuentry "Batocera" {
      search --set=root --label BATOCERA
      linux /boot/linux label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0
      initrd /boot/initrd.gz
}

menuentry "Windows" {
    insmod part_gpt
    insmod chain
    search --no-floppy --fs-uuid --set=root FA00-FF3B
    chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi
}

Unmount the USB drive with sudo umount /dev/sda1.

Insert in the target machine and ensure that the BIOS boot order has it at the top.

Run the GRUB install command again:

sudo grub-install --target=x86_64-efi --efi-directory=$HOME/usb_mnt --boot-directory=$HOME/usb_mnt/boot --removable --recheck