I used to have to do this on a home server on a single board computer with an external hard drive. I would not personally use "disk destroyer" for this task even though the code you have above is not destructive. I don't think you harmed your disk, but you played with fire! A mistyped dd command can wreck the contents of a drive. Again, that particular command as you had it should be harmless.
The hdparm utility would be the right way to disable sleep mode on an internal hard drive on a normal Linux distro, but external drives use cheap USB bridges that don't support the low level functions needed for hdparm to fix the sleep issue. That's been my experience anyway.
Flandango is probably correct about power usage, so check that first, but it still might be worth your time to use the touch command scheduled as a job instead of manually running a script from PuTTY.
Touch creates or updates a file with the current time when run. It's just enough write activity to keep a drive from sleeping. You can have it run on an interval using the cron daemon. Cron jobs don't work "out of the box" on MiSTer, but see the end of this message for a work around.
The touch command would be like this:
Code: Select all
touch /path/to/externalDrive/keepAwake
Where "keepAwake" is the empty file created and updated by this command. It can be named anything (it's best practice to avoid spaces in the file name though because sometimes it's hard for scripts to properly parse that file name).
If you did want to use the original script anyway, you can't paste it into the terminal like that and have it work. You will want to copy that text and paste it into an empty text file (Notepad++ if you're using Windows. Don't use the built-in Notepad program because it does not format the file correctly for Linux to be able to use it).
You could also create this file through PuTTY. Use the program nano to create the new text file where the script commands above will live. You should be able to copy and paste it in. Ctrl + s to save and Ctrl + x to exit.
The text file would be saved as the file "nameofscript.sh". The .sh means it's a shell script. You would then execute it by entering into the terminal:
or
assuming that the terminal is in the correct directory where the script is located. If not you can change to that directory using the "cd" command first or type out the full path and name of the script together:
Code: Select all
./media/fat/Scripts/nameofscript.sh
That will run it assuming you put it on the micro SD card with the other MiSTer scripts. If you place it there, then you should be able to run it from the main MiSTer menu like the other scripts, although I think you wouldn't want to do that as it might lock the screen to the terminal while that runs.
You can also schedule that script to run using the cron daemon although it's cleaner to just replace the touch command within the quotation marks below with the dd command from the script.
I'm putting the following in bold for everyone, not yelling at you, OP.
I've seen this come up a few times. Cron jobs are possible but not setup to work by default on the MiSTer Linux distro. I got cron jobs working in a pretty hacky way, but it does work.
The folders /var/spool/cron and /var/spool/cron/crontabs need to be created after each startup as well as the cron job/s in the file at /var/spool/cron/crontabs/root
The cron daemon then needs to be started.
You could use crontab to create the commands in the cron job file, however it is destroyed upon shutdown.
That missing file with the desired command/s can be recreated in different ways, but the below is easier for new Linux users than explaining how to use and exit the vi editor with crontab or how to change vi to nano first and then how to move the crontab output to a different location so it's not destroyed at shutdown.
I know there are probably better ways to do this.
"Don't @ me!"
Okay TLoMatt,
Edit /media/fat/linux/user-startup.sh and add the following to the end of the file:
Code: Select all
mkdir -p /var/spool/cron/crontabs
echo "*/25 * * * * touch /path/to/externalDrive/keepAwake" > /var/spool/cron/crontabs/root
crond
Save and reboot. It should work going forward. You can replace the touch command in the above text with whatever command you want at whatever interval.
The above code block will run touch once every 25 minutes to update the keepAwake file's properties with the current time which will also keep the hard drive spinning.
The echo command is putting the text in quotations (the command you want automated) in the file after the > symbol. If you want to add additional cron jobs then you will still use the echo command but you will need to use >> before each file name.
> is "save this command's output to this file name and overwrite it if it exists."
>> is "add this output at the end of the existing text in this file or create the file with this text if it doesn't exist."
So it would look like this:
Code: Select all
echo "*/25 * * * * touch /path/to/externalDrive/keepAwake" > /var/spool/cron/crontabs/root
echo "*/25 * * * * otherCommand" >> /var/spool/cron/crontabs/root
Actually since the file that contains the cron job commands gets destroyed upon power off, you could use >> with every echo command. There's no chance we're adding to an existing file accidentally when we meant to start fresh. I just wanted you to understand the difference in case you do want to use multiple jobs at some point.
This site can help you format new cron job lines properly and easily:
https://crontab.guru/
If you want to hide the keepAwake file just use a period at the beginning of the file name. You can do the same with folders.
You can disable these commands from running by editing the file at /media/fat/linux/user-startup.sh and placing a # at the beginning of each line.
The way above would not be necessary on a standard Linux distro. Linux isn't as complicated as you might think if you're used to Windows or MacOS, it's just different. Things are more open to modifications so that you get to have the final say about what your computer does instead of having to accept that being decided for you by a corporation. The new Steam Deck is running on Linux, and it's a great example of how malleable Linux is and how easy it can be to use when a great team gets behind a distribution. The MiSTer is also another great example, of course, but we all know the FPGA part is the real magic with the Linux distro being tailored for speed and small size.