Switch to USB

Kernel, Main, Utilities & Applications, Miscellaneous Devices.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Switch to USB

Unread post by jca »

As mounted a NTFS volume does not allow files to be made executable. To run a script you have to go to the console and start the script with
bash <scriptname>.

Found on the internet:
I had the exact same problem and the solution in my case was to write de exec mount option after the users option. That's because the users option implicitly activate the noexec option, so you have to explicitly specify exec.

With a volume formatted ext4 it gets worse: "Switch to USB" is grayed out.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

State of the Switch to USB experiment.

1.First test done with a clean SD card with Mr. Fusion and a clean USB HDD formatted NTFS.
No major problems except not being able to run scripts from the OSD, they must be run from the console using bash <Script Name>.
This is due to the way the USB drive is mounted, by default the option noexec is used. Option exec should fix the problem.
I suppose it would be an easy fix.

2. I redid the install with the drive formatted as ext4 which would fix the problem of running scripts from the OSD.
This was short lived: with a USB drive formatted ext4 the Switch to USB is grayed out in the OSD.
Is there any specific reason for that?
My normal setup which uses a drive with only the games directory (no Switch to USB) is formatted ext4 and I do not experience any problem.
I suppose this could also be fixed.

3. Back to square one with NTFS.
I rebooted MISTer to be sure of having the minimum of things open on the USB HDD.
I SSHed into MISTer and typed mount:
/dev/sda1 on /media/usb0 type fuseblk (rw,nosuid,nodev,noexec,noatime,sync,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
In the OSD I selected Scripts, navigated to the Scripts folder on the SD card without running any script, just to stay as far away as possible from the USB HDD.
I typed unmount /dev.sda1 and prayed. Nothing bad happened.
I typed mount -o exec /dev/sda1 /media/usb0. Again nothing bad happened. I have been stingy with the options as can be seen by typing mount.
/dev/sda1 on /media/usb0 type fuseblk (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other,blksize=4096).
Next time I will do better.
Going back to the OSD I just had a window saying No File! I guess the unmounting was not appreciated but pressing the OSD button 2 times things when back to normal.
First thing I did was to run a script from the OSD -> No problem at all.
So far I don't have much installed: all arcades from the update all script, Acorn Atom a new core and C64 with the OneLoad64 Games Collection.
Everything seems to be fine.

I know that when Switch to USB is mentioned it is advised not to use it due to problems.
Anyone knowing about these problems please let me know what they are so I can test it.
I will keep testing but so far I do not have any major problem.

Thanks for your help, it will be highly appreciated.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

I updated the mount command in order to have the same options as when the USB HDD is originally mounted by MISTer except for the default option of noexec which I replaced with exec in order to be able to run scripts from the OSD.
mount -t ntfs-3g -o exec,noatime,sync,default_permissions /dev/sda1 /media/usb0
Result of the mount command:
/dev/sda1 on /media/usb0 type fuseblk (rw,nosuid,nodev,noatime,sync,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)

Result of the mount command when the USB HDD is originally mounted by MISTer:
/dev/sda1 on /media/usb0 type fuseblk rw,nosuid,nodev,noexec,noatime,sync,user_id=0,group_id=0,default_permissions,allow_other,blksize=4096)
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

I created a S99SwitchToUSB script:

#!/bin/bash
umount /dev/sda1
mount -t ntfs-3g -o exec,noatime,sync,default_permissions /dev/sda1 /media/usb0

