add script grml2ram and manpage for grml2ram
authorMichael Prokop <mika@grml.org>
Tue, 12 Dec 2006 18:59:29 +0000 (19:59 +0100)
committerMichael Prokop <mika@grml.org>
Tue, 12 Dec 2006 18:59:29 +0000 (19:59 +0100)
manpages/grml2ram.8 [new file with mode: 0644]
usr_sbin/grml2ram [new file with mode: 0755]

diff --git a/manpages/grml2ram.8 b/manpages/grml2ram.8
new file mode 100644 (file)
index 0000000..34310d2
--- /dev/null
@@ -0,0 +1,21 @@
+.TH grml2ram 8
+.SH "NAME"
+grml2ram \- copy compressed GRML image to RAM
+.SH SYNOPSIS
+.B grml2ram
+.SH DESCRIPTION
+grml2ram is a script which copies the compressed GRML image to RAM and
+unmounts /cdrom then. This allows ejecting of the CD (run 'eject /dev/cdrom' for example)
+afterwards. Therefore running the grml live-cd without the need for a present grml-ISO is possible.
+Please notice that you need enough free RAM to run grml2ram. At least enough space for the compressed
+GRML image itself (about 52MB for grml-small and 685MB for grml) and for running userspace software
+afterwards (at least 128MB are recommended) should be available.
+.SH OPTIONS
+grml2ram supports only the following option:
+.TP
+.B -f, \-\-force
+Force copy process for GRML image even though the check for enough free RAM fails.
+.SH SEE ALSO
+.B bootoption toram
+.SH AUTHOR
+This manual page was written by Michael Prokop <mika@grml.org> for the grml project.
diff --git a/usr_sbin/grml2ram b/usr_sbin/grml2ram
new file mode 100755 (executable)
index 0000000..bbd4bd6
--- /dev/null
@@ -0,0 +1,56 @@
+#!/bin/sh
+# Filename:      grml2ram
+# Purpose:       copy compressed GRML image to RAM
+# Authors:       grml-team (grml.org), (c) Michael Schierl <schierlm-public@gmx.de>, (c) Michael Prokop <mika@grml.org>
+# Bug-Reports:   see http://grml.org/bugs/
+# License:       This file is licensed under the GPL v2.
+# Latest change: Die Dez 12 19:55:05 CET 2006 [mika]
+################################################################################
+
+set -e
+
+. /etc/grml/lsb-functions
+. /etc/grml/script-functions
+
+check4root || exit 1
+check4progs rsync gawk || exit 2
+
+if ! isgrmlcd ; then
+   eerror "Not running grml in live-cd mode. Nothing to be done, exiting." ; eend 1
+   exit 1
+fi
+
+if ! [ -r /cdrom/GRML/GRML ] ; then
+   eerror "Can not access /cdrom/GRML/GRML. Looks like you did run grml2ram already?" ; eend 1
+   exit 1
+fi
+
+GRMLSIZE=$(du /cdrom/GRML/GRML | awk '{print $1}')
+RAM=$(/usr/bin/gawk '/MemFree/{print $2}' /proc/meminfo)
+
+case "$*" in -f|--force)
+  ewarn "Forcing copy process for grml-image (${GRMLSIZE}kB) as requested via force option." ; eend 0
+   ;;
+  *)
+   if test $RAM -lt $GRMLSIZE ; then
+      eerror "Sorry, not enough free RAM (${RAM}kB) available for grml-image (${GRMLSIZE}kB)." ; eend 1
+      exit 1
+   fi
+   ;;
+esac
+
+einfo "Copying /cdrom/GRML/GRML to RAM, this might take a while."
+rsync -a --progress /cdrom/GRML/GRML /tmp/GRML
+LANGUAGE=C LANG=C LC_ALL=C perl << EOF
+open LOOP, '</dev/loop0' or die $!;
+open DEST, '</tmp/GRML' or die $!;
+ioctl(LOOP, 0x4C06, fileno(DEST)) or die $!
+close LOOP;
+close DEST;
+EOF
+
+einfo "Unmounting /cdrom."
+umount /cdrom ; eend $?
+einfo "Now you can eject your grml-cd (e.g. run 'eject /dev/cdrom')." ; eend 0
+
+## END OF FILE #################################################################