#!/bin/bash initrd_mount() { # {{{ dev=${1} mntpoint=${2} /sbin/fsck -C -a ${dev} fsckrc=${?} if [ ${fsckrc} -eq 8 ] ; then return 1 fi if [ $(( ${fsckrc} & ~3 )) != 0 ] ; then echo " **" echo " ** Filesystem ${dev} || error=${?} failed (returncode=${fsckrc})." echo " ** Please repair the broken disk(s) manually." echo " **" exec /bin/bash elif [ $(( ${fsckrc} & 2 )) != 0 ] ; then echo " **" echo " ** fsck has requested the system to be rebooted." echo " ** Running a shell." echo " **" echo exec /bin/bash fi mount -n ${dev} ${mntpoint} return ${?}} # }}} PATH="/sbin:/usr/sbin:/bin/:/usr/bin" rootfs=""rootfsmounted=0 mount -n -t tmpfs tmpfs /tmpmount -n -t proc proc /procmount -n -t sysfs sysfs /sysmount -n -t ramfs ramfs /dev/sbin/udevstartcd /devrm -rf fdln -sf /proc/self/fdmkdir -p pts shmcd / while read dev mntpoint fstype options fsck1 fsck2 ; do [ "${mntpoint}" == "/" ] && rootfs=${dev} [ -n "${rootfs}" ] && breakdone < /etc/fstab echo "loading kernel modules". /etc/conf/kernel for x in /etc/conf/* ; do [ "${x}" == "/etc/conf/kernel" ] && continue echo "Running ${x} ..." . ${x}done if [ ${rootfsmounted} -eq 0 ] ; then echo "Mounting rootfs (${rootfs}) on /root" initrd_mount ${rootfs} /root rootfsmounted=1fi echo "starting init in /root"echo "parameters passed to init: ${@}"cd /rootmkdir -p /root/initrdmount -n --move /tmp /root/tmpmount -n --move /proc /root/procmount -n --move /sys /root/sysmount -n --move /dev /root/dev/sbin/pivot_root . initrdexec chroot . /sbin/init "${@}"
#!/bin/bash
initrd_mount() { # {{{
dev=${1}
mntpoint=${2}
/sbin/fsck -C -a ${dev}
fsckrc=${?}
if [ ${fsckrc} -eq 8 ] ; then
return 1
fi
if [ $(( ${fsckrc} & ~3 )) != 0 ] ; then
echo " **"
echo " ** Filesystem ${dev} || error=${?} failed (returncode=${fsckrc})."
echo " ** Please repair the broken disk(s) manually."
exec /bin/bash
elif [ $(( ${fsckrc} & 2 )) != 0 ] ; then
echo " ** fsck has requested the system to be rebooted."
echo " ** Running a shell."
echo
mount -n ${dev} ${mntpoint}
return ${?}
} # }}}
PATH="/sbin:/usr/sbin:/bin/:/usr/bin"
rootfs=""
rootfsmounted=0
mount -n -t tmpfs tmpfs /tmp
mount -n -t proc proc /proc
mount -n -t sysfs sysfs /sys
mount -n -t ramfs ramfs /dev
/sbin/udevstart
cd /dev
rm -rf fd
ln -sf /proc/self/fd
mkdir -p pts shm
cd /
while read dev mntpoint fstype options fsck1 fsck2 ; do
[ "${mntpoint}" == "/" ] && rootfs=${dev}
[ -n "${rootfs}" ] && break
done < /etc/fstab
echo "loading kernel modules"
. /etc/conf/kernel
for x in /etc/conf/* ; do
[ "${x}" == "/etc/conf/kernel" ] && continue
echo "Running ${x} ..."
. ${x}
done
if [ ${rootfsmounted} -eq 0 ] ; then
echo "Mounting rootfs (${rootfs}) on /root"
initrd_mount ${rootfs} /root
rootfsmounted=1
echo "starting init in /root"
echo "parameters passed to init: ${@}"
cd /root
mkdir -p /root/initrd
mount -n --move /tmp /root/tmp
mount -n --move /proc /root/proc
mount -n --move /sys /root/sys
mount -n --move /dev /root/dev
/sbin/pivot_root . initrd
exec chroot . /sbin/init "${@}"