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 [2023/09/17 05:27] – [Linux Mint/MX Linux] Use HTTPS link maximumentropydual_boot_ubuntu_batocera.linux [2024/09/21 20:15] (current) – [Ventoy] maximumentropy
Line 49: Line 49:
   - Under "Type", select **Custom code**.   - Under "Type", select **Custom code**.
   - Name the "Title" as "Batocera", place it in whichever "Menu Slot" desired and reduce the "Pause Seconds" to **0**.   - 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: <code>+  - 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  set efibootmgr=/EFI/BOOT/bootx64.efi
      getpartition  file  $efibootmgr  root      getpartition  file  $efibootmgr  root
Line 60: Line 70:
      savelast 1 'Batocera'      savelast 1 'Batocera'
 </code> <WRAP center round tip> </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.+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> </WRAP>
   - Close the text editor.   - Close the text editor.
Line 122: 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 197: 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 213: 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.1694928448.txt.gz
  • Last modified: 3 years ago
  • by maximumentropy