2006-08-30 07:32:35 +02:00
|
|
|
run_hook ()
|
|
|
|
{
|
|
|
|
if [ "x${ramdisk_size}" = "x" ]; then
|
|
|
|
ramdisk_size="75%"
|
|
|
|
fi
|
|
|
|
msg -n ":: Mounting tmpfs, size=${ramdisk_size}..."
|
|
|
|
mount -t tmpfs -o "size=${ramdisk_size}" tmpfs /tmpfs
|
|
|
|
msg "done."
|
|
|
|
|
2007-10-11 05:57:29 +02:00
|
|
|
if [ "x${BOOT_MOUNT}" = "x" ]; then
|
2006-09-28 06:36:34 +02:00
|
|
|
echo "ERROR: BOOT_MOUNT is not set. The boot-cd or boot-usb hook MUST"
|
|
|
|
echo " be run before this one. This image was improperly built"
|
2006-08-30 07:32:35 +02:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2007-10-06 03:52:03 +02:00
|
|
|
squashimg="${BOOT_MOUNT}/archlive.sqfs"
|
2007-10-06 03:09:53 +02:00
|
|
|
if [ "${copytoram}" = "y" ]; then
|
2007-10-06 03:52:03 +02:00
|
|
|
/bin/cat ${squashimg} > /tmpfs/archlive.sqfs
|
|
|
|
squashimg="/tmpfs/archlive.sqfs"
|
2007-10-06 03:09:53 +02:00
|
|
|
fi
|
2006-09-11 10:36:37 +02:00
|
|
|
|
2006-09-28 04:15:25 +02:00
|
|
|
msg ":: Mounting squashfs image"
|
2006-08-30 07:32:35 +02:00
|
|
|
/bin/modprobe -q squashfs >/dev/null 2>&1
|
2006-08-30 07:36:12 +02:00
|
|
|
/bin/mkdir -p /tmpfs/squashfs_root
|
2006-09-28 04:15:25 +02:00
|
|
|
if ! /bin/losetup /dev/loop0 "${squashimg}" >/dev/null 2>&1; then
|
2006-08-30 07:32:35 +02:00
|
|
|
echo "ERROR: Cannot mount loop device /dev/loop0...aborting"
|
|
|
|
exit 1
|
|
|
|
fi
|
2006-09-11 10:36:37 +02:00
|
|
|
|
2006-08-30 07:36:12 +02:00
|
|
|
/bin/mount -r -t squashfs /dev/loop0 /tmpfs/squashfs_root
|
2006-08-30 07:32:35 +02:00
|
|
|
|
2006-09-28 04:15:25 +02:00
|
|
|
msg ":: Mounting root (union) filesystem"
|
2006-08-30 07:32:35 +02:00
|
|
|
/bin/modprobe -q unionfs >/dev/null 2>&1
|
2007-10-16 12:10:36 +02:00
|
|
|
/bin/mount -t unionfs -o dirs=/tmpfs=rw none /real_root
|
2006-08-30 07:32:35 +02:00
|
|
|
|
2007-10-16 12:10:36 +02:00
|
|
|
# TODO: some of this could be broken into functions
|
|
|
|
LOOP_NUM="1"
|
|
|
|
addon_dir="${BOOT_MOUNT}/addons"
|
|
|
|
if [ -e "${addon_dir}/config" ]; then
|
2007-10-12 09:48:16 +02:00
|
|
|
msg ":: Mounting addons"
|
2007-10-16 12:10:36 +02:00
|
|
|
while read img mountpoint type; do
|
|
|
|
# check if this line is a comment (starts with #)
|
|
|
|
[ "${img#'#'}" != "${img}" ] && continue
|
|
|
|
|
|
|
|
if [ "${type}" = "bind" ]; then
|
|
|
|
msg " Binding ${img} to ${mountpoint}"
|
|
|
|
mkdir -p /real_root${mountpoint}
|
|
|
|
/bin/mount -o bind ${addon_dir}/$img /real_root${mountpoint}
|
|
|
|
elif [ "${type}" = "squashfs" ]; then
|
|
|
|
msg " Adding new union branch: ${img}"
|
|
|
|
mkdir -p "/tmpfs/mnt/loop${LOOP_NUM}"
|
|
|
|
if ! /bin/losetup "/dev/loop${LOOP_NUM}" ${addon_dir}/$img > /dev/null 2>&1; then
|
|
|
|
echo "ERROR: Cannot mount loop device /dev/loop${LOOP_NUM}"
|
|
|
|
echo " Couldn't mount all addons"
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
/bin/mount -r -t squashfs "/dev/loop${LOOP_NUM}" "/tmpfs/mnt/loop${LOOP_NUM}"
|
|
|
|
/bin/mount -t unionfs -o remount,add=:/tmpfs/mnt/loop${LOOP_NUM}=ro none "/real_root"
|
|
|
|
LOOP_NUM=$(( $LOOP_NUM + 1 ))
|
|
|
|
fi
|
|
|
|
done < ${addon_dir}/config
|
2007-10-12 09:48:16 +02:00
|
|
|
fi
|
|
|
|
|
2007-10-16 12:10:36 +02:00
|
|
|
/bin/mount -t unionfs -o remount,add=:/tmpfs/squashfs_root=ro none /real_root
|
|
|
|
|
2006-08-30 07:36:12 +02:00
|
|
|
if [ -d /proc/sys/dev/cdrom ]; then
|
2006-08-30 07:32:35 +02:00
|
|
|
echo 0 > /proc/sys/dev/cdrom/lock
|
|
|
|
echo 1 > /proc/sys/dev/cdrom/autoeject
|
|
|
|
fi
|
|
|
|
|
2007-10-11 05:42:50 +02:00
|
|
|
if [ "${break}" = "y" ]; then
|
|
|
|
echo ":: Break requested, type 'exit' to resume operation"
|
|
|
|
echo " NOTE: klibc contains no 'ls' binary, use 'echo *' instead"
|
|
|
|
PS1="ramfs$ " /bin/sh -i
|
|
|
|
fi
|
|
|
|
|
2006-08-30 07:32:35 +02:00
|
|
|
udevpid=$(/bin/minips -C udevd -o pid=)
|
2006-08-30 07:36:12 +02:00
|
|
|
[ "x${udevpid}" != "x" ] && /bin/kill -9 $udevpid 2>&1 >/dev/null
|
2006-08-30 07:32:35 +02:00
|
|
|
#Yep, we're bailing out here. We don't need kinit.
|
2006-08-30 07:36:12 +02:00
|
|
|
msg ":: Passing control to Archlinux Initscripts...Please Wait"
|
2006-09-11 10:36:37 +02:00
|
|
|
/bin/umount /sys
|
|
|
|
/bin/umount /proc
|
2006-08-30 07:32:35 +02:00
|
|
|
exec /bin/run-init -c /dev/console /real_root /sbin/init ${CMDLINE}
|
|
|
|
}
|
2007-10-11 03:12:47 +02:00
|
|
|
|
|
|
|
# vim:ft=sh:ts=4:sw=4:et:
|