Hey everybody,

I just want to share my expirences with initramfs and aufs.
Again I have to say that the kind manner in this list 
is something I really like.

my initramfs structur looks like this:

./
|-- aufs
|-- bin
|   |-- busybox
|   |-- cat -> busybox
|   |-- cut -> busybox
|   |-- echo -> busybox
|   |-- findfs -> busybox
|   |-- grep -> busybox
|   |-- ls -> busybox
|   |-- mdev -> busybox
|   |-- mkdir -> busybox
|   |-- mount -> busybox
|   |-- msh -> busybox
|   |-- sh -> busybox
|   |-- switch_root -> busybox
|   |-- test -> busybox
|   `-- umount -> busybox
|-- dev
|   `-- console
|-- flashroot
|-- init
|-- newroot
|-- proc
`-- sys


stuffed in a initramfs_data.cpio.gz its about 334K.


The init script can be found below.

--
flip



cat init
#!/bin/sh
#
# simple phase 1 init script
#
# by: Philipp Wehrheim          20071023
#
# This file is released under the GPLv2.
#
export PATH="/bin"
#
# OVERLAYLABEL is the filesystem lable
# of the overlay partition
OVERLAYLABEL="Overlay"
#
# mount
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t tmpfs tmpfs /dev
#
# mdev create devices
mdev -s

#
# find mtd Ramdisk
MTDRAMDISK=`cat /proc/mtd | grep Ramdisk | cut -d':' -f1`

#
# find the overlay partition 
#
# WARNING: What happens if more than one Devices with the label is fond?
echo "searching for filesystem $OVERLAYLABEL"
PARTITION=`findfs LABEL=$OVERLAYLABEL 2>/dev/null`

echo "PARTITION: $PARTITION"

# if findfs found a partition try to mount it
if test $? -eq 0 ; then
        echo "mounting /aufs partition"
        mount $PARTITION /aufs >/dev/null 2>&1
fi

# if the mount did not succeed
if test $? -ne 0 ; then
        echo "mounting /aufs with tmpfs"
        mount -t tmpfs tmpfs -o size=10m /aufs >/dev/null 2>&1
fi

# extract squash image from flash
cat /dev/$MTDRAMDISK > /squash.img

# mount the squash.img
mount -n -t squashfs -o loop /squash.img /flashroot

# mount aufs and squash.img to newroot
mount -n -t aufs -o br=/aufs:/flashroot none /newroot

# create mountpoints for mount move
mkdir /newroot/system/aufs
mkdir /newroot/system/flashroot

# move the mountpoints
# into the new root
mount --move /aufs /newroot/system/aufs
mount --move /flashroot /newroot/system/flashroot

# clean up
umount -l /proc /sys /dev 

# switch root
exec switch_root /newroot /sbin/init




-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/

Reply via email to