Copied it to /etc/init.d along with my S99Spin script which keeps the USB HDD spinning (viewtopic.php?p=14964#p14964).
When I start my MISTer it looks like I have a fully functional MISTer switched to USB.
Time will tell.
But now is the time to fill the games directory and look for any problem.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

End of the Year Report card on Switch to USB

There are known knowns; there are things we know we know. We also know there are known unknowns; that is to say we know there are some things we do not know. But there are also unknown unknowns—the ones we don't know we don't know.

Regarding the knows for which I am in the known: everything is in this thread.

Regarding the knows by other users (scripts and configs) they are still unknown to me (not much of a feedback, it looks like I am talking to myself).

Regarding the unknown unknowns they will remain in this state for the time being.
cursedverses
Posts: 180
Joined: Sun May 24, 2020 9:13 pm
Has thanked: 186 times
Been thanked: 34 times

Re: Switch to USB

Unread post by cursedverses »

It's worth looking at the /etc/usbmount/usbmount.conf and removing noexec from the mountoptions line, so:

Code: Select all

MOUNTOPTIONS="sync,noexec,nodev,noatime,nodiratime"
becomes

Code: Select all

MOUNTOPTIONS="sync,nodev,noatime,nodiratime"
I then usually format exFAT, once that's all plugged in, hit F9 (or ssh in) and do the following:

Code: Select all

mkdir /media/usb0/Scripts
cp /media/fat/Scripts/update.sh /media/usb0/Scripts
chmod +x /media/usb0/Scripts/update.sh
nano /media/usb0/Scripts/update.ini
This goes into my update.ini file:

Code: Select all

BASE_PATH="/media/usb0"
ADDITIONAL_REPOSITORIES+=( "https://github.com/MiSTer-devel/Fonts_MiSTer|pf|$BASE_PATH/font" )
You should then be able to select the update script from usb0 and have it update your cores (apart from a select few that will absolutely go to your SD card regardless, like the MiSTer core itself)
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

Thanks very much for this information. When I started to experiment with Switch to USB and discovered the noexec problem I knew that there should be some settings I could change somewhere in Linux. But it has been so long since I did Linux administration that I decided to use this /etc/init.d hack, it works but I did not like too much the idea and you solution is much better. I will try it. You are using exFAT; is there any advantage to use this FS compared to NTFS?
Are you using Switch to USB full time and in the affirmative did you experience any glitch?
On my side I had a strange problem with the update scripts: the script wants to create the sub-directories in the games directory if they do not exist but it does not get it right in some cases. The problem has to do with case sensitivity: for example the script creates the NeoGeo sub-directory but the real name of the core is NEOGEO and the sub-directory name should be NEOGEO. I was surprised when I tried to load a game and was greeted with Directory does not exists. I discovered that NTFS is case sensitive and Linux handles it properly. Using FTP I created the NEOGEO directory, moved the files from NeoGeo to NEOGEO and deleted NeoGeo without any problem. After sometime and several updates I noticed that the NeoGeo directory came back and did not bother deleting it. After filling my games sub-directories with ROMs I decided to make a backup of my USB drive under Windows. Things became weird under Windows: a dir command showed both directories and before making the backup I decided to delete these "duplicates" but before doing it I looked in both directories and surprise! both directories contained ROMs. Brain dead Windows ignores the case sensitivity of NTFS and looking at the contents of NEOGEO and NeoGeo only looked at NEOGEO. I suppose MS did this for "backwards compatibility": users are used to have files names case insensitive so ignore the case sensitivity of NTFS. This is stupid, if I had just deleted the directory it would have been the wrong one.
I guess using exFAT would not exhibit this behavior.
On the other hand NTFS is a much more robust FS.
I see that it is possible to tell Linux to be case insensitive with NTFS using the mount option -o ignore_case but it also requires mounting the drive using the type -t lowntfs-3g which I can do in my /etc/init.d script but I am not sure how to do this using /etc/usbmount/usbmount.conf. I will try replacing ntfs fuseblk in FILESYSTEMS with ntfs lowntfs-3g fuseblk.
jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

Latest and last (?) update:
I did not work on my Switch to USB setup for a while: my test drive comes from a dead old laptop and is rather small so I have been working on a bigger one but just with the games directory on it (no Switch to USB) in order to organize my roms and prepare everything for the day I decided to Switch to USB for good (I call this drive my "reorganized" drive further down).
The day has come and I used my 1TB WD Elements HDD which I used initially (just with the games directory) and was formatted ext4 (not a good idea).
I decided do ditch NTFS and go with exFAT.

I started from zero:
Reformatted my SD card with SDFormater and used Mr. Fusion to install MISter on it.

Reformatted my HDD to exFAT.

Connected the HDD and booted from the SD card.

Went into the menu and Switched to USB.

SSHed into MISTer.

Copied /media/fat/MiSTer_example.ini to /media/fat/MiSTer.ini and changed the video mode corresponding to my monitor.

Edited the file /etc/usbmount/usbmount.conf and replaced the line
MOUNTOPTIONS="sync,nodev,noexec,noatime,nodiratime"
with
MOUNTOPTIONS="sync,nodev,noatime,nodiratime"
in order to be able to run MISTer scripts.

Copied update.sh from /media/fat/Scripts to /media/usb0/Scripts.

Created update.ini with the line BASE_PATH="/media/usb0".

Rebooted MISTer.

Ran the update script.
Now I have an updated MISTer with no cores and no roms.

I downloaded the update_all.sh script (the usb version).

Created the following update_all.ini
BASE_PATH="/media/usb0"
BIOS_GETTER_INI="update_all.ini"
MAME_GETTER_INI="update_all.ini"
HBMAME_GETTER_INI="update_all.ini"
ARCADE_ORGANIZER_INI="update_all.ini"
BIOSDIR="/media/usb0/BIOS"
ROMMAME="/media/usb0/games/mame"
ROMHBMAME="/media/usb0/games/hbmame"
MRADIR="/media/usb0/_Arcade"
ORGDIR="/media/usb0/_Arcade/_Organized"
JOTEGO_UPDATER="true"
BIOS_GETTER="false"
UNOFFICIAL_UPDATER="true"
In my case I disabled BIOS_GETTER as I already have all my bioses on my "reorganized" drive.

I shut down MISTer, connected the USB drive to my PC along with my "reorganized" drive and copied the games directory from the "reorganized" drive to the games directory of the WD Elements drive (I excluded mame and hbmame as they have been filled with the latest by the update_all script.

I reconnected the WD Elements to MISTer and rebooted MISTer. So far so good.
I just have to double check the arcade cores as it has been mentioned that the update script has some problems downloading the proper mras for some cores (Pengo for example).
User avatar
segamemister
Posts: 68
Joined: Tue Mar 08, 2022 3:13 pm
Location: Chao Garden
Has thanked: 8 times
Been thanked: 13 times

Re: Switch to USB

Unread post by segamemister »

@jca

A few questions since i follow your post

  1. do you have any issues with arcade roms? for me some wont even load yet if i use an altervite boom works no problem

  2. did you have any issues with the update all scripts havnt run it yet but my mister was fully upto date when i moved my sd card over to usb

jca
Top Contributor
Posts: 1911
Joined: Wed May 27, 2020 1:59 pm
Has thanked: 145 times
Been thanked: 454 times

Re: Switch to USB

Unread post by jca »

This is very old and I don't use "Switch to USB" any longer as it was said to be kind of obsolete by Sorge. Instead he recommended to use symlinks which I did. Also all the references to the update script are relative to the old update all script which did not use the new downloader. I don't think the downloader was available at that time.

Post Reply