Skip to content

Instantly share code, notes, and snippets.

@viljoviitanen
viljoviitanen / zzspindown
Last active December 11, 2015 07:58
Spins down an idle disc. Made for raspberry pi raspbian wheezy, and my external usb drive which spins down with the command "sg_start -r -S".
#!/bin/sh
#spins down a disk. put this in /etc/cron.hourly so that it runs last
#cronjobs are run in alphabetical order so zzspindown is a sure bet...
#licence: public domain
DISK=sda
SGSTART=/usr/bin/sg_start
if [ ! -x $SGSTART ]
then
@viljoviitanen
viljoviitanen / zram.sh
Last active December 11, 2015 05:08
Puts a "zram" (compressed memory based) swap on a machine. Works at least in some recent debian based distros, maybe others too. Script was made for debian (raspbian) wheezy. Stuff that gets put in the zram swap usually compresses quite well
#!/bin/sh
FILE=/etc/rc.local
grep -q enable_zram $FILE && echo Zram already enabled && exit 1
#remove the exit 0 line. Hopefully it's the last line.
sed -i -e "/^exit 0/ d" $FILE
cat >>$FILE <<END
#enable_zram
modprobe zram
#a good size is about 10-20% of physical ram.
echo 52428800 > /sys/block/zram0/disksize