[BusyBox] OT: Using CRAMFS and DEVFS on BB system?
Erik Andersen
andersen at lineo.com
Mon Apr 30 17:33:04 UTC 2001
On Mon Apr 30, 2001 at 07:00:07PM -0400, Tom Cameron wrote:
> Hello all,
> I have a problem. Essentially, I want a read-write filesystem
> on my BB system, but I use cramfs for my bootimage. Now, my question
> is: How would I go about mounting a, lets say ramdrive, formatting it,
> and getting my BB system copied to it...and after all that, mounting the
> new ramdrive as / ? Keep in mind that I'm using DEVFS, which is making
> things a bit difficult for me (as I can't even mount the root now
> because the devices haven't been created). Anyone with any ideas would
> be a GREAT help...or anyone with a better way even. Thanks in
> advance!!!
I personally would leave the root fs read-only, but mount ramdisks
over the top of places you need to write to -- like /tmp. Then make
other places that need to be written to symlinks to dirs under /tmp.
But anyways, here is a rough implementation of what you asked for:
1) The kernel mounts root fs (cramfs)
2) The kernel starts /sbin/init (busybox)
3) busybox init reads a line like "::sysinit:/etc/init.d/rcS" from /etc/inittab
4) /etc/init.d/rcS runs ash and looks something like:
#!/bin/sh
# disable modprobe calls
if [ -f "/proc/sys/kernel/modprobe" ] ; then
echo "/bin/true" >/proc/sys/kernel/modprobe
fi
# Start all init scripts in /etc/init.d
# executing them in numerical order.
#
for i in /etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue
case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
5) Then you would have a S01mount script to do things like
#!/bin/sh
mount -t devfs devfs /dev
# I have no idea if devfs subsumes devpts or not.
# Assuming not...
mkdir -p /dev/pts
mount devpts /dev/pts -t devpts -o rw,gid=5,mode=620
6) Then you need to create a ramdisk to work in and pivot_root to it.
#!/bin/sh
SIZE=8192
INODES=850
# Build ramdisks to overlay the underlying filesystem
echo -n "Building device ramdisk: "
dd if=/dev/zero of=/dev/ram1 bs=1k count=$SIZE > /dev/null 2>&1
mkfs.minix -n30 -i $INODES /dev/ram1 $SIZE > /dev/null 2>&1
mount /dev/ram1 /mnt -t minix -o rw > /dev/null 2>&1
if [ ! $? -eq 0 ] ; then
echo "failed."
fi;
cp -a /usr /bin /sbin /lib <whatever> /mnt > /dev/null 2>&1
if [ ! $? -eq 0 ] ; then
echo "failed."
fi;
pivot_root /mnt /opt
-Erik
--
Erik B. Andersen email: andersen at lineo.com
--This message was written using 73% post-consumer electrons--
More information about the busybox
mailing list