[Custom Script] Making EmuELEC read rom folders from external and internal storage

A while ago I made a script with a friend so we could have our EmuELEC to read roms from an external drive, the script consisted of making a symlink for every external game rom, which took a while to run.

This version, however, creates a symlink for every console folder found on the external drive.

You can check it out at GitHub - GuiCoppini/emuelec-scripts: Repository containing some custom EmuELEC scripts
Also, feel free to contribute as you wish!

Please note that this was not mass-tested and was only tested on EmuELECs installed in internal memory (not tested on EmuELECs booted by SDCard).

It is also unknown what could happen if you have the same console folderon many external drives.

To run the scripts, save them as .sh files (example: folder_links.sh and clear_folder_links.sh) and leave them in “/emuelec/scripts”. Open the user-scripts on your EmuELEC, run them and reboot the console.

2 Likes

Did a quick check and find a problem: If a same system exists on multiple external drives, then only the last one in alphabetical order will be used

You could call the clear script first in create script, and skip the folders where target link already exists, or maybe this can be solved in a per-system external option or per-rom link (would be slow, though)

1 Like

Hmm good one, I knew that something weird would happen if the console existed on many drives, I just had no idea of what I should do… I might change it to make as you suggested of just considering the first system found, what do you think?

My dream is to give a little prompt like “N64 was found on X and Y drives, which one do you want to use?”, but I think it goes further than just bash scripts.

The old script I had was a per-rom link, it was waaaaay slower to run and I like the per-console style because not only it is faster, but it also takes the “images” folder together, so I can scrape roms via EmuELEC and have the images being downloaded into the external drive.

I prefer EmuELEC reading roms from a NAS, and it’s not difficult to implement

Sorry I might be missing the point, but I do not understand why this script is needed. EmuELEC already mounts external drives ROMS on external USB media ¡ EmuELEC/EmuELEC Wiki (github.com) automatically or via the EmuELEC settings menu in Emulationstation. Unless this is meant to have both internal and external at the same time?

The script is not needed at all, it’s a custom thing as an extra. It was mainly made so that I could use my 1TB external HD as a place to add roms that I would not want occupying the internal storage, for example PSP and PS1 games. The ideia is purely when someone wants to have some consoles on one storage and other consoles on other storage; good SD Cards with a high capacity are sometimes expensive and I had an old HDD that I could use to carry some extra games.

I keep the “main” games on the internal drive, such as megadrive, snes, nes etc, and the occasional ones on the external drive, such as PSP, PS1, NDS etc.

Ah there it is, yeah after looking at the script I understand what you are doing, this allows both internal and external to have roms. Thanks

P.S. I have edited the title to reflect this.

In fact, to achieve this, I think it is completely possible to add the roms path selection function in the emuelec menu, so that as long as the external or internal roms specify the path, the system can easily access the game roms with the new path after restarting.

FYI, I re-implemented the whole mounting logic in C using native C calls and now EE can mount ROMs across multiple different mount sources, if you want to try this now, you can build it from the PR branch:
eemount: introduce package & change mount logic by 7Ji ¡ Pull Request #980 ¡ EmuELEC/EmuELEC (github.com)

The mounting utility itself is open source and licensed under GPL3. You can tailor it further depending on your personal need.
7Ji/eemount: Multi-source ROMs mounting utility for EmuELEC (github.com)

This bad boy can easily handle tens of different mount sources and almost 100 systems (which is a stupid number and already exceeds the number of systems EE can emulate) in under 3 seconds, and can push that further to under 1 second (avg 0.7 s) if you don’t have systemd mounts involved, and then further to under 0.1 second if you just have a couple of external systems

3 Likes

That’s amazing, just read the PR description and I loved it. This is a feature that I missed a lot when I first got EE, the possibility of having external drives with roms without affecting the OS is amazing, I’m glad someone put my weird bash script to sleep with a real feature. Thanks for letting us know. Even if it doesn’t go to a release, it’s cool to be able to build it by ourselves.

1 Like

It is hoped that emuelec 4.6 official version can integrate this software package for mounting external drives.

Thank you very much for 7 Ji. EE is more wonderful with you.

2 Likes

I’m using google translator.

In EmuELEC 4.6 - which has now received the support for multiple discs mentioned here - how should I put different consoles on various USB media and on the Tv Box have access to games from all media simultaneously, making all consoles available in the initial menu at the same time?

Would I have to use the EMUELEC SETTINGS/EXTERNAL MOUNT OPTIONS path? How to make?

Is this possible without me having to add some script to the system (like the system Hozerino describes in this topic)? If so, what label would I have to give the partitions on external media?

I managed to put different consoles on 3 external media and using a hub I have access to all but one media at a time, alternating them in EXTERNAL MOUNT OPTIONS.

I cannot access the folders of the three USB media and consequently all the consoles at the same time.

use the EMUELEC SETTINGS/EXTERNAL MOUNT OPTIONS path

You need to use that option, but leave it as unset/empty: setting a drive in that option explicitly will make that drive the only one that’ll be used, not like what you want. The multi-drive logic will only be effective if you don’t set a drive explicitly, in which case every possible external drives will be scanned so mixing them would then be possible.

If so, what label would I have to give the partitions on external media?

