[How To] Recalbox Network (Samba) Roms Folder

Here is my technique for having the Recalbox roms folder mounted on the network.
This allows for all yours roms to be on the network and every Recalbox can access them.

 There were a few obstacles

1) Emulation station is booted before the network is up to reduce boot times
2) If we change any of the existing init.d files - our changes will be overwritten on updates
3) fstab won't work either

Our solution is to create a custom.sh script that Emulationstation will run on boot.

Please note: This method requires at least Recalbox 4.0.0-beta4

Let's get started.

First boot the Raspberry Pi into Recalbox.

Now we need to SSH into Recalbox.
We do this using a program called Putty on a Windows computer that is on the same network as the Pi.

Download putty.exe from here

Save it somewhere you can easily find it.
It's portable - which means it doesn't need to be installed.
Open the downloaded putty.exe to start Putty.

Enter the Pi's IP address in the host name field and make sure the port is 22.
(Often you can find the IP by looking at the DHCP client list in your router settings page.)
Then click Open.


You should see "login as:" appear.
Type root and hit enter. Now type in the password recalboxroot and hit enter.

You should now be logged into the Pi remotely.
Now, you can copy the below commands into the terminal window.

First, we need to change the filesystem from RO (read only) to RW (read / write).
mount -o remount,rw /
Now we need to mount our network folder and copy over all the files.
mkdir /tmp/share
mount -t cifs -o user={USER},password={PASS},rw //{IP}/{SHARE} /tmp/share
If your share is public and doesn't require username / password, then use the below
mount -t cifs -o user=guest,rw //{IP}/{SHARE} /tmp/share
Replace {IP} with the IP address of your share & replace {SHARE} with the name of the share.
If required, replace {USER} and {PASS} to what is required for your share.
Note: It appears Recalbox requires write (rw) permission to the network share.

We now need to copy over all the files from the existing roms folder to our new roms folder
cp -r /recalbox/share/roms/. /tmp/share/
Now unmount this share
umount -l /tmp/share
Now let's create our custom.sh script
nano /recalbox/share/system/custom.sh
Copy the below text into the editor
#!/bin/sh

case "$1" in
start)
  while ! ping -c 1 -W 1 {IP}; do
     sleep 1
  done

  mount -t cifs -o user={USER},password={PASS},rw \
         //{IP}/{SHARE} /recalbox/share/roms

  /etc/init.d/S*emulationstation restart
  ;;
stop)
  umount -l /recalbox/share/roms
  ;;
esac

exit $?
Remember to change {IP}, {SHARE}, {USER} and {PASS} to match your setup  :)

Save the file (CTRL-X, Y, ENTER)

