Benutzer-Werkzeuge

Webseiten-Werkzeuge


howto:ramdisk_einrichten

Diese Seite befindet sich noch im Aufbau. Quellen:

#!/bin/sh
### BEGIN INIT INFO
# Provides: A ramdisk to save intermittent data
# Required-Start:
# Required-Stop:
# X-Start-Before:
# X-Stop-After:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: create a ramdisk
# Description: create a ramdisk with 50MB and mount it to /media/ramdisk
### END INIT INFO
#
case "$1" in
    start)
        if [ ! -e /media/ramdisk ]; then
                mkdir /media/ramdisk
        fi
	echo "Creating ramdisk..."
        #/sbin/mke2fs -m 0 /dev/ramdisk
	#/sbin/mkfs.ext4 -m 0 /dev/ram0
        /bin/mount -t tmpfs /dev/ram0 -o size=50m /media/ramdisk
	if [ -e /media/ramdisk-backup.tar.gz ]; then
		echo "Copying files to ramdisk..."
		cd /media
		tar zxvf ramdisk-backup.tar.gz
		echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched from HD >> /var/log/ramdisk_sync.log
	fi
	;;
    sync)
	echo "Synching files from ramdisk to Harddisk"
	echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
	cd /media
	mv -f ramdisk-backup.tar.gz ramdisk-backup-old.tar.gz
	tar zcvf ramdisk-backup.tar.gz ramdisk
	;;
    stop)
	echo "Synching logfiles from ramdisk to Harddisk"
	echo [`date +"%Y-%m-%d %H:%M"`] Ramdisk Synched to HD >> /var/log/ramdisk_sync.log
	cd /media
	tar zcvf ramdisk-backup.tar.gz ramdisk
	/bin/umount -v /media/ramdisk
	;;
    *)
        echo "Usage: $0 {start|stop|sync}"
        exit 1
esac
exit 0
howto/ramdisk_einrichten.txt · Zuletzt geändert: 2013/11/05 10:06 von echo