You don’t need to set the label. Just edit the empty file “emuelecroms” you used to store inside the roms folder in the drive you use. Since you’re using three drives you would have three these mark files right? Each would be under the corresponding roms folder. The idea is to write system names (e.g. nes, ps1, etc, all those names that’ll be created automatically by EE if you used the drive) inside the “emuelecroms”, one system per line, so then only these listed systems will be used, not the whole drive. If you keep the mark file empty then the whole drive will be used. There could only be one drive proving the whole “roms” folder, and one drive providing a certain system.

Let’s assume you have three drive with these roms: you store multiple random small systems on drive 1, big ps1 games on drive 2, other heavy neogeo and mame games on drive3.

For drive 1, you would want to keep the “emuelecroms” file empty as it used to be, so the whole roms folder will be used, but systems in it could be replaced by other drives.
For drive 2, write ps1 in its emuelecroms, so only ps1 roms on this drive will be used, and it will replace ps1 roms on drive 1 (if any)
For drive 3, write neogeo and mame in its emuelecroms one per line, so only neogeo and mame roms on this drive will be used, and they will replace neogeo and mame roms on drive 1 (if any)

Josemar Leite Prete via EmuELEC <notifications@emuelec.discoursemail.com> 于 2022年12月17日周六 下午7:53写道:

2 Likes

I’m using google translator.

7Ji, thank you very much!

I have to thank you very much, but thank you very much for your detailed and very clear explanations about what procedure to do. It worked and I’m very happy!

I was on the right path, I did everything correctly, but what was missing for it to work was to edit the empty file “emuelecroms”. I didn’t know I had to do it that way.

My only reservation was about leaving the option EMUELEC SETTINGS/EXTERNAL MOUNT OPTIONS, as not “defined/empty”. I think you meant to use the “AUTOMATIC” option, as it is the only one that exists in ES, in addition to the definition of individual media.

I’ll let you know briefly what I did. I inform you that I did it only as an experiment, to know how it works.

I used an 8 GB SD Card, one of those very common ones, that comes with the beelink tv box, despite being generic it works well! I configured it to format in exfat and flashed it.

Then I booted, everything was normal, EmuELEC started and I configured the system. Through the network I put the bios and the bezels in the roms folder of the STORAGE partition, on the 8GB card (EXT4). That way I can only put roms on external media.

I formatted the three pen drives and an external HD with power supply as exfat. And to facilitate identification (on the box, over the network, on Windows) I put labels on the media. And label identification is very useful when choosing from the ES menu, when you want to access only one of the media. It looked like this:

HD-GAMES (here I put several consoles). (2 TB)

PD16-NEOGEO-FBNEO-MAME (16 GB)

PD32-3D0-ATMW-DC-NAO-SAT (32 GB)

PD64-PSX-PSP (64 GB)

Then I connected the pen drives and the HD to a USB hub, connected the hub to the box, set it to AUTOMATIC and it worked!!

This method of using multiple storage media turned out great! I want to congratulate you and the EmuELEC team for this initiative, it is extremely useful.

And it will definitely help a lot of people.

For example, the user may not be able to buy a 128 or 256 GB Sd Card, but he has a card from 8 GB and several smaller pen drives at home, as in my example.

You can use them together and the sum of their capacities can replace that 128 or 256 GB card. As in my case, 3 small thumb drives resulted in about 105 GB effective.

One final suggestion: it would be very helpful if this information - the need to edit the empty emuelecroms file and in what form - were put on the wiki! This is very useful for inexperienced users like me.

Once again, congratulations and thank you!

Finnaly finished my exams and got enough time to write a Wiki, this should be detailed enough for anyone that wants to mix ROMs from multiple drives

1 Like

7Ji,

Yes, certainly no one will have any difficulties, as always your explanation is very detailed so that there are no doubts.

In the last few days I’ve done several experiments with several units and several systems, everything works great!

Now everyone will be able to take advantage of the USB media they already have in their homes. Great!

Thank you very much for taking the time to do this, your initiative will be appreciated by everyone!

@7Ji , one question when i worked out Mixing ROMs from multiple drives, included one external USB pendrive along with originally internal TF card (EMUELEC system).
Shall I need to creat a additional “emuelecroms” file w/ whole path structure in the TF card EEROMS that did not include in the scenario of single drive?

Thanks. Regards

The mark file is always needed for any external drive you want to use for ROMs.

The mark file, with content, is only needed for external drives you want to use for ROMs of only specific systems.

The mark file, without content, i.e. empty, is needed for for THE external drive you want to use for all systems.

The EEROMS partition on your system drive is another case, it would always provide ROMs for all systems, unless you have created a mark file to specify it to only provide for specific systems.

There’s also rules that:

  1. There could only be one drive providing ROMs for all systems (Main drive)
  2. There could only be one drive providing ROMs for ONE specific system, and that system, even if it’s provided by such drive in rule 1, would be considered to be provided by this drive. (Alternative drives)

So you don’t need the mark file unless you want to use another external drive as the main drive and the internal one as the alternative

weirdly :thinking: the roms structure of the external drive w/ one specific romset, like dc only, overwrote the original EEROMS’s all directories of main drive roms as the default when I created a with-content mark file and did nothing of EEROMs.
will check again step by step. thanks for clarity.