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 [2020/05/25 00:42] lbrpdxdual_boot_ubuntu_batocera.linux [2023/12/28 01:11] (current) lbrpdx
Line 1: Line 1:
-~~NOTOC~~+====== Dual boot Batocera ======
  
-===== Install Ubuntu ===== +It is recommended to boot Batocera off of a USB/other external drive and to [[:install_batocera|use your BIOS boot selection menu]] to switch between Batocera and other operating systems that may already be on other drives. You can still [[:store_games_on_a_second_usb_sata_drive|use drives with other operating systems on them]] to host your userdata such as ROMs, BIOS files, saves, etc. This is the far simpler option to do instead of what you'll have to do if you only want to do everything from one drive. However, some people prefer to have Batocera directly installed on the main hard drive alongside another pre-existing OSes, this page is for that.
-Follow your favorite method for the initial Ubuntu install.+
  
-Once Ubuntu ins installed, make sure the command ''grub-customizer'' is available on your system (it is available from Ubuntu repositories).+<WRAP center round alert> 
 +Before attempting //any// of this**make a backup of your data**. There is a chance that the following actions (shrinking partitions, replacing boot loaders, etc.can render the storage devices inoperable.
  
-===== Batocera partitions ===== +If this sounds too spooky to youjust [[:install_batocera|flash Batocera to a USB drive]] as is recommended and use that instead. 
-Create 2 consecutive partitions on your hard drive +</WRAP>
-  * partition 1 : type = fat32name = BATOCERA +
-  * partition 2 : type = ext4. It must be created right after the BATOCERA partition. +
-  * download [[http://batocera.org/upgrades/x86_64/stable/last/boot.tar.xz boot.tar.xz]] and unzip it on the BATOCERA partition.+
  
-===== Configure the Ubuntu grub =====+Ordinarily, Batocera utilizes [[https://wiki.syslinux.org/wiki/index.php?title=The_Syslinux_Project|Syslinux]] to boot, which is configured to only boot Batocera. Thus, for most dual boot setups we will be utilizing [[https://www.gnu.org/software/grub/|GRUB]] to show a boot selection menu after BIOS has loaded instead.
  
-Use ''grub-customizer'': create **new** and write BATOCERA as its name or anything you like, with type "other".+<WRAP center round important> 
 +In case you install Batocera on your hard-drive, you may want to rename the BATOCERA partition to something unique like BATOPC. If you do, edit the ''grub.cfg'' file below to have ''label=BATOPC'' instead of ''label=BATOCERA''. This allows you to still boot using Batocera installed on a USB without worry that the hard-drive will always take priority due to sharing the same label. 
 +</WRAP>
  
-Then, with ''gparted'', find the UUID from your BATOCERA partition. In the example below, **3377-44C4** is my UUID, don't forget to adapt to yours.+===== Dual boot Batocera and Windows =====
  
-Paste the following code: +==== Automatically ==== 
-  insmod fat + 
-  search --no-floppy --fs-uuid --set=root 3377-44C4 +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]] 
-  linux /boot/linux label=BATOCERA console=tty3 quiet  loglevel=0 vt.global_cursor_default=0 + 
-  initrd /boot/initrd.gz+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 === 
 + 
 +Partition the drive, having a 8 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: 
 + 
 +<code> 
 +D:\ 
 +├─ boot\ 
 +├─ EFI\ 
 +├─ tools\ 
 +└─ batocera-boot.conf 
 +</code> 
 + 
 +=== Installing GRUB over Windows' boot manager === 
 + 
 +Download and install [[https://sourceforge.net/projects/grub2win/|grub2win]]. It may come up as a false positive on anti-virus software, we are going to be overiding the boot manager which could potentially prevent Windows from booting so maybe they are right in that regard. Either way, just let it through to continue. 
 +  - Extract the grub2win ZIP, and run ''setup.exe''
 +  - Allow grub2win to download the latest EFI package for your operating system. 
 +  - Ensure the target drive is the one the system boots into by default (usually C:\). Click **Setup**. 
 +  - Once it's done, click **Return To The Setup Menu**. 
 +  - Check "Delete setup files" if desired, and then **Close The Setup Program**. 
 +  - Grub2win will automatically scan for available operating systems. It will not find Batocera, unfortunately. Click **Manage Boot Menu** in the middle bottom of the window. 
 +  - Click **Add New Entry** near the top of the window. 
 +  - Under "Type", select **Custom code**. 
 +  - 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 editor. Paste in the following and save the file, for Batocera **v39** and higher: <code
 + set efibootmgr=/EFI/batocera/bootx64.efi 
 +     getpartition  file  $efibootmgr  root 
 +     if [ ! -z $reviewpause ] ; then 
 + echo GNU Grub will load the Batocera EFI Boot Manager at disk address $root 
 +         g2wsleep   
 +     fi 
 +     echo GNU Grub is now loading the Batocera EFI Boot Manager 
 +     chainloader $efibootmgr 
 +     savelast 1 'Batocera' 
 +</code>For Batocera **v38** and lower<code> 
 + set efibootmgr=/EFI/BOOT/bootx64.efi 
 +     getpartition  file  $efibootmgr  root 
 +     if [ ! -z $reviewpause ] ; then 
 + echo GNU Grub will load the Batocera EFI Boot Manager at disk address $root 
 +         g2wsleep   
 +     fi 
 +     echo GNU Grub is now loading the Batocera EFI Boot Manager 
 +     chainloader $efibootmgr 
 +     savelast 1 'Batocera' 
 +</code> <WRAP center round tip> 
 +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. 
 +  - Grub2win will then scan the code for mistakes. If all goes well, click **OK**, followed by **OK**. 
 +  - Check that the Batocera listing is correct and in the menu slot desired. Then click **Apply**. 
 +  - Set any further cosmetic settings desired. Lower the "Grub timeout" from **30** down to **10** and change the background by clicking on the preview. When done, click **OK**. 
 +  - Grub2win will then install the desired boot menu onto the drive. Green means it's good. Click **Close**. 
 +  - Reboot and pray to whatever entity that you want that it worked. 
 + 
 +===== Dual boot Batocera and MacOS or other UEFI-based x86_64 systems using rEFInd ===== 
 + 
 +<WRAP center round important> 
 +Although Windows can be hostile towards other operating systems (erasing their bootloaders on an update, clearing the master boot record without warning, etc.), Macs can be even more hostile. Keep this in mind and definitely have a secure method of restoring a backup when playing with the Mac's bootloader. 
 + 
 +For "Hackintosh" builds, this is usually safer. 
 +</WRAP> 
 + 
 +<WRAP center round important> 
 +Before installing rEFInd, be sure to read and understand the entire contents of its documentation first. Being negligent in this regard can result in an unbootable system if no flashing method is prepared earlier. To quote the author of rEFInd: "Note: I consider rEFInd to be beta-quality software! That said, rEFInd is a usable program in its current form on many systems." 
 +</WRAP> 
 + 
 +Install [[https://www.rodsbooks.com/refind/|rEFInd Boot Manager]] and check that the system is still booting. Batocera might be automatically detected (but with a generic name); if so lucky you! Otherwise, Batocera can be added manually by adding the following to the ''refind.conf'' file. 
 + 
 +<code> 
 +menuentry "Batocera"
 +    icon EFI/boot/icons/os_linux.png 
 +    loader /boot/linux 
 +    initrd /boot/initrd.gz 
 +    options "label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0" 
 +
 +</code> 
 + 
 +===== Dual boot Batocera and other Linux distributions ===== 
 + 
 +Here are some examples on how to dual boot Batocera with popular Linux distributions like Ubuntu or Linux Mint. 
 + 
 +==== Ubuntu Linux ==== 
 + 
 +=== Install Ubuntu === 
 + 
 +Follow your favorite method for the initial Ubuntu install, leaving extra unpartitioned space for Batocera and its userdata. 
 + 
 +=== Batocera partitions === 
 + 
 +After the Ubuntu partition, create two consecutive partitions: 
 +  * Partition 1: Type = ''fat32'', name = ''BATOCERA'' 
 +  * Partition 2: Type = ''ext4'', no special labels or flags required, 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. 
 + 
 +=== Configure the Ubuntu GRUB === 
 + 
 +  - While booted into Ubuntu, create ''/etc/grub.d/50_batocera'' with the following content: <file - 50_batocera>#!/bin/bash 
 + 
 +cat << EOF 
 +menuentry "batocera.linux"
 +      search --set=root --label BATOCERA 
 +      linux /boot/linux label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 
 +      initrd /boot/initrd.gz 
 +
 +EOF 
 +</file> 
 +  - Make it executable by running ''sudo chmod +x /etc/grub.d/50_batocera'' 
 +  - Run ''sudo update-grub'' 
 +  - Reboot 
 + 
 +You will now be presented with the GRUB menu upon booting, allowing you to select either Batocera or Ubuntu to boot into. 
 + 
 +<WRAP center round info> 
 +Older versions of Ubuntu may need ''grub-customizer'' to do the above. More info on [[:dual_boot_ubuntu_batocera.linux?rev=1617117239#configure_the_ubuntu_grub|this earlier version of the page]]. 
 + 
 +Alternatively, try the [[#linux_mint|Linux Mint section below]]. 
 +</WRAP> 
 + 
 +==== Linux Mint/MX Linux ==== 
 + 
 +For other distributions like Linux Mint 19.03, you can use the following method. It also works for MX Linux, all mentions of Linux Mint also refer to MX Linux in this section. 
 + 
 +=== Install Linux Mint === 
 + 
 +Follow your favorite method for the initial Mint install, leaving extra unpartitioned space for Batocera and its userdata. 
 + 
 +=== Batocera partitions === 
 + 
 +Create 2 consecutive partitions on your hard drive: 
 +  * Partition 1: type = fat32, name = ''BATOCERA'' 
 +  * Partition 2: type = ext4. It must be created and placed right after 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> 
 +Since it's been set up manually, you can remove the ''autoresize'' flag from ''batocera-boot.conf''. It may interfere with booting if it's still on and there's no more space to expand to. 
 +</WRAP> 
 + 
 +=== Configure the GRUB boot loader === 
 + 
 +  - Download the following file and save it to ''/etc/grub.d/15_batocera'': <file - 15_batocera> 
 +#! /bin/sh 
 + 
 +BATOCERA_UUID=$(lsblk --fs --noheadings --pairs -o TYPE,LABEL,UUID | 
 +        grep -E '^TYPE="part" LABEL="BATOCERA" UUID="[^"]*"$'
 +        sed -e s+'^TYPE="part" LABEL="BATOCERA" UUID="\([^"]*\)"$'+'\1'+ | head -1) 
 + 
 +if test -n "${BATOCERA_UUID}" 
 +then 
 +    echo "Image batocera found on ${BATOCERA_UUID}" >&
 + 
 +    cat <<EOF 
 +menuentry "batocera.linux"
 + insmod fat 
 +        search --no-floppy --fs-uuid --set=root ${BATOCERA_UUID} 
 + linux /boot/linux label=BATOCERA console=tty3 quiet loglevel=0 vt.global_cursor_default=0 
 + initrd /boot/initrd.gz 
 +
 +EOF 
 +fi 
 +</file> 
 +    * The file can also be automatically downloaded with the following command: <code> 
 +sudo wget 'https://wiki.batocera.org/_export/code/dual_boot_ubuntu_batocera.linux?codeblock=4' -O /etc/grub.d/15_batocera 
 +</code> 
 +  - Then run the following commands: <code> 
 +sudo chmod a+x /etc/grub.d/15_batocera 
 +sudo update-grub 
 +</code> Eventually, it will output the following: <code> 
 +  [...]  
 +​Image batocera found on 3377-44C4 
 +  [...] 
 +</code> 
 +  - Reboot 
 + 
 +You will now be presented with the GRUB menu upon booting, allowing you to select either Batocera or Linux Mint to boot into. 
 + 
 +===== Ventoy ===== 
 + 
 +https://www.ventoy.net/en/index.html 
 + 
 +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): 
 + 
 +<code> 
 +qemu-img resize batocera.img +#G 
 +sudo losetup --find --show batocera.img 
 +</code> 
 + 
 +and expanding the userdata partition with Gparted or something similar. 
 + 
 +{{:ventoy_mount.png|}} 
 + 
 +If you want to keep using [[https://gparted.org/display-doc.php?name=help-manual#gparted-run-from-cmd-line|the command line for Gparted]]: 
 + 
 +<code> 
 +gparted /dev/loop * 
 +</code>
  
-Save and reboot. 
  • dual_boot_ubuntu_batocera.linux.1590360162.txt.gz
  • Last modified: 4 years ago
  • by lbrpdx