Created
November 5, 2011 15:13
-
-
Save suapapa/1341643 to your computer and use it in GitHub Desktop.
ramdrive to swap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
import os | |
import sys | |
import commands | |
iRamName = "GIGABYTE i-RAM" | |
def foundDevName(modelName): | |
for c in "abcdefghijklmnopqrstuvwxyz": | |
devPath = "/dev/sd%s"%c | |
if os.path.exists(devPath): | |
report = commands.getoutput('/sbin/hdparm -i %s'%devPath) | |
for line in report.split('\n'): | |
if line.strip().startswith("Model=") and modelName in line: | |
return devPath | |
return None | |
iRamDevName = foundDevName(iRamName) | |
if not iRamDevName: | |
sys.exit(-1) | |
print iRamDevName | |
sys.exit(0) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
#DEV_IRAM=/dev/sdb | |
DEV_IRAM=`iram-get-devname` | |
PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
mkswap -f $DEV_IRAM | |
swapon $DEV_IRAM | |
;; | |
restart|reload|force-reload) | |
echo "Error: argument '$1' not supported" >&2 | |
exit 3 | |
;; | |
stop) | |
# swapoff $DEV_IRAM | |
# no op | |
;; | |
*) | |
echo "Usage: $0 start|stop" >&2 | |
exit 3 | |
;; | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
install: iram-swap iram-get-devname | |
cp iram-get-devname /usr/bin/ | |
cp iram-swap /etc/init.d/ | |
ln -s /etc/init.d/iram-swap /etc/rcS.d/S15iram-swap | |
@echo "all done" | |
uninstall: | |
rm -f /usr/bin/iram-get-devname | |
rm -f /etc/init.d/iram-swap | |
rm -f /etc/rcS.d/S15iram-swap | |
@echo "all done" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment