A Xmas present
This is an updated version of my post explaining how to make your USB HDD forever.
With this version your HDD will be made to spin forever automatically upon bootup.
I changed the name of the 2 scripts: first I removed the .sh "extension" so the scripts do not show up in the OSD -> Scripts. Second the launcher script becomes S99spin and the main script becomes Spin.
The S99spin script will be copied to /etc/init.d in order to start automatically, the name was chosen so this script starts after all regular scripts as the last one is S91smb (it is not necessary for this script to be the last one but it is the way I did it).
The 2 scripts will be created in /media/fat/Scripts, even if you selected "Switch to USB" in the OSD.
The S99spin script will be copied to /etc/init.d and the original kept in the Scripts folder: if linux is updated the script is likely to have disappeared from the /etc/init.d directory and you can easily copy it back.
You need 2 things: how long it takes for the drive to spin down and the uuid of the disk.
My drive spins down after 5 minutes and I read the disk every 4 minutes.
Getting the uuid:
You can use the MISTer terminal or ssh. I prefer ssh as I can copy/paste the uuid.
Type blkid, you get something like
/dev/loop0: UUID="2d232a45-aeab-4b31-a8ad-ae0f27091c95" BLOCK_SIZE="1024" TYPE="ext4"
/dev/mmcblk0p1: LABEL="MiSTer_Data" UUID="017B-FF39" BLOCK_SIZE="512" TYPE="exfat" PTTYPE="dos" PARTUUID="3107eecb-01"
/dev/mmcblk0p2: PARTUUID="3107eecb-02"
/dev/loop8: LABEL="rootfs" UUID="356e4b65-6863-4872-9649-633c109c607d" BLOCK_SIZE="1024" TYPE="ext4"
/dev/sda1: UUID="993eedbb-30e9-410c-a363-560473d75e74" BLOCK_SIZE="4096" TYPE="ext4" PARTUUID="3c2d443f-01"
The HD is /dev/sda1
The main script Spin:
#!/bin/bash
while :
do
dd if=/dev/disk/by-uuid/993eedbb-30e9-410c-a363-560473d75e74 of=/dev/null count=1 skip=$RANDOM >/dev/null 2>&1
sleep 4m
done
The launcher script S99spin
#!/bin/bash
nohup /media/fat/Scripts/Spin </dev/null >/dev/null 2>/dev/null &
You can now test your scripts. At the console or via ssh:
/root# cd /media/fat/Scripts
/media/fat/Scripts# ./S99spin
/media/fat/Scripts# ps -ef | grep "Spin"
11664 root {Spin} /bin/bash /media/fat/Scripts/Spin
11737 root grep Spin
After 5 minutes (in my case) the HDD is still spinning. Time to copy S99spin to /etc/init.d and reboot.
/media/fat/Scripts# cp S99spin /etc/init.d
After reboot you can always check that the script is running with
ps -ef | grep "Spin"
Notes:
if you want to use these scripts do not forget to change the uuid and the sleep time in accordance to your HD.
If you are using Windows to create these scripts use Notepad++ and go to Edit -> EOL Conversion -> Unix (LF) before saving as Linux does not like at all DOS/Windows end of line. If you are using a Mac don't ask me as I won't touch Apple products even with a 10 foot pole.
If you already have these scripts from my previous post you can do a quick thing:
mv Spin.sh S99spin
cp S99spin /etc/init.d
After reboot your disk should be spinning, the main script will still be the original name and visible in the oSD Scripts menu.