Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| store_games_on_a_nas [2022/01/22 22:23] – grandmabetty | store_games_on_a_nas [2024/01/29 20:17] (current) – instructions for mounting network-based /userdata folders that are dependent on an established VPN or Tailscale connection cs | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Store games on a NAS ====== | ====== Store games on a NAS ====== | ||
| + | |||
| Instead of using the internal storage or an external USB key/hard drive to store your userdata (games, saves, configuration, | Instead of using the internal storage or an external USB key/hard drive to store your userdata (games, saves, configuration, | ||
| - | Of course you can also use your NAS as a backup target | + | |
| + | Recommended watching: [[https:// | ||
| + | |||
| + | <WRAP center round important> | ||
| + | Batocera repeatedly checks | ||
| + | |||
| + | In general, if using Batocera on a portable device | ||
| + | </ | ||
| ===== Syntax ===== | ===== Syntax ===== | ||
| + | |||
| You will need to replace the '' | You will need to replace the '' | ||
| - | <WRAP center round tip 60%> | + | <WRAP center round tip> |
| You can tell if you have successfully done this as the **Storage Device** in **Main Menu** > **System Settings** will be blank! But that could also mean you've entered an invalid entry to '' | You can tell if you have successfully done this as the **Storage Device** in **Main Menu** > **System Settings** will be blank! But that could also mean you've entered an invalid entry to '' | ||
| </ | </ | ||
| Line 13: | Line 22: | ||
| There are the pre-defined keywords you can use: | There are the pre-defined keywords you can use: | ||
| - | * For the whole user data directory, '' | + | |
| - | * For the roms directory, '' | + | ^ Keyword ^ Description ^ |
| - | * For the bios directory, '' | + | | '' |
| - | * For the saves directory, '' | + | | '' |
| - | * For custom menu background music, '' | + | | '' |
| - | * For custom bezels, '' | + | | '' |
| - | * For screenshots taken in game or with '' | + | | '' |
| - | * For themes, | + | | '' |
| - | * For cheats databases, | + | | '' |
| - | * For sounds, | + | | '' |
| - | | + | | '' |
| - | * For the boot splash, '' | + | | '' |
| + | | '' | ||
| + | | '' | ||
| You can add any combination of the above (except '' | You can add any combination of the above (except '' | ||
| - | <WRAP center round info 60%> | + | <WRAP center round info> |
| If you map only certain directories to your NAS, Batocera will search the internal storage for the remaining directories. | If you map only certain directories to your NAS, Batocera will search the internal storage for the remaining directories. | ||
| </ | </ | ||
| - | '' | + | ==== For Samba ==== |
| + | |||
| + | '' | ||
| Then add the @ symbol, the IP address/ | Then add the @ symbol, the IP address/ | ||
| - | '' | + | '' |
| - | Examples below. | + | ==== For NFS ==== |
| - | <WRAP center round important | + | '' |
| + | |||
| + | Examples are [[# | ||
| + | |||
| + | <WRAP center round important> | ||
| If Batocera fails to connect to the network at boot, it will wait approximately one minute retrying to connect before falling back to internal storage. | If Batocera fails to connect to the network at boot, it will wait approximately one minute retrying to connect before falling back to internal storage. | ||
| </ | </ | ||
| ===== Samba/ | ===== Samba/ | ||
| + | |||
| Windows shares can use identification or a guest account to connect. | Windows shares can use identification or a guest account to connect. | ||
| Line 50: | Line 68: | ||
| === The whole user data directory on the NAS === | === The whole user data directory on the NAS === | ||
| + | |||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_smb1=SHARE@192.168.0.1: | + | sharenetwork_smb1=SHARE@192.168.0.1: |
| </ | </ | ||
| - | === Only the roms directory on the NAS === | + | |
| + | === Only the ROMs directory on the NAS === | ||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_smb1=ROMS@192.168.0.1: | + | sharenetwork_smb1=ROMS@192.168.0.1: |
| </ | </ | ||
| - | === Only the roms directory on the NAS with CIFS authentication === | + | |
| + | === Only the ROMs directory on the NAS with CIFS authentication === | ||
| + | |||
| + | <WRAP center round important> | ||
| + | Unless you really know what you're doing, it is ill-advised to set up the NAS with a username and password for your ROMs, saves and system folders. This can interfere with Batocera' | ||
| + | |||
| + | It is recommended however to use authentication for your NAS in general, it's possible to create an additional share that only shares the ROMs folder with guest access for example. | ||
| + | |||
| + | If your NAS was already using NTFS then this limitation is already in affect, thus it would be no different to using authentication anyway. | ||
| + | </ | ||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_smb1=ROMS@192.168.0.1: | + | sharenetwork_smb1=ROMS@192.168.0.1: |
| </ | </ | ||
| - | === The roms, saves and bios directories on the NAS === | + | |
| + | === The ROMs, saves and BIOS directories on the NAS === | ||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_smb1=ROMS@192.168.0.1: | + | sharenetwork_smb1=ROMS@192.168.0.1: |
| - | sharenetwork_smb2=SAVES@192.168.0.1: | + | sharenetwork_smb2=SAVES@192.168.0.1: |
| - | sharenetwork_smb3=BIOS@192.168.0.1: | + | sharenetwork_smb3=BIOS@192.168.0.1: |
| </ | </ | ||
| === Specific SMB version options === | === Specific SMB version options === | ||
| + | |||
| In several cases, **you need to add SMB options**, for instance if you NAS requires a specific CIFS version: | In several cases, **you need to add SMB options**, for instance if you NAS requires a specific CIFS version: | ||
| Line 90: | Line 124: | ||
| === The whole user data directory on the NAS === | === The whole user data directory on the NAS === | ||
| + | |||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_nfs1=SHARE@192.168.0.1:/ | + | sharenetwork_nfs1=SHARE@192.168.0.1:/ |
| </ | </ | ||
| - | === Only the roms directory on the NAS, with a specific NFS version === | + | |
| + | === Only the ROMs directory on the NAS, with a specific NFS version === | ||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_nfs1=ROMS@192.168.0.1:/ | + | sharenetwork_nfs1=ROMS@192.168.0.1:/ |
| </ | </ | ||
| - | === The roms, saves and bios directories on the NAS === | + | |
| + | === The ROMs, saves and BIOS directories on the NAS === | ||
| < | < | ||
| - | | + | sharedevice=NETWORK |
| - | sharenetwork_nfs1=ROMS@192.168.0.1:/ | + | sharenetwork_nfs1=ROMS@192.168.0.1:/ |
| - | sharenetwork_nfs2=SAVES@192.168.0.1:/ | + | sharenetwork_nfs2=SAVES@192.168.0.1:/ |
| - | sharenetwork_nfs3=BIOS@192.168.0.1:/ | + | sharenetwork_nfs3=BIOS@192.168.0.1:/ |
| </ | </ | ||
| - | ===== Advanced | + | ===== Mounting network shares behind a VPN or Tailscale network |
| + | === Background === | ||
| + | Mounting a shared folder on a server that requires a VPN or Tailscale connection to be established first is troublesome due to the Batocera boot initialization process. While Batocera does provide [[: | ||
| - | === Troubleshooting === | + | __Basic boot process flow:__\\ |
| + | 1. / | ||
| + | 2. / | ||
| + | 3. / | ||
| + | 4. / | ||
| + | 5. / | ||
| - | Make sure you escape special characters in your CIFS passwords if you have some. To escape a character, put a \ in front of it. To escape a \ itself, use %%\\%%. | + | From the above, we can see that the VPN/ |
| - | For troubleshooting purposes, you have '' | + | === Workaround === |
| + | There is a [[: | ||
| - | === Samba/Windows manually mounted shares === | + | First, setup and test the VPN/Tailscale client according |
| - | It is possible | + | |
| + | The final result of my configuration looks something like the below. Note that in my example, I am using Tailscale and mounting NFS folders, although this should be adaptable for any combination of VPN/ | ||
| < | < | ||
| - | sharenetwork_cmd1=mount.cifs | + | sharedevice=NETWORK |
| - | sharenetwork_cmd2=mount.cifs | + | sharenetwork_cmd1=eval if [ ! -d /dev/net ]; then mkdir -p /dev/net; mknod / |
| - | sharenetwork_cmd3=mount.cifs -o guest //192.168.0.1/ | + | sharenetwork_nfs1=ROMS@100.0.0.1:/mnt/ |
| - | sharenetwork_cmd4=mount.cifs -o guest //192.168.0.1/ | + | sharenetwork_nfs2=SAVES@100.0.0.1:/mnt/ |
| + | sharenetwork_nfs3=BIOS@100.0.0.1:/mnt/ | ||
| </ | </ | ||
| - | This will only work if '' | + | ===== Advanced ===== |
| - | <WRAP center round tip 60%> | + | === Troubleshooting === |
| - | These will appear as if though they are local to the drive, so keep that in mind when troubleshooting in the future! | + | |
| - | </ | + | |
| - | === NFS and root permissions === | + | Make sure you escape special characters in your CIFS passwords if you have some. To escape a character, put a \ in front of it. To escape |
| - | Batocera has a unique '' | + | |
| - | You should check how the file permissions are declared on your NFS server, but a common way to make sure your file permissions are managed correctly is to map the file rights to the UID of the user that will access these files locally. Typically, if your NFS shares are defined in ''/ | + | |
| - | < | + | |
| - | / | + | |
| - | </ | + | |
| - | ==== Backup your data to a NAS ==== | + | For troubleshooting purposes, you have ''/ |
| - | In this example we will cover how to **automatically** backup the most important two data folders ''/ | + | === Discover network share names === |
| - | === Synology NAS example === | + | If you haven' |
| - | <WRAP center round tip 60%> | + | {{: |
| - | This tutorial assumes you have already set a static IP address for your Synology NAS on the according LAN interface and a static IP address for your Batocera system. To set a static IP address for your Batocera system it is best to configure it based on your Batocera system' | + | |
| - | Also, for automation purposes, you will need to have at least one (if you have multiple) of your Synology' | + | |
| - | </ | + | |
| - | For this tutorial you will need to enable | + | This can be used to confirm that your Batocera machine can at least see the NAS. You may want to note down these names. You will not be able to access any shares from this menu, however. |
| - | * **SMB** → Navigate to '' | + | |
| - | * **rsync** → Navigate | + | |
| - | * **SSH** → Navigate | + | |
| - | <WRAP center round tip 60%> | + | === Discover network share paths === |
| - | You don't have to worry if you are already using port 22 for default SSH encrypted connections, | + | |
| - | </ | + | |
| - | Next, you will need to [[https://kb.synology.com/en-us/DSM/ | + | Kodi can be used to see //and// access network shares. You may need [[# |
| - | Next, you will need to [[https://kb.synology.com/en-us/ | + | {{:screenshot-2022.01.28-15h16.44.png?720|}} {{: |
| - | {{:useanasbackup03.png? | + | From here, enter the network share name (and your username and password if you don't have guest/ |
| - | Next, you will need to [[https://kb.synology.com/en-us/ | + | {{:screenshot-2022.01.28-15h17.57.png?720|}} |
| - | * '' | + | |
| - | * '' | + | |
| - | In addition it is also strongly(!) recommended to limit the firewall rule to allow only the static IP address of your Batocera system: | + | |
| - | {{: | + | <WRAP center round tip> |
| + | In the case that you don't know the name of the networked device | ||
| - | Now [[https:// | + | Instead of going to **Add network location...**, instead go to **Zeroconf browser**. You will be shown a list of all devices. Select |
| - | < | + | |
| - | + | ||
| - | <WRAP center round tip 60%> | + | |
| - | On the following steps we will cover on how to create three scripts here: | + | |
| - | | + | |
| - | * '' | + | |
| - | | + | |
| - | We are separating | + | |
| </ | </ | ||
| - | <WRAP center round important 60%> | + | Your share will be added to the list of browseable devices, navigate to it (in this example, |
| - | **Beware:** The '' | + | |
| - | </ | + | |
| - | Now create the following script file: | + | {{:screenshot-2022.01.28-15h18.17.png?720|}} {{:screenshot-2022.01.28-15h18.23.png? |
| - | < | + | |
| - | And paste the following content (replace ''< | + | |
| - | < | + | |
| - | #!/bin/sh | + | |
| - | USER=backup | + | |
| - | PASS=< | + | |
| - | SHARE=//< | + | |
| - | MOUNT_POINT=/ | + | |
| - | mkdir -p " | + | |
| - | mount -t cifs -o username=" | + | |
| - | rsync -Pav --delete -e ssh / | + | |
| - | cd /tmp | + | |
| - | umount -f " | + | |
| - | exit 0 | + | |
| - | </ | + | |
| - | Save the file and quit the editor. | + | |
| - | Now create | + | Note down the file path stated at the bottom of the window, this is the path that should be used when configuring your NAS. eg. Kodi's path '' |
| - | < | + | |
| - | And paste the following content | + | |
| - | < | + | |
| - | #!/bin/sh | + | |
| - | USER=backup | + | |
| - | PASS=< | + | |
| - | SHARE=//< | + | |
| - | MOUNT_POINT=/ | + | |
| - | mkdir -p " | + | |
| - | mount -t cifs -o username=" | + | |
| - | cd " | + | |
| - | tar cfv " | + | |
| - | rm -rf ./ | + | |
| - | cd /tmp | + | |
| - | umount | + | |
| - | exit 0 | + | |
| - | </ | + | |
| - | Save the file and quit the editor. | + | |
| - | Now create the following script file: | ||
| - | < | ||
| - | And paste the following content: | ||
| < | < | ||
| - | #!/bin/sh | + | sharedevice=NETWORK |
| - | /userdata/scripts/ | + | sharenetwork_smb1=ROMS@RASPBERRYPI: |
| - | / | + | |
| - | shutdown -h now | + | |
| </ | </ | ||
| - | Save the file and quit the editor. | ||
| - | Now make all three scripts executable by executing: | + | === Samba/Windows manually mounted shares === |
| - | < | + | |
| - | Now let's do the automation part: | + | It is possible to map individual folders with '' |
| - | [[https://kb.synology.com/en-global/DSM/tutorial/How_to_login_to_DSM_with_root_permission_via_SSH_Telnet|SSH]] with user '' | + | < |
| - | < | + | sharenetwork_cmd1=mount.cifs -o guest //192.168.0.1/Documents/batocera/music /userdata/ |
| - | < | + | sharenetwork_cmd2=mount.cifs -o guest //192.168.0.1/ |
| - | Insert the Batocera '' | + | sharenetwork_cmd3=mount.cifs |
| + | sharenetwork_cmd4=mount.cifs -o guest //192.168.0.1/ | ||
| + | </ | ||
| - | Now go back to the Synology DSM web GUI and create the according automation task: | + | This will only work if '' |
| - | Navigate to '' | + | |
| - | <WRAP center round tip 60%> | + | <WRAP center round tip> |
| - | If your Synology NAS does have multiple network interfaces, | + | These will appear as if though they are local to the drive, so keep that in mind when troubleshooting in the future! |
| </ | </ | ||
| - | <WRAP center round tip 60%> | + | === NFS and root permissions === |
| - | If your Batocera | + | |
| - | </WRAP> | + | Batocera |
| < | < | ||
| - | #!/bin/sh | + | /media/games/ |
| - | sudo synonet --wake < | + | |
| - | sleep 30 | + | |
| - | ssh root@< | + | |
| </ | </ | ||
| - | Confirm by clicking on '' | ||
| - | That's it! Your scheduled backup automation should work now. | + | ===== Troubleshooting ===== |
| + | |||
| + | Logs for share mounting specifically can be found at ''/ | ||
store_games_on_a_nas.1642890212.txt.gz · Last modified: by grandmabetty