[Fai-commit] r5695 - in trunk: . debian lib
Thomas Lange
lange at alioth.debian.org
Tue Jan 12 13:34:12 UTC 2010
Author: lange
Date: 2010-01-12 13:34:07 +0000 (Tue, 12 Jan 2010)
New Revision: 5695
Added:
trunk/lib/mkramdisk
Modified:
trunk/README
trunk/debian/changelog
Log:
lib/mkramdisk: new script that mounts a ramdisk onto a directory and
copies its contents to the ramdisk, can also umount the ramdisk and
put the modified contents back to the hard disks, this script is a
modified version of mkrw from FAI 3.1.8.
Modified: trunk/README
===================================================================
--- trunk/README 2010-01-11 06:09:03 UTC (rev 5694)
+++ trunk/README 2010-01-12 13:34:07 UTC (rev 5695)
@@ -53,4 +53,4 @@
1024D/AB9B66FD AEA6 A8C1 BD8E 67C4 8EF6 8BCA DC13 E54E AB9B 66FD
----------------------------------------------------------------------
-Copyright (c) 1999-2009 Thomas Lange. All rights reserved.
+Copyright (c) 1999-2010 Thomas Lange. All rights reserved.
Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog 2010-01-11 06:09:03 UTC (rev 5694)
+++ trunk/debian/changelog 2010-01-12 13:34:07 UTC (rev 5695)
@@ -1,5 +1,11 @@
fai (3.3.3) unstable; urgency=low
+ [ Thomas Lange ]
+ * lib/mkramdisk: new script that mounts a ramdisk onto a directory and
+ copies its contents to the ramdisk, can also umount the ramdisk and
+ put the modified contents back to the hard disks, this script is a
+ modified version of mkrw from FAI 3.1.8.
+
[ Michael Tautschnig ]
* setup-storage: Bumped version number to 1.2
* setup-storage: Encryption is now configured via a separate cryptsetup
@@ -15,7 +21,7 @@
* disk-info, setup-storage/Init.pm: Also accept Xen's xvd[a-t] as valid disk
name (thanks Rudy Gevaert for the patch). (closes: #561489)
- -- Thomas Lange <lange at debian.org> Tue, 01 Dec 2009 21:41:56 +0100
+ -- Thomas Lange <lange at debian.org> Tue, 12 Jan 2010 14:32:41 +0100
fai (3.3.2) unstable; urgency=low
Added: trunk/lib/mkramdisk
===================================================================
--- trunk/lib/mkramdisk (rev 0)
+++ trunk/lib/mkramdisk 2010-01-12 13:34:07 UTC (rev 5695)
@@ -0,0 +1,83 @@
+#! /bin/bash
+
+#*********************************************************************
+#
+# mkramdisk -- mount a ramdisk on top of a directory
+#
+# This script is part of FAI (Fully Automatic Installation)
+# (c) 2003-2010 by Thomas Lange, lange at informatik.uni-koeln.de
+# Universitaet zu Koeln
+#
+#*********************************************************************
+
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+mount_ramdisk() {
+
+ # save all dirs and files under directory $1
+ # mount tmpfs on top of dir $1
+ # extract dirs and files into tmpfs
+
+ local n=
+
+ if [ ! -d "$1" ]; then
+ echo "WARNING: $1 is not a directory. Cannot make it writeable."
+ return
+ fi
+
+ echo
+
+ set -e
+ local tmp1=$(mktemp) || exit 12
+ tar -C $1 -cf $tmp1 .
+ mount $2 $3 -t tmpfs tmpfs $1 || exit 13
+ echo "Ramdisk mounted onto $1"
+ tar -C $1 -xf $tmp1
+ rm -f $tmp1
+ set +e
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+umount_ramdisk() {
+
+ # put contents of ramdisk back to original location on harddisk
+
+ disk=$1
+ ram=${disk}-in-ramdisk
+
+ # test, if a ramdisk is mounted to this directory
+ mount | grep -q " $1 type tmpfs"
+ if [ $? -eq 1 ]; then
+ echo "$d is not a mounted ramdisk."
+ return
+ fi
+
+ set -e
+ mkdir $ram
+ mount --move $disk $ram # move current ramdisk to a new location
+ rm -rf $disk
+ cp -a $ram $disk # copy ramdisk contents to disk
+ umount $ram
+ echo "Ramdisk on $d umounted"
+ rmdir $ram
+ set +e
+}
+# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+size= # no default size
+umount=0
+
+while getopts ns:u opt ; do
+ case "$opt" in
+ u) umount=1 ;;
+ s) size="-o size=$OPTARG" ;;
+ n) mtab="-n" ;;
+ esac
+done
+shift $(($OPTIND - 1))
+
+for d in "$@"; do
+ if [ $umount -eq 1 ]; then
+ umount_ramdisk $d
+ else
+ [ -d "$d" ] && mount_ramdisk $d $size $mtab
+ fi
+done
Property changes on: trunk/lib/mkramdisk
___________________________________________________________________
Added: svn:executable
+ *
More information about the Fai-commit
mailing list