Hi all, my first post here :)
I currently have a workaround for my needs, but I guess these might be common enough to request as feature. I have a RPi4 with a 1TB disk attached and a Retropie-based setup, which I’m using as NAS for Batocera Linux x64 in an old laptop. I don’t have enough storage on the 1TB RPi4 NAS for heavier games that run only on the laptop, e.g. Wii / Gamecube, so I’ve done an overlay setup to use both.
The method below is safe: keeps changes written by Batocera in the laptop and won’t write them to the Rpi4 storage, avoiding potential screw-ups.
I would rather like to see an official way to support multiple storage types at the same type, also the change in /etc/inittab below is currently necessary to keep reboot/shutdown functionality.
1) Create a null_share folder both on /userdata/ and somewhere within your RPi4 shares ( e.g. mkdir -p /home/pi/addonusb/roms/null_share shows up within “roms_USB” share)
2) Create a folder for your roms on the laptop (NOT on /userdata/roms!) and a “work” folder that will combine both the RPi4 share and the internal storage. This will be mounted then as /userdata/roms
Examples:
mkdir -p /userdata/roms_ssd (for ROMS stored locally in the SSD)
mkdir -p /media/NO_LABEL/roms_hdd (for ROMS stored locally in the HDD)
mkdir -p /userdata/overlay_netroms (mountpoint for RPi network share, mounted read-only)
mkdir -p /userdata/overlay_localroms (extra layer for writes (upperdir), to ensure even /roms_hdd and /roms_ssd are treated as lowerdirs, i.e. read-only)
mkdir -p /userdata/overlay_work (temporary folder used by overlayFS for filesystem merges, needs to be in the same storage unit as upperdir.
3) Copy your BIOS to /userdata/bios. I’ve also copied the music to /userdata/music and the screensaver images to /userdata/screenshots :)
4) Make the following changes on the laptop
NOTE: you’ll need to run “mount /dev/sdb1 -o remount,rw” before changes on /boot folder.
NOTE2: My Pi is mapped to IP 192.168.1.151, replace with your own (reserve it on your router).
/boot/batocera-boot.conf (dummy command, allows triggering the custom.sh script)
sharedevice=NETWORK
sharenetwork_cmd1=/sbin/mount.cifs -o ro,guest //192.168.1.151/roms_USB/null_share /userdata/null_share
/userdata/system/custom.sh
NOTE: /media/NO_LABEL on the example below is my 512GB HDD laptop internal storage, replace it with your own.
NOTE 2: the “work” folder needs to be in the same storage unit as upperdir.
NOTE 3: multiple lowerdir (read-only from overlayfs perspective), we can only have one upperdir (read/write). This allows me to merge (i.e. present as a single folder) the contents of my SSD, my HDD and my network share running from the Pi.
#!/bin/sh
while ! ping -c 1 -W 1 192.168.1.151; do
echo “Waiting for RPi”
sleep 1
done
/sbin/mount.cifs -o ro,guest //192.168.1.151/roms_combo_scraper_only /userdata/overlay_netroms
mount -t overlay overlay -o lowerdir=/userdata/overlay_netroms:/userdata/roms_ssd:/media/NO_LABEL/roms_hdd,upperdir=/userdata/overlay_localroms,workdir=/userdata/overlay_work /userdata/roms
/userdata/system/.xinitrc
Forcing HDMI resolution, disable laptop display.
xrandr –output “eDP-1-1” –off
xrandr –output “HDMI-1-1” –mode 1366×768 -r 60
/etc/inittab
Edit and insert the first line as the extra overlay breaks the shutdown/reboot sequence. Change shd* numbers accordingly to keep the sequence.
Stuff to do before rebooting
shd0:06:wait:/bin/umount -l -a -t overlay
shd1:06:wait:/etc/init.d/rcK
shd2:06:wait:/sbin/swapoff -a
shd3:06:wait:/bin/umount -a -r -f
after saving all files run batocera-save-overlay to make changes permanent and reboot.