Now make sure the script is executable
chmod +x /recalbox/share/system/custom.sh
Now reboot.
reboot
Recalbox will boot and initially show the 'internal' roms.
This is because Emulation Station starts before the network and our script :(

Once the network is started our script will then run, mount the network roms folder and restart Emulation Station to display the network roms.

I also advise making a backup of your working custom.sh file.
Just in case the file is deleted during updates (shouldn't happen though).

Comments

  1. is user=username really username or must be replaced?

    ReplyDelete
    Replies
    1. Yes. You need to put in your SAMBA share username and password so the Pi can have write access.

      Delete
  2. hi,
    how can I do this in version 4.0.0. But if I do everything as in the description Recalbox is not loaded.
    Please help
    Thank you

    ReplyDelete
    Replies
    1. This post is for the older version of Recalbox. I will update it when I can. Thanks.

      Delete
    2. Updated now and tested working.
      It only mounts the roms directory now.

      Delete
  3. Hello,
    I got your newest dual-boot setup for OpenELEC and Recalbox which worked fine before I made any changes. Since I set my Recalbox to mount the Roms via NFS I am experiencing serious issues. The commands via SSH worked all fine. Folder and files were created/moved correctly to the NFS. But when I try to boot Recalbox via OpenELEC now (I have set OpenELEC to auto boot and use your Addon shortcut) all I get is the boot / splash screen with the Recalbox Release info and so on. The PI then seems to freeze and turns into a black screen after approx. 10 minutes. Have you heard of similar problems before or do you maybe even have a solution for this problem?
    Best Regards

    ReplyDelete
    Replies
    1. This post is for the older version of Recalbox. I will update it when I can. Thanks.

      Delete
    2. Updated now and tested working.
      It only mounts the roms directory now.

      Delete
    3. Hello,

      Thank you for the reply!
      I reran the setup with your new tutorial and now recalbox boots again.
      The problem is that the ROMs do not seem to be loaded.
      If I execute all your commands until:

      "cp -r /recalbox/share/roms/. /mnt/share/"

      Then I can ls -l /mnt/share and see that all ROMs are being loaded from my NFS.
      Strangely, after I unmount the share, remove the directory, create the scripts and reboot recalbox no ROMs are being loaded.
      If I ls -l /mnt/share after the reboot the folder is empty. In Recalbox there is only the one standard preinstalled ROM (Donkey Kong Classic) being displayed.
      There must be something I did wrong, but since I am very inexperienced with linux/unix terminal commands I am not quite sure where I made the mistake.
      Could you maybe give me a tip?
      Best Regards,
      Johannes

      Delete
    4. You shouldn't have a /mnt/share directory if you followed my steps.

      You only have it temporally to copy the initial roms directory from Recalbox to your network share. It is then removed.

      Can you post the mount command you are using to mount the NFS share? Obviously XXX out your password :)

      Delete
    5. Of course, I can! :-)

      mount -t cifs //192.168.1.4/ROMs -o user=admin,password=XXX /mnt/share

      This is the command I initially use to mount my NFS-Rom-Folder. After this command i can execute ls -l for the /mnt/share folder and can see the exact same folder structure as on my NFS share.

      I also transferred the above login information (NFS IP + username/password) to the init scripts.

      I even tried to get rid of the folder substructure (seperate folders for SNES, SEGA, GBC, N64 Roms etc.) and copy all ROMs into the same folder but that did not bring any effect either. Only the default ROMs were loaded.

      Delete
    6. Maybe another error source:
      Could it be a problem that Recalbox gets its IP dynamically via DHCP? The NFS is connected to the router via cable and has a static IP (192.168.1.4) consequently whereas recalbox gets assigned a different IP after each restart. I already tried to change this via /etc/network/interfaces but recalbox does not really seem to care about that.

      Delete
    7. Ok, my post might be a bit confusing.
      Get rid of the /mnt/share folder. You don't need to use this if your roms are already on your network.

      In this folder: //192.168.1.4/ROMs you should have all the folders for each system eg. //192.168.1.4/ROMs/SNES etc. That is correct.

      Your init lines should look like:
      http://pastebin.com/tfBi2tns

      You probably also don't need the -t cifs (thats for samba)
      Try just having:

      mount //192.168.1.4/ROMs -o user=admin,password=XXX /recalbox/share/roms


      Recalbox doesn't need a static IP unless your NFS is setup to only allow access to certain IP's (unlikely)

      Delete
    8. umount /mnt/share

      before deleting it or you might delete the network folder as well. Or just leave it alone. But we don't use it :)

      Delete
    9. Recalbox looks in the /recalbox/share/roms for it's roms.
      So, we are mounting the network folder over this folder so it finds our network roms instead.

      Delete
    10. Wow, Thanks a lot for all the info!
      I am currently not at home but will try this as soon as I get home. I think I have always checked the /mnt/share folder for the ROMs but after your explanation it makes sense to me why I don't even need this folder and it is therefore deleted after the copy process. Will definitely have to check if the ROMs are being copied to the /recalbox/share/roms folder corretly. Also I will try to get rid of the -t cifs (although this might not be the problem since I was able to load the ROMs to /mnt/share with the same command in the past). Static IP shouldn't be the problem either since I have not setup any IP or MAC filters for my NAS. By all means I will need to try this as soon as I am home again and stop speculating.
      Thank you so much for your input so far. Now I am pretty optimistic that I will get this thing running today!
      Best Regards,
      Johannes

      Delete
    11. OK, I finally had the chance to test your adjustments. It's still not working. I double checked all file paths, case sensitivity and command options and now I am sure that it has something to do with the init scripts. When i manually mount the NFS share into /recalbox/share/roms and then update the game list in recalbox all games appear. But when I restart recalbox all ROMs are gone again. Maybe the scripts are not being executed properly?
      Mods for both files read: -rwx------ is this correct?
      Thanks for all the effort you have put in helping me so far!
      Best Regards,
      Johannes

      Delete
    12. Hmm, possibly try adding a delay after the network start line.

      Like this:
      http://pastebin.com/1zk5Wh8r

      Those permissions look OK

      Ps: How did you make Recalbox update the game list??

      Delete
    13. Sounds good, will give it a go tomorrow. You can manually refresh the Game List via "Game Settings" in the Main Context Menu. Glad I can help you for ohe time ;-)

      Edit: OK, so I had the chance to test the script with the timer. Still not working. I now tried to manually run the script via terminal with

      /etc/init.d/S20mountcifs start

      That's what the terminal tells me:

      # /etc/init.d/S20mountcifs start
      ifup: interface lo already configured
      [ 633.06] : eth0 will be used as wired interface
      ifdown: interface eth0 not configured

      Then nothing happens for at least 5 minutes.
      When I then try to do something else via terminal it tells me either:

      Write failed: Host is down

      or

      Write failed: Broken pipe

      Things are getting pretty strange here...

      Delete
    14. Hmm. I'm really not sure...
      I'll have another play around when I get time and see if I can fix

      Delete
  4. Hi Matt I am a complete beginner to rasp pi. After reading your article on the dual boot of recalbox and open elec I decided to give it a try. I have had success getting the files onto my mirco SD card and booting it from the rasp pi. I am having trouble loading my roms onto the system. I am following this tutorial, but am having an issue. When using putty I am able to put my login as root but when I go to type in the password it doesnt not give me the option. I type but nothing is displayed just the green cursor. Any help would be greatly appreciated.

    ReplyDelete
    Replies
    1. This post is for having your roms on the Network. If you just want them on the SD card, then either transfer them over using SAMBA or enter the IP address of the Pi in your browser, and you can use the Recalbox web interface to upload roms.

      Delete
  5. Hello, I tried this yesterday on my rpi3 and it works great as long as I am on wired ethernet. When I try it on wifi the cifs mount is never there after boot. Initially I suspected I needed to add a few seconds of sleep to allow for wireless to come up. After adding 20 seconds to the cifs startup script I ruled that out and I now suspect that it's due to the wireless being "torn down" and re-established during the normal network startup. Any recommendations?

    ReplyDelete
    Replies
    1. Hmm. I haven't tested using Wifi. Will try and report back.
      I think / hope the eventual plan is that Recalbox will add support for networked Roms..

      Delete
    2. Damn it! I have the exact same problem as you. Luckily I read the comments, I thought the whole time I did something wrong.

      Delete
  6. so i strugeled a bit to get this working over wlan.
    To get it working i make the following changes.

    In /etc/init.d/S40network i used the mount command so it looks like this:

    case "$1" in
    start)
    sleep 2
    /sbin/ifup lo
    /recalbox/scripts/recalbox-config.sh ethernet start
    /recalbox/scripts/recalbox-config.sh wifi start
    sleep 10
    mount -t cifs //192.168.xxx.xxx/ROMs -o user=xxx,password=xxx /recalbox/share/roms
    /etc/init.d/S31emulationstation restart
    ;;

    greetz MauwiWauwi

    ReplyDelete
    Replies
    1. Thanks for your comment.
      You might want to consider putting it into a separate file so it's not over-written on next update.

      Delete
  7. It works perfectly ! Great post ! Thank you !!

    ReplyDelete
  8. Hi Matt, Great Work!

    But i have a problem with the script custom.sh

    i get a syntax error in the line 9. I think the problem are the ;;

    Any idea?

    ReplyDelete

Post a Comment