3 INIT=/sbin/init.sysvinit
4 #OVERLAYS=/media/ram /media/cf /media/card
5 ROOTBACKUP=/media/realroot
7 PATH=/usr/bin:/usr/sbin:/bin:/sbin
9 if ! test -e ${INIT}; then
10 echo >&2 "ERROR: ${INIT} not found"
14 if test x"$*" != "x"; then
18 if ! which unionctl; then
26 if test "$1" = "-o"; then
30 elif test "$1" = "-t"; then
38 if test x"$2" = "x"; then
44 mountmatch="^[^ ]+ $mountpt $type"
45 # echo "NOTE: grep -E -q \"$mountmatch\" /proc/mounts"
46 if grep -E -q "$mountmatch" /proc/mounts; then
49 if test x"$type" != "x"; then
52 echo >&2 "NOTE: executing mount $type $opts $device $mountpt"
54 /bin/mount.busybox $type $opts $device $mountpt
56 if test "$ret" = "0"; then
57 wemounted="$wemounted $mountpt"
66 /bin/mount.busybox /proc
67 insmod /lib/modules/`uname -r`/kernel/fs/unionfs.o
68 nodupmount -t unionfs -o dirs=/.=rw,setattr=all none ${UNION}
69 # nodupmount -o bind / ${UNION}/${ROOTBACKUP}
70 # for OVERLAY in ${OVERLAYS}; do
71 # nodupmount ${OVERLAY}
72 # union-ctl /. --add --mode rw ${OVERLAY}
73 # nodupmount -o bind ${OVERLAY} ${UNION}/${OVERLAY}
75 /bin/umount.busybox /proc
76 # nodupmount -o bind /proc ${UNION}/proc
77 # nodupmount -o bind / ${ROOTBACKUP}
79 echo >&2 "ERROR: unable to setup mounts for chroot";
80 if test x"$wemounted" != "x"; then
82 for mount in $wemounted; do
83 /bin/umount.busybox $mount
89 pivot_root . ./${ROOTBACKUP}