Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
dual_boot_ubuntu_batocera.linux [2022/09/08 06:48] – add rEFInd instructions, improve automatic Windows grub instructions ataridual_boot_ubuntu_batocera.linux [2024/09/21 20:15] (current) – [Ventoy] maximumentropy
Line 20: Line 20:
  
 For those that prefer video guides (there is... no actual need to flash a spare USB drive, just download the boot.tar.xz): [[https://www.youtube.com/watch?v=VjyBKHadbgw|Pleilleur's Choice #1 Dualboot Windows 10 and Batocera]] For those that prefer video guides (there is... no actual need to flash a spare USB drive, just download the boot.tar.xz): [[https://www.youtube.com/watch?v=VjyBKHadbgw|Pleilleur's Choice #1 Dualboot Windows 10 and Batocera]]
 +
 +This guide is assuming Windows is being booted from an EFI partition. If it isn't, or you don't know, **proceed at your own risk**.
  
 === Preparing the drive === === Preparing the drive ===
  
-Partition the drive, having a GB FAT32 partition after the Windows drive immediately followed by the "userdata" partition, which can be [[:batocera.linux_architecture#using_an_alternative_filesystem_for_userdata|any compatible filesystem]]. If preferred, it is also possible to [[:store_games_on_a_second_usb_sata_drive|have Batocera to use the Windows partition as its userdata]], however that requires manually setting it up before the rest of the installation so for first-timers this is not recommended.+Partition the drive, having a GB FAT32 partition after the Windows drive immediately followed by the "userdata" partition, which can be [[:batocera.linux_architecture#using_an_alternative_filesystem_for_userdata|any compatible filesystem]]. If preferred, it is also possible to [[:store_games_on_a_second_usb_sata_drive|have Batocera to use the Windows partition as its userdata]], however that requires manually setting it up before the rest of the installation so for first-timers this is not recommended.
  
 Extract and copy the latest [[https://mirrors.o2switch.fr/batocera/x86_64/stable/last/boot.tar.xz|Batocera ''boot.tar.xz'']] (can be extracted with 7-zip) to the root of the FAT32 partition. Its contents should look similar to the following: Extract and copy the latest [[https://mirrors.o2switch.fr/batocera/x86_64/stable/last/boot.tar.xz|Batocera ''boot.tar.xz'']] (can be extracted with 7-zip) to the root of the FAT32 partition. Its contents should look similar to the following:
Line 46: Line 48:
   - Click **Add New Entry** near the top of the window.   - Click **Add New Entry** near the top of the window.
   - Under "Type", select **Custom code**.   - Under "Type", select **Custom code**.
-  - Name the "Title" as "Batocera", and place it in whichever slot desired. +  - Name the "Title" as "Batocera", place it in whichever "Menu Slot" desired and reduce the "Pause Seconds" to **0**
- +  - Click **Edit Custom Code**. A text document will be opened with the default text editorPaste in the following and save the file, for Batocera **v39** and higher<code> 
-==== Manually ==== + set efibootmgr=/EFI/batocera/bootx64.efi 
- +     getpartition  file  $efibootmgr  root 
-You will likely have to wipe your hard drive's contents to do this, so no data can be carried over from a pre-existing Windows installationTo dual boot Windows and Batocera on the same drive+     if [ ! -z $reviewpause ] ; then 
- +  echo GNU Grub will load the Batocera EFI Boot Manager at disk address $root 
-  - Partition your intended drive to begin with a large physical NTFS partition for Windows. It is recommended to use a GPT partition table. The rest of the free space will be used for Batocera. +         g2wsleep   
-  - Install Windows via your preferred method. It will re-partition the existing NTFS partition into smaller logical partitions, but should retain its total size. +     fi 
-  - In the empty space, add a new physical FAT32 partition around 8GB in size (can be larger if you want, but not smaller) labelled "BATOCERA". This will be used for Batocera's boot files+     echo GNU Grub is now loading the Batocera EFI Boot Manager 
-  - Immediately after the BATOCERA partition, create another partition to fill up the rest of the drive. This will be used as the "internal" userdata. [[:add_games_bios#userdata_filesystem_options|Check out which filesystem to use.]] If you'd like to allow Windows to access the userdata partition, it is recommended to use exFAT or NTFS. BTRFS can also work, but requires kernel drivers for Windows to be installed to allow access to it. +     chainloader $efibootmgr 
-  - Rename the folders in Windows' EFI partition from ''EFI/Boot'' to ''EFI/Boot_backup'' +     savelast 1 'Batocera' 
-  - Download [[https://updates.batocera.org/grub/EFI_WINDOWS.zip|this ZIP file]] and extract it. +</code>For Batocera **v38** and lower: <code> 
-  - Copy the contents of ''EFI_WINDOWS'' to Windows' EFI partitionThe ''BOOT'' folder should be in the same spot as the old ''Boot'' folder was+ set efibootmgr=/EFI/BOOT/bootx64.efi 
-  - Boot into Batocera from a USB drive, run ''blkid /dev/sda#'' (where ''sda#'' is the Windows EFI partition) and note down the ID of the partition. +     getpartition  file  $efibootmgr  root 
-    FIXME (confirmation needed) To do this on Windows itselfopen an administrator command prompt and run ''diskpart'', ''list disk'', ''select disk=#'' (where # is the number of the disk with Windows EFI on it, usually 0), ''uniqueid disk'' to get your disk ID (add the hyphen in the middle){{ :diskpart-disk-id.png?nolink |}} +     if [ ! -z $reviewpause ] ; then 
-  - Open ''ubuntu/grub.cfg'' and change ''2AD8-4A0C'' to the ID of the partition. + echo GNU Grub will load the Batocera EFI Boot Manager at disk address $root 
- +         g2wsleep   
-The final ''grub.cfg'' file should look like this: <file - grub.cfg>set default=0 +     fi 
-set timeout=5 +     echo GNU Grub is now loading the Batocera EFI Boot Manager 
- +     chainloader $efibootmgr 
-menuentry 'Windows 10' { +     savelast 1 'Batocera' 
-  search --fs-uuid --no-floppy --set=root 2AD8-4A0C +</code> <WRAP center round tip> 
-  chainloader (${root})/EFI/Microsoft/Boot/bootmgfw.efi +Pleillear keeps an updated copy of the file at [[https://drive.google.com/file/d/1L5bf_DNFhYDFIieS8ktj41rbVfPRAD67/view|this Google Drive link]], so check that if this page hasn't been updated for a while.  Note that the file at this Google Drive link is not up to date for v39, and would need ''set efibootmgr=/EFI/BOOT/bootx64.efi'' changed to ''set efibootmgr=/EFI/batocera/bootx64.efi'' 
-+</WRAP> 
- +  - Close the text editor
-menuentry "batocera.linux" { +  - Grub2win will then scan the code for mistakesIf all goes well, click **OK**, followed by **OK**. 
-  search --set=root --label BATOCERA +  - Check that the Batocera listing is correct and in the menu slot desiredThen click **Apply**
-  linux /boot/linux label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 +  - Set any further cosmetic settings desiredLower the "Grub timeout" from **30** down to **10** and change the background by clicking on the previewWhen done, click **OK**
-  initrd /boot/initrd.gz +  - Grub2win will then install the desired boot menu onto the driveGreen means it's good. Click **Close**
-+  - Reboot and pray to whatever entity that you want that it worked.
-</file>+
  
-===== Dual boot Batocera and iOS/using rEFInd =====+===== Dual boot Batocera and MacOS or other UEFI-based x86_64 systems using rEFInd =====
  
 <WRAP center round important> <WRAP center round important>
Line 131: Line 132:
 EOF EOF
 </file> </file>
 +  - Make it executable by running ''sudo chmod +x /etc/grub.d/50_batocera''
   - Run ''sudo update-grub''   - Run ''sudo update-grub''
   - Reboot   - Reboot
Line 156: Line 158:
   * Partition 2: type = ext4. It must be created and placed right after the ''BATOCERA'' partition.   * Partition 2: type = ext4. It must be created and placed right after the ''BATOCERA'' partition.
  
-Then download [[http://batocera.org/upgrades/x86_64/stable/last/boot.tar.xz|boot.tar.xz]] and unzip it on the ''BATOCERA'' partition.+Then download [[https://batocera.org/upgrades/x86_64/stable/last/boot.tar.xz|boot.tar.xz]] and unzip it on the ''BATOCERA'' partition.
  
 <WRAP center round tip> <WRAP center round tip>
Line 186: Line 188:
 </file> </file>
     * The file can also be automatically downloaded with the following command: <code>     * The file can also be automatically downloaded with the following command: <code>
-sudo wget https://batocera.org/upgrades/grub/15_batocera -O /etc/grub.d/15_batocera+sudo wget 'https://wiki.batocera.org/_export/code/dual_boot_ubuntu_batocera.linux?codeblock=4' -O /etc/grub.d/15_batocera
 </code> </code>
   - Then run the following commands: <code>   - Then run the following commands: <code>
Line 206: Line 208:
 Technically, this isn't really dual-booting, but booting a static image already loaded onto your drive's filesystem as its own mounted filesystem. It can ease the process of updating the image, however this is probably unnecessary as Batocera itself has [[:updates_and_downloads|its own updating tool]]. Nonetheless it could be useful for machines that otherwise don't have an internet connection and have to rely on another one to update or machines that absolutely refuse to boot via conventional manners. Technically, this isn't really dual-booting, but booting a static image already loaded onto your drive's filesystem as its own mounted filesystem. It can ease the process of updating the image, however this is probably unnecessary as Batocera itself has [[:updates_and_downloads|its own updating tool]]. Nonetheless it could be useful for machines that otherwise don't have an internet connection and have to rely on another one to update or machines that absolutely refuse to boot via conventional manners.
  
-By default, Batocera's userdata partition is only 512MB before expanding, obviously not large enough to do anything. Ventoy's boot process prevents Batocera from seeing the drive as having any available free space, so auto-expansion on the first boot never occurs. This can be solved by either //only// mounting Batocera's boot partition (thus making the next immediate partition the userdata partition, whatever that may be) or by running the following (replace ''#'' with the number of GB you want in **total**, including the boot partition):+By default, Batocera's userdata partition is only 512MB before expanding, obviously not large enough to do anything. Ventoy uses the booted image file as a virtual hard disk, so with a factory-provided image, the userdata partition can't be auto-expanded beyond the baseline 512MB at first boot. This can be solved by either //only// mounting Batocera's boot partition (thus making the next immediate partition the userdata partition, whatever that may be) or by running the following (replace ''#'' with the number of GB you want in **total**, including the boot partition):
  
 <code> <code>
Line 222: Line 224:
 gparted /dev/loop * gparted /dev/loop *
 </code> </code>
 +
 +If you prefer using a script instead of manual procedures, this will add a specified amount of space to a Batocera image file, 
 +and will expand the /userdata SHARE partition to fill the added space:
 +
 +<code bash| batocera-ventoy-resize.sh>
 +#!/bin/bash
 +# batocera-ventoy-resize.sh 20240921 n2qz/maximumentropy
 +# Expand a Batocera installation image file to make storage space
 +# available in SHARE when booting the image from Ventoy.
 +#
 +# Tested on Ubuntu 24.04.1 LTS with e2fsprogs 1.47.0. May not work on
 +# older versions of linux, as current Batocera images (v41+) use newer
 +# ext4 features not available with older ext4 utilities
 +err () {
 +    exitcode=$?
 +    echo "... Exit code $exitcode on line ${BASH_LINENO[0]} while executing command: $BASH_COMMAND"
 +    exit $exitcode
 +}
 +trap err ERR
 +growsize="$1"
 +inputimage="$2"
 +outputimage="$3"
 +if [ -z "${growsize}" -o -z "${inputimage}" -o "${inputimage}" = "${outputimage}" -o "${outputimage}" != "$(basename "${outputimage}" .gz)" ]
 +then
 +    echo "Usage: $0 growsize inputimage[.gz] [outputimage]"
 +    echo "Example: $0 32G batocera.img ventoy.img"
 +    exit 2
 +fi
 +image=$(basename "${inputimage}" .gz)
 +if [ -z "${outputimage}" ]
 +then
 +    outputimage="ventoy-${image}"
 +fi
 +if [ "${inputimage}" = "${image}" ]
 +then
 +    echo "... Copy ${inputimage} to ${outputimage}"
 +    cp "${inputimage}" "{$outputimage}"
 +else
 +    echo "... Decompress ${inputimage} to ${outputimage}"
 +    gzip -vkcd "${inputimage}" > "${outputimage}"
 +fi
 +echo "... Grow image ${outputimage}"
 +truncate -s "+${growsize}" "$outputimage"
 +echo "... Set up loopback device"
 +lodev=$(sudo losetup --find --show --partscan "${outputimage}")
 +echo "... Loopback device is: ${lodev}"
 +sharepart=2
 +sharepartdev="${lodev}p${sharepart}"
 +echo "... Adjust GPT on ${lodev}"
 +sudo sgdisk -e "${lodev}"
 +echo "... Show free space on ${sharepartdev}"
 +sudo dumpe2fs "${sharepartdev}" | grep '^Free blocks'
 +echo "... Resize SHARE partition ${sharepartdev}"
 +sudo parted -s "${lodev}" "resizepart ${sharepart} 100%"
 +echo "... Check ${sharepartdev}"
 +sudo fsck -f "${sharepartdev}"
 +echo "... Grow ${sharepartdev}"
 +sudo resize2fs "${sharepartdev}"
 +echo "... Show free space on ${sharepartdev}"
 +sudo dumpe2fs "${sharepartdev}" | grep '^Free blocks'
 +echo "... Detach loopback device ${lodev}"
 +sudo losetup -d "${lodev}"
 +echo "... Successfully completed"
 +</code>
 +
  
  • dual_boot_ubuntu_batocera.linux.1662619738.txt.gz
  • Last modified: 4 years ago
  • by atari