Useful SSH Commands For MiSTer?
Useful SSH Commands For MiSTer?
-
- Posts: 2
- Joined: Sun May 24, 2020 7:31 pm
- Has thanked: 57 times
- Been thanked: 1 time
- PistolsAtDawn
- Posts: 359
- Joined: Fri Feb 18, 2022 7:29 pm
- Has thanked: 307 times
- Been thanked: 100 times
Re: Useful SSH Commands For MiSTer?
SSH is simply a Secure SHell (almost always through a network, but can be done over other mediums like USB), and that shell in our case is BASH, or the Bourne-Again SHell.
Here is the online manual for it: https://www.gnu.org/software/bash/manua ... tures.html
For those who don't use Linux outside of the MiSTer, I would say that the basics of the shell are good to understand, but the shell is also able to be used in very complicated and powerful ways depending on what it is a user needs to accomplish. Those uses are largely going to be beyond the needs of most of the community.
Here is the online manual for it: https://www.gnu.org/software/bash/manua ... tures.html
For those who don't use Linux outside of the MiSTer, I would say that the basics of the shell are good to understand, but the shell is also able to be used in very complicated and powerful ways depending on what it is a user needs to accomplish. Those uses are largely going to be beyond the needs of most of the community.
Re: Useful SSH Commands For MiSTer?
I think SSH is quite useful in my opinion. I actually feel lazy most of the time to fetch the keyboard when I need to inspect the contents of the SD card or downloading things directly on my MiSTer while I have it plugged in. So what I end up doing is using a terminal emulator on my phone and connecting to MiSTer via SSH to accomplish this.
-
- Top Contributor
- Posts: 860
- Joined: Wed Feb 09, 2022 11:50 pm
- Has thanked: 64 times
- Been thanked: 195 times
Re: Useful SSH Commands For MiSTer?
I normally leave an SSH session open to the Mister all the time. I use it to run upgrades or occasionally do housekeeping. That's how I set up my SMB3 share, for instance, by downloading and using the official script, and then setting up symlinks so that there is absolutely no confusion about where files go.
The biggest advantage, IMO, is cut/copy and paste. You can drop to the SSH command line from the main Mister menu by hitting F9, but there's no mouse support turned on in Linux, and thus no ability to mark text for copying. Running from a remote terminal is much more convenient.
There's a bunch of official Mister scripts here:
https://github.com/MiSTer-devel/Scripts_MiSTer
They don't seem to be installed by default anymore. You have to click through to the Raw version for it to be downloadable with wget. For instance, clicking on security_fixes.sh will take you here:
https://github.com/MiSTer-devel/Scripts ... y_fixes.sh
... but that won't work as a link to download. The header that says "437 lines" has a Raw button over on the right. Click that, copy that URL, and prepend wget:
(Wget downloads into the current dir, so I went to Scripts first.)
There's lots of interesting stuff in that repository. The "make_linux_nice" script also needs a bunch of extra files in the "nice-linux" directory, so you'll need to create a local nice-linux directory in Scripts, and download all the files for that script to work. There's probably an easy way to grab all of them at once, but I didn't bother figuring that out.
edit: be careful with the mac_address_change.sh script. It erases any existing u-boot.txt settings, like fast USB polling, by clobbering /media/fat/linux/u-boot.txt.
This is the bad line in question:
It should be changed to:
That's changing from one > to two >>, meaning to append, instead of overwrite.
The biggest advantage, IMO, is cut/copy and paste. You can drop to the SSH command line from the main Mister menu by hitting F9, but there's no mouse support turned on in Linux, and thus no ability to mark text for copying. Running from a remote terminal is much more convenient.
There's a bunch of official Mister scripts here:
https://github.com/MiSTer-devel/Scripts_MiSTer
They don't seem to be installed by default anymore. You have to click through to the Raw version for it to be downloadable with wget. For instance, clicking on security_fixes.sh will take you here:
https://github.com/MiSTer-devel/Scripts ... y_fixes.sh
... but that won't work as a link to download. The header that says "437 lines" has a Raw button over on the right. Click that, copy that URL, and prepend wget:
Code: Select all
cd /media/fat/Scripts
wget https://raw.githubusercontent.com/MiSTer-devel/Scripts_MiSTer/master/security_fixes.sh
There's lots of interesting stuff in that repository. The "make_linux_nice" script also needs a bunch of extra files in the "nice-linux" directory, so you'll need to create a local nice-linux directory in Scripts, and download all the files for that script to work. There's probably an easy way to grab all of them at once, but I didn't bother figuring that out.
edit: be careful with the mac_address_change.sh script. It erases any existing u-boot.txt settings, like fast USB polling, by clobbering /media/fat/linux/u-boot.txt.
This is the bad line in question:
Code: Select all
echo "ethaddr=${MAC_ADDRESS^^}" > /media/fat/linux/u-boot.txt
Code: Select all
echo "ethaddr=${MAC_ADDRESS^^}" >> /media/fat/linux/u-boot.txt
Re: Useful SSH Commands For MiSTer?
i use scp quite often. it copies files/folders via ssh. For example:
For a single file
scp file_to_copy user@192.168.178.123:/media/fat/location/
for a folder
scp -r folder_to_copy user@192.168.178.123:/media/fat/location/
For a single file
scp file_to_copy user@192.168.178.123:/media/fat/location/
for a folder
scp -r folder_to_copy user@192.168.178.123:/media/fat/location/
• FireBee • Falcon030/040/060 • MiSTer • TT • (Mega)STe • Suska III-B • Suska III-C • (Mega)ST •
Re: Useful SSH Commands For MiSTer?
No need to ssh into the box at all, just execute the script via ssh. For example:Bits n Stuff wrote: ↑Sun Jul 24, 2022 4:11 pm ssh root@xxx.xxx.x.xxx
cd /media/fat/Scripts; ./update_all.sh
ssh root@xxx.xxx.x.xxx "bash /media/fat/Scripts/update_all.sh"
• FireBee • Falcon030/040/060 • MiSTer • TT • (Mega)STe • Suska III-B • Suska III-C • (Mega)ST •
- pgimeno
- Top Contributor
- Posts: 710
- Joined: Thu Jun 11, 2020 9:44 am
- Has thanked: 277 times
- Been thanked: 226 times
Re: Useful SSH Commands For MiSTer?
Keep in mind that the command line of the MiSTer is a Linux system.
That means you can do many things that can be done with a Linux system. For example, running the converters in my signature (if you first place them in an appropriate directory in the MiSTer where you can invoke them).
That means you can do many things that can be done with a Linux system. For example, running the converters in my signature (if you first place them in an appropriate directory in the MiSTer where you can invoke them).
Converters I've written: Floppy DIM/FDI/FDD/HDM to D88, D88 to XDF, Tape SVI 318/328 CAS to WAV
- PistolsAtDawn
- Posts: 359
- Joined: Fri Feb 18, 2022 7:29 pm
- Has thanked: 307 times
- Been thanked: 100 times
Re: Useful SSH Commands For MiSTer?
That message you're getting for gdrive stuff is saying the computer it's running on has too new of a kernel for the script to run properly and that the author hasn't updated it yet for the 5.XX series kernel.
-
- Top Contributor
- Posts: 860
- Joined: Wed Feb 09, 2022 11:50 pm
- Has thanked: 64 times
- Been thanked: 195 times
Re: Useful SSH Commands For MiSTer?
It's been that way for awhile, and I find it very surprising, because if there's one thing the Linux devs are passionate about, it's never ever breaking userspace programs. And I'm not even sure why a gdrive-sync script would care about the Linux version at all. It should be doing user-level I/O, which pretty much any Linux kernel would support, going way, way back.
I wonder if it's some other binary that got dropped from the distro, and the error message is bad?
edit: it's looking for a binary named 'gdrive', that somehow seems to have been dropped.
I wonder if it's some other binary that got dropped from the distro, and the error message is bad?
edit: it's looking for a binary named 'gdrive', that somehow seems to have been dropped.
- Newsdee
- Top Contributor
- Posts: 873
- Joined: Mon May 25, 2020 1:07 am
- Has thanked: 104 times
- Been thanked: 239 times
- Natrox
- Scripting Wizard
- Posts: 36
- Joined: Thu Aug 04, 2022 2:05 pm
- Has thanked: 8 times
- Been thanked: 75 times
Re: Useful SSH Commands For MiSTer?
On Google Drive, the binary still downloads just fine on my end. You may have to reinitialize the entire thing by deleting the ".gd" folder and such. Or you can manually wget the binary from here https://github.com/odeke-em/drive/relea ... rive_armv7. You can put this in "/media/fat/linux/" and rename it to "gdrive", chmod +x it and it should work.
There are many useful commands, but it comes down to how comfortable you are with Linux. As a daily driver and also someone experienced with ARM embedded Linux, I love to mess around to add extra functionality.
For example, I have done this:
To be able to install Entware generic armv7 binaries. I don't recommend you do this unless you understand Linux well enough, but installing Entware stuff gives you a package manager (opkg) allowing you to install many standard tools.
I've installed GCC, mosh-server (nice SSH alternative), btrfs-progs, and most importantly, borg.
Borg is a tool to do deduplicated backups. I've made a backup of the whole system including SD (around 100GB total) to my SMB share. After compression and deduplication it only takes up 33GB.
Here's an example of the script I use to incrementally backup the SD:
I can run this at any time and it will only archive the differential changes, making it very compact unless you completely swap out every ROM.
Next, I want to look into using BTRFS with compression and deduplication for the SD. Considering ROMs have a lot of dead space and repetition (except .chd), there's a lot of extra space you can get out of an SD card. I am not sure if the kernel supports BTRFS, but I already installed the tools. I will have to check later.
Here's a script I'll share that can be used to open a terminal on the MiSTer itself. It goes into "/media/fat/Scripts" and I've named it "open_screen.sh":
It's fairly simple but effective, it opens up a new "screen" and sets you up with a prompt. You can run whatever command you'd like and then use "CTRL+A" and then "D" to detach and return to the menu. Once you run the script again, you will return to the prompt you were using. You can use it to run things in the background without the need for SSH.
There is much more you can do with Entware. I've also got git installed, so I can clone new repositories right on the MiSTer itself. I've got "axel" so I can do fast multithreaded downloads - beats "wget" for big stuff. You can install "transmission" to run torrents on the MiSTer (although not super useful if you run a home server). There are also quite a lot of VPN tools which may be useful if you are away from home but want to access ROMs stored in your home network. Hell there is even "apache" and "nginx" so you could run a HTTP server on the MiSTer as an alternative way to work with it (maybe useful if you run an arcade cabinet).
Also, mandatory neofetch:
There are many useful commands, but it comes down to how comfortable you are with Linux. As a daily driver and also someone experienced with ARM embedded Linux, I love to mess around to add extra functionality.
For example, I have done this:
Code: Select all
mount --bind /media/fat/opt /opt
I've installed GCC, mosh-server (nice SSH alternative), btrfs-progs, and most importantly, borg.
Borg is a tool to do deduplicated backups. I've made a backup of the whole system including SD (around 100GB total) to my SMB share. After compression and deduplication it only takes up 33GB.
Here's an example of the script I use to incrementally backup the SD:
Code: Select all
cd /media/fat
borg create -s -v -C lz4 -e "_CIFS" -p /media/fat/_CIFS/Borg::$(date +%s) .
Next, I want to look into using BTRFS with compression and deduplication for the SD. Considering ROMs have a lot of dead space and repetition (except .chd), there's a lot of extra space you can get out of an SD card. I am not sure if the kernel supports BTRFS, but I already installed the tools. I will have to check later.
Here's a script I'll share that can be used to open a terminal on the MiSTer itself. It goes into "/media/fat/Scripts" and I've named it "open_screen.sh":
Code: Select all
#!/bin/sh
screen -R htty
There is much more you can do with Entware. I've also got git installed, so I can clone new repositories right on the MiSTer itself. I've got "axel" so I can do fast multithreaded downloads - beats "wget" for big stuff. You can install "transmission" to run torrents on the MiSTer (although not super useful if you run a home server). There are also quite a lot of VPN tools which may be useful if you are away from home but want to access ROMs stored in your home network. Hell there is even "apache" and "nginx" so you could run a HTTP server on the MiSTer as an alternative way to work with it (maybe useful if you run an arcade cabinet).
Also, mandatory neofetch:
Re: Useful SSH Commands For MiSTer?
Very helpful thread. I like the way i can have an open session to my mister. Can I load up games directly from SCP? or is that a stupid question.
Im updating from SCP and dropping files in and out so got that far.
Im updating from SCP and dropping files in and out so got that far.
- Natrox
- Scripting Wizard
- Posts: 36
- Joined: Thu Aug 04, 2022 2:05 pm
- Has thanked: 8 times
- Been thanked: 75 times
Re: Useful SSH Commands For MiSTer?
I don't think you can, SCP is purpose-built for linear file transfer whereas games require random access. You can of course SCP to a temporary folder, and set up a script to clear it at boot.
There are two other ways:
- Using Samba, or Windows File Sharing. It's possible to set up shares on either Windows or Linux which can hold your games. Using this, you can mount the share on the MiSTer and stream your games over the network directly. Do keep in mind that access can be a bit slower. I've noticed for instance that running PSX games with "Fast Seek" on causes some stutter now and then, probably because my wifi can't keep up with the seek speed. See "cifs_mount.sh" in the scripts folder.
- Similar to Samba, you can also use NFS if you have a Linux computer that stores your games! Although you can set up NFS on Windows too, I am not familiar with it and I think you need third-party software. The benefit of NFS is that it couples well with SSH, and you have more flexibility in choosing which folder(s) to mount. In terms of performance, it's basically like Samba.
Of course, you can also use an external USB drive - maybe fitted with an SSD. I would recommend building your own by buying an NVMe drive and an enclosure. These things are blazingly fast, although the MiSTer probably won't use its full potential, transferring games onto it is super quick.
Re: Useful SSH Commands For MiSTer?
How does one install Entware?Natrox wrote: ↑Wed Aug 24, 2022 2:45 am For example, I have done this:To be able to install Entware generic armv7 binaries. I don't recommend you do this unless you understand Linux well enough, but installing Entware stuff gives you a package manager (opkg) allowing you to install many standard tools.Code: Select all
mount --bind /media/fat/opt /opt
I've installed GCC, mosh-server (nice SSH alternative), btrfs-progs, and most importantly, borg.