blob: 4dfe53cf610c4208443c776e463a1329091f2050 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
#!/bin/sh
. /etc/default/rcS
FSTYPE=ext2
if test ! -e /proc/mtd
then
test "$VERBOSE" != "no" && echo >&2 "/proc not mounted, or mtd support not enabled in kernel."
exit
fi
RAM_MTD_NO=`cat /proc/mtd | grep mtdram | tail -n 1 | cut -d: -f1 | cut -dd -f2`
if test -z "$RAM_MTD_NO"; then exit 0; fi
if test -e /dev/mtdblock/0
then
RAM_MTD=/dev/mtd/$RAM_MTD_NO
RAM_MTDBLK=/dev/mtdblock/$RAM_MTD_NO
else
RAM_MTD=/dev/mtd$RAM_MTD_NO
RAM_MTDBLK=/dev/mtdblock$RAM_MTD_NO
fi
if grep -q $RAM_MTDBLK /etc/mtab; then echo "Device $RAM_MTDBLK already mounted"; exit 0; fi
if test ! -e $RAM_MTD; then echo >&2 "Mtdram device $RAM_MTD does not exist!"; exit 1; fi
RAM_MNTPT=/mnt/ram
RAM_MTD_SIZE_HEX=`cat /proc/mtd | grep mtdram | tail -n 1 | cut -d" " -f 2`
RAM_MTD_SIZE=`dc 0x$RAM_MTD_SIZE_HEX 1024 / p`
test -e /etc/ramdisk.conf && OLD_MTD_SIZE=`cat /etc/ramdisk.conf`
echo $RAM_MTD_SIZE > /etc/ramdisk.conf
if test ! -d "$RAM_MNTPT"; then echo >&2 "Mountpoint $RAM_MNTPT does not exist!"; exit 0; fi
if (test ! -e /etc/.configured) || test "$OLD_MTD_SIZE" != "$RAM_MTD_SIZE"; then
test "$VERBOSE" != "no" && echo -n "Wiping ramdisk: "
dd if=/dev/zero bs=1024 count=$RAM_MTD_SIZE of=$RAM_MTD 2>/dev/null >&2 || exit 1
test "$VERBOSE" != "no" && echo "$RAM_MTD";
test "$VERBOSE" != "no" && echo -n "Creating filesystem on ramdisk: "
mkfs.$FSTYPE $RAM_MTDBLK 2>/dev/null >&2 || exit 1
test "$VERBOSE" != "no" && echo "$RAM_MTDBLK";
fi
test "$VERBOSE" != "no" && echo -n "Mounting ramdisk: "
mount -t $FSTYPE $RAM_MTDBLK $RAM_MNTPT 2>/dev/null >&2 || exit 1
test "$VERBOSE" != "no" && echo "$RAM_MTDBLK";
exit 0
|