summaryrefslogtreecommitdiffstats
path: root/meta/packages/initscripts/initscripts-1.0/ramdisk
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/initscripts/initscripts-1.0/ramdisk')
-rwxr-xr-xmeta/packages/initscripts/initscripts-1.0/ramdisk46
1 files changed, 46 insertions, 0 deletions
diff --git a/meta/packages/initscripts/initscripts-1.0/ramdisk b/meta/packages/initscripts/initscripts-1.0/ramdisk
new file mode 100755
index 0000000000..03ac9bd05b
--- /dev/null
+++ b/meta/packages/initscripts/initscripts-1.0/ramdisk
@@ -0,0 +1,46 @@
1#!/bin/sh
2
3. /etc/default/rcS
4
5FSTYPE=ext2
6
7if test ! -e /proc/mtd
8then
9 test "$VERBOSE" != "no" && echo >&2 "/proc not mounted, or mtd support not enabled in kernel."
10 exit
11fi
12
13RAM_MTD_NO=`cat /proc/mtd | grep mtdram | tail -n 1 | cut -d: -f1 | cut -dd -f2`
14if test -z "$RAM_MTD_NO"; then exit 0; fi
15
16if test -e /dev/mtdblock/0
17then
18 RAM_MTD=/dev/mtd/$RAM_MTD_NO
19 RAM_MTDBLK=/dev/mtdblock/$RAM_MTD_NO
20else
21 RAM_MTD=/dev/mtd$RAM_MTD_NO
22 RAM_MTDBLK=/dev/mtdblock$RAM_MTD_NO
23fi
24
25RAM_MNTPT=/mnt/ram
26RAM_MTD_SIZE_HEX=`cat /proc/mtd | grep mtdram | tail -n 1 | cut -d" " -f 2`
27RAM_MTD_SIZE=`dc 0x$RAM_MTD_SIZE_HEX 1024 / p`
28test -e /etc/ramdisk.conf && OLD_MTD_SIZE=`cat /etc/ramdisk.conf`
29echo $RAM_MTD_SIZE > /etc/ramdisk.conf
30
31if test ! -d "$RAM_MNTPT"; then echo >&2 "Mountpoint $RAM_MNTPT does not exist!"; exit 0; fi
32
33if (test ! -e /etc/.configured) || test "$OLD_MTD_SIZE" != "$RAM_MTD_SIZE"; then
34 test "$VERBOSE" != "no" && echo -n "Wiping ramdisk: "
35 dd if=/dev/zero bs=1024 count=$RAM_MTD_SIZE of=$RAM_MTD 2>/dev/null >&2 || exit 1
36 test "$VERBOSE" != "no" && echo "$RAM_MTD";
37 test "$VERBOSE" != "no" && echo -n "Creating filesystem on ramdisk: "
38 mkfs.$FSTYPE $RAM_MTDBLK 2>/dev/null >&2 || exit 1
39 test "$VERBOSE" != "no" && echo "$RAM_MTDBLK";
40fi
41
42test "$VERBOSE" != "no" && echo -n "Mounting ramdisk: "
43mount -t $FSTYPE $RAM_MTDBLK $RAM_MNTPT 2>/dev/null >&2 || exit 1
44test "$VERBOSE" != "no" && echo "$RAM_MTDBLK";
45
46exit 0