|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
. /etc/initrd.defaults
|
|
|
|
. /etc/initrd.scripts
|
|
|
|
|
|
|
|
# Clean input/output
|
|
|
|
exec >${CONSOLE} <${CONSOLE} 2>&1
|
|
|
|
|
|
|
|
if [ "$$" != '1' ]
|
|
|
|
then
|
|
|
|
echo '/linuxrc has to be run as the init process as the one'
|
|
|
|
echo 'with a PID of 1. Try adding init="/linuxrc" to the'
|
|
|
|
echo 'kernel command line or running "exec /linuxrc".'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
mount -t proc -o noexec,nosuid,nodev proc /proc >/dev/null 2>&1
|
|
|
|
mount -o remount,rw / >/dev/null 2>&1
|
|
|
|
mount -t tmpfs -o rw,nosuid,nodev,relatime,mode=755 none /run 2>&1
|
|
|
|
mount -t tmpfs none /dev/shm 2>&1
|
|
|
|
|
|
|
|
/bin/busybox --install -s
|
|
|
|
|
|
|
|
if [ "$0" = '/init' ]
|
|
|
|
then
|
|
|
|
[ -e /linuxrc ] && rm /linuxrc
|
|
|
|
fi
|
|
|
|
|
|
|
|
CMDLINE=$(cat /proc/cmdline)
|
|
|
|
FAKE_ROOT=''
|
|
|
|
FAKE_INIT=''
|
|
|
|
FAKE_ROOTFLAGS=''
|
|
|
|
INIT_OPTS=''
|
|
|
|
ROOTFSTYPE='auto'
|
|
|
|
CRYPT_SILENT=0
|
|
|
|
QUIET=''
|
|
|
|
|
|
|
|
mkdir -p /etc/cmdline /etc/modprobe.d
|
|
|
|
for x in ${CMDLINE}
|
|
|
|
do
|
|
|
|
case "${x}" in
|
|
|
|
real_root=*)
|
|
|
|
REAL_ROOT=${x#*=}
|
|
|
|
;;
|
|
|
|
root=*)
|
|
|
|
FAKE_ROOT=${x#*=}
|
|
|
|
;;
|
|
|
|
subdir=*)
|
|
|
|
SUBDIR=${x#*=}
|
|
|
|
;;
|
|
|
|
real_init=*)
|
|
|
|
REAL_INIT=${x#*=}
|
|
|
|
;;
|
|
|
|
init=*)
|
|
|
|
FAKE_INIT=${x#*=}
|
|
|
|
;;
|
|
|
|
init_opts=*)
|
|
|
|
INIT_OPTS=${x#*=}
|
|
|
|
;;
|
|
|
|
cdroot)
|
|
|
|
CDROOT=1
|
|
|
|
;;
|
|
|
|
cdroot=*)
|
|
|
|
CDROOT=1
|
|
|
|
CDROOT_DEV=${x#*=}
|
|
|
|
;;
|
|
|
|
cdroot_type=*)
|
|
|
|
CDROOT_TYPE=${x#*=}
|
|
|
|
;;
|
|
|
|
cdroot_marker=*)
|
|
|
|
CDROOT_MARKER=${x#*=}
|
|
|
|
;;
|
|
|
|
loop=*)
|
|
|
|
LOOP=${x#*=}
|
|
|
|
;;
|
|
|
|
looptype=*)
|
|
|
|
LOOPTYPE=${x#*=}
|
|
|
|
;;
|
|
|
|
isoboot=*)
|
|
|
|
ISOBOOT=${x#*=}
|
|
|
|
;;
|
|
|
|
domdev)
|
|
|
|
USE_MDEV=1
|
|
|
|
;;
|
|
|
|
dolvm)
|
|
|
|
USE_LVM_NORMAL=1
|
|
|
|
;;
|
|
|
|
domdadm)
|
|
|
|
USE_MDADM=1
|
|
|
|
;;
|
|
|
|
dodmraid)
|
|
|
|
USE_DMRAID_NORMAL=1
|
|
|
|
;;
|
|
|
|
dodmraid=*)
|
|
|
|
DMRAID_OPTS=${x#*=}
|
|
|
|
USE_DMRAID_NORMAL=1
|
|
|
|
;;
|
|
|
|
domultipath)
|
|
|
|
good_msg "Booting with multipath activated."
|
|
|
|
USE_MULTIPATH_NORMAL=1
|
|
|
|
;;
|
|
|
|
dozfs*)
|
|
|
|
USE_ZFS=1
|
|
|
|
|
|
|
|
if [ "${x#*=}" = 'force' ]
|
|
|
|
then
|
|
|
|
ZPOOL_FORCE=-f
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
quiet)
|
|
|
|
QUIET=1
|
|
|
|
;;
|
|
|
|
debug)
|
|
|
|
DEBUG='yes'
|
|
|
|
;;
|
|
|
|
scandelay=*)
|
|
|
|
SDELAY=${x#*=}
|
|
|
|
;;
|
|
|
|
scandelay)
|
|
|
|
SDELAY=3
|
|
|
|
;;
|
|
|
|
doload=*)
|
|
|
|
MDOLIST=${x#*=}
|
|
|
|
MDOLIST=$(echo ${MDOLIST} | sed -e 's/,/ /g')
|
|
|
|
;;
|
|
|
|
nodetect)
|
|
|
|
NODETECT=1
|
|
|
|
;;
|
|
|
|
noload=*)
|
|
|
|
MLIST=${x#*=}
|
|
|
|
MLIST="$(echo ${MLIST} | sed -e 's/,/ /g')"
|
|
|
|
export MLIST
|
|
|
|
;;
|
|
|
|
CONSOLE=*|console=*)
|
|
|
|
CONSOLE=${x#*=}
|
|
|
|
CONSOLE=$(basename ${CONSOLE})
|
|
|
|
;;
|
|
|
|
splash)
|
|
|
|
PLYMOUTH=1
|
|
|
|
;;
|
|
|
|
splash=*)
|
|
|
|
FBSPLASH=1
|
|
|
|
;;
|
|
|
|
lvmraid=*)
|
|
|
|
RAID_DEVICES="${x#*=}"
|
|
|
|
RAID_DEVICES="$(echo ${RAID_DEVICES} | sed -e 's/,/ /g')"
|
|
|
|
USE_LVM_NORMAL=1
|
|
|
|
;;
|
|
|
|
part=*)
|
|
|
|
MDPART=${x#*=}
|
|
|
|
;;
|
|
|
|
part|partitionable)
|
|
|
|
MDPART=1
|
|
|
|
;;
|
|
|
|
ip=*)
|
|
|
|
IP=${x#*=}
|
|
|
|
;;
|
|
|
|
nfsroot=*)
|
|
|
|
NFSROOT=${x#*=}
|
|
|
|
;;
|
|
|
|
|
|
|
|
iscsi_initiatorname=*)
|
|
|
|
ISCSI_INITIATORNAME=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_target=*)
|
|
|
|
ISCSI_TARGET=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_tgpt=*)
|
|
|
|
ISCSI_TGPT=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_address=*)
|
|
|
|
ISCSI_ADDRESS=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_port=*)
|
|
|
|
ISCSI_PORT=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_username=*)
|
|
|
|
ISCSI_USERNAME=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_password=*)
|
|
|
|
ISCSI_PASSWORD=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_username_in=*)
|
|
|
|
ISCSI_USERNAME_IN=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_password_in=*)
|
|
|
|
ISCSI_PASSWORD_IN=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_debug=*)
|
|
|
|
ISCSI_DEBUG=${x#*=}
|
|
|
|
;;
|
|
|
|
iscsi_noibft)
|
|
|
|
ISCSI_NOIBFT=1
|
|
|
|
;;
|
|
|
|
|
|
|
|
crypt_root=*)
|
|
|
|
CRYPT_ROOT=${x#*=}
|
|
|
|
;;
|
|
|
|
crypt_swap=*)
|
|
|
|
CRYPT_SWAP=${x#*=}
|
|
|
|
;;
|
|
|
|
root_key=*)
|
|
|
|
CRYPT_ROOT_KEY=${x#*=}
|
|
|
|
;;
|
|
|
|
root_keydev=*)
|
|
|
|
CRYPT_ROOT_KEYDEV=${x#*=}
|
|
|
|
;;
|
|
|
|
root_trim=*)
|
|
|
|
CRYPT_ROOT_TRIM=${x#*=}
|
|
|
|
;;
|
|
|
|
|
|
|
|
swap_key=*)
|
|
|
|
CRYPT_SWAP_KEY=${x#*=}
|
|
|
|
;;
|
|
|
|
swap_keydev=*)
|
|
|
|
CRYPT_SWAP_KEYDEV=${x#*=}
|
|
|
|
;;
|
|
|
|
real_resume=*|resume=*)
|
|
|
|
REAL_RESUME=${x#*=}
|
|
|
|
;;
|
|
|
|
noresume)
|
|
|
|
NORESUME=1
|
|
|
|
;;
|
|
|
|
crypt_silent)
|
|
|
|
CRYPT_SILENT=1
|
|
|
|
;;
|
|
|
|
real_rootflags=*)
|
|
|
|
REAL_ROOTFLAGS=${x#*=}
|
|
|
|
;;
|
|
|
|
rootflags=*)
|
|
|
|
FAKE_ROOTFLAGS=${x#*=}
|
|
|
|
;;
|
|
|
|
rootfstype=*)
|
|
|
|
ROOTFSTYPE=${x#*=}
|
|
|
|
;;
|
|
|
|
keymap=*)
|
|
|
|
keymap=${x#*=}
|
|
|
|
;;
|
|
|
|
aufs)
|
|
|
|
USE_AUFS_NORMAL=1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
|
|
|
|
quiet_kmsg
|
|
|
|
|
|
|
|
setup_real_root
|
|
|
|
|
|
|
|
zfs_init
|
|
|
|
|
|
|
|
cmdline_hwopts
|
|
|
|
|
|
|
|
mount_devfs
|
|
|
|
|
|
|
|
mount_sysfs
|
|
|
|
|
|
|
|
devmgr_init
|
|
|
|
|
|
|
|
splash_init
|
|
|
|
|
|
|
|
modules_init
|
|
|
|
|
|
|
|
# Apply scan delay if specified
|
|
|
|
sdelay
|
|
|
|
|
|
|
|
# If we're mdev, we better wait for all the modules to be loaded.
|
|
|
|
is_mdev && splashcmd init
|
|
|
|
|
|
|
|
cd /
|
|
|
|
|
|
|
|
start_iscsi
|
|
|
|
|
|
|
|
# Setup btrfs, see bug 303529
|
|
|
|
setup_btrfsctl
|
|
|
|
|
|
|
|
# Setup md device nodes if they dont exist
|
|
|
|
is_mdev && setup_md_device
|
|
|
|
|
|
|
|
start_volumes
|
|
|
|
|
|
|
|
setup_keymap
|
|
|
|
|
|
|
|
# Initialize LUKS root device except for livecd's
|
|
|
|
is_livecd || start_luks
|
|
|
|
|
|
|
|
# Initialize resume from hibernation
|
|
|
|
is_livecd || resume_init
|
|
|
|
|
|
|
|
mkdir -p "${NEW_ROOT}"
|
|
|
|
CHROOT="${NEW_ROOT}"
|
|
|
|
|
|
|
|
# Run debug shell if requested
|
|
|
|
rundebugshell "before setting up the root filesystem"
|
|
|
|
|
|
|
|
# Setup Live system mounts
|
|
|
|
is_livecd && livecd_init
|
|
|
|
|
|
|
|
# Determine root device
|
|
|
|
rootdev_init
|
|
|
|
|
|
|
|
# If CD root is set determine the looptype to boot
|
|
|
|
if is_livecd
|
|
|
|
then
|
|
|
|
good_msg 'Determining looptype ...'
|
|
|
|
cd "${NEW_ROOT}"
|
|
|
|
|
|
|
|
# Find loop and looptype
|
|
|
|
[ -z "${LOOP}" ] && find_loop
|
|
|
|
[ -z "${LOOPTYPE}" ] && find_looptype
|
|
|
|
|
|
|
|
cache_cd_contents
|
|
|
|
|
|
|
|
# If encrypted, find key and mount, otherwise mount as usual
|
|
|
|
if [ -n "${CRYPT_ROOT}" ]
|
|
|
|
then
|
|
|
|
CRYPT_ROOT_KEY="$(head -n 1 "${CDROOT_PATH}"/${CDROOT_MARKER})"
|
|
|
|
CRYPT_ROOT='/dev/loop0'
|
|
|
|
good_msg 'You booted an encrypted livecd' "${CRYPT_SILENT}"
|
|
|
|
|
|
|
|
losetup /dev/loop0 "${CDROOT_PATH}/${LOOPEXT}${LOOP}"
|
|
|
|
test_success 'Preparing loop filesystem'
|
|
|
|
|
|
|
|
start_luks
|
|
|
|
|
|
|
|
case ${LOOPTYPE} in
|
|
|
|
normal)
|
|
|
|
MOUNTTYPE="ext2"
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
MOUNTTYPE="${LOOPTYPE}"
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
mount -t "${MOUNTTYPE}" -o ro /dev/mapper/root "${NEW_ROOT}/mnt/livecd"
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
# Setup the loopback mounts, if unencrypted
|
|
|
|
else
|
|
|
|
if [ "${LOOPTYPE}" = 'normal' ]
|
|
|
|
then
|
|
|
|
good_msg 'Mounting loop filesystem'
|
|
|
|
mount -t ext2 -o loop,ro "${CDROOT_PATH}/${LOOPEXT}${LOOP}" "${NEW_ROOT}/mnt/livecd"
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
elif [ "${LOOPTYPE}" = 'squashfs' ]
|
|
|
|
then
|
|
|
|
if [ "${USE_AUFS_NORMAL}" != '1' ]; then
|
|
|
|
good_msg 'Mounting squashfs filesystem'
|
|
|
|
_CACHED_SQUASHFS_PATH="${NEW_ROOT}/mnt/${LOOP}"
|
|
|
|
_squashfs_path="${CDROOT_PATH}/${LOOPEXT}${LOOP}" # Default to uncached
|
|
|
|
# Upgrade to cached version if possible
|
|
|
|
[ "${DO_cache}" -a -f "${_CACHED_SQUASHFS_PATH}" ] \
|
|
|
|
&& _squashfs_path=${_CACHED_SQUASHFS_PATH}
|
|
|
|
mount -t squashfs -o loop,ro "${_squashfs_path}" "${NEW_ROOT}/mnt/livecd" || {
|
|
|
|
bad_msg "Squashfs filesystem could not be mounted, dropping into shell."
|
|
|
|
if [ -e /proc/filesystems ]; then
|
|
|
|
fgrep -q squashfs /proc/filesystems || \
|
|
|
|
bad_msg "HINT: Your kernel does not know filesystem \"squashfs\"."
|
|
|
|
fi
|
|
|
|
do_rundebugshell
|
|
|
|
}
|
|
|
|
else
|
|
|
|
good_msg 'Mounting squashfs & aufs filesystems'
|
|
|
|
setup_squashfs_aufs
|
|
|
|
test_success 'Mount filesystem'
|
|
|
|
fi
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
elif [ "${LOOPTYPE}" = 'gcloop' ]
|
|
|
|
then
|
|
|
|
good_msg 'Mounting gcloop filesystem'
|
|
|
|
echo ' ' | losetup -E 19 -e ucl-0 -p0 "${NEW_ROOT}/dev/loop0" "${CDROOT_PATH}/${LOOPEXT}${LOOP}"
|
|
|
|
test_success 'losetup the loop device'
|
|
|
|
|
|
|
|
mount -t ext2 -o ro "${NEW_ROOT}/dev/loop0" "${NEW_ROOT}/mnt/livecd"
|
|
|
|
test_success 'Mount the losetup loop device'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
elif [ "${LOOPTYPE}" = 'zisofs' ]
|
|
|
|
then
|
|
|
|
FS_LOCATION="${CDROOT_PATH/\/}/${LOOPEXT}${LOOP}"
|
|
|
|
elif [ "${LOOPTYPE}" = 'noloop' ]
|
|
|
|
then
|
|
|
|
FS_LOCATION="${CDROOT_PATH/\/}"
|
|
|
|
elif [ "${LOOPTYPE}" = 'sgimips' ]
|
|
|
|
then
|
|
|
|
# getdvhoff finds the starting offset (in bytes) of the squashfs
|
|
|
|
# partition on the cdrom and returns this offset for losetup
|
|
|
|
#
|
|
|
|
# All currently supported SGI Systems use SCSI CD-ROMs, so
|
|
|
|
# so we know that the CD-ROM is usually going to be /dev/sr0.
|
|
|
|
#
|
|
|
|
# We use the value given to losetup to set /dev/loop0 to point
|
|
|
|
# to the liveCD root partition, and then mount /dev/loop0 as
|
|
|
|
# the LiveCD rootfs
|
|
|
|
good_msg 'Locating the SGI LiveCD Root Partition'
|
|
|
|
echo ' ' | \
|
|
|
|
losetup -o $(getdvhoff "${NEW_ROOT}${REAL_ROOT}" 0) \
|
|
|
|
"${NEW_ROOT}${CDROOT_DEV}" \
|
|
|
|
"${NEW_ROOT}${REAL_ROOT}"
|
|
|
|
test_success 'losetup /dev/sr0 /dev/loop0'
|
|
|
|
|
|
|
|
good_msg 'Mounting the Root Partition'
|
|
|
|
mount -t squashfs -o ro "${NEW_ROOT}${CDROOT_DEV}" "${NEW_ROOT}/mnt/livecd"
|
|
|
|
test_success 'mount /dev/loop0 /'
|
|
|
|
FS_LOCATION='mnt/livecd'
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Unpacking additional packages from NFS mount
|
|
|
|
# This is useful for adding kernel modules to /lib
|
|
|
|
# We do this now, so that additional packages can add whereever
|
|
|
|
# they want.
|
|
|
|
if is_nfs
|
|
|
|
then
|
|
|
|
if [ -e "${CDROOT_PATH}/add" ]
|
|
|
|
then
|
|
|
|
for targz in $(ls ${CDROOT_PATH}/add/*.tar.gz)
|
|
|
|
do
|
|
|
|
tarname=$(basename ${targz})
|
|
|
|
good_msg "Adding additional package ${tarname}"
|
|
|
|
(cd ${NEW_ROOT} ; /bin/tar -xzf ${targz})
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
if [ "${USE_AUFS_NORMAL}" != '1' ]; then
|
|
|
|
|
|
|
|
good_msg "Copying read-write image contents to tmpfs"
|
|
|
|
# Copy over stuff that should be writable
|
|
|
|
(cd "${NEW_ROOT}/${FS_LOCATION}"; cp -a ${ROOT_TREES} "${NEW_ROOT}") || {
|
|
|
|
bad_msg "Copying failed, dropping into a shell."
|
|
|
|
do_rundebugshell
|
|
|
|
}
|
|
|
|
|
|
|
|
# Now we do the links.
|
|
|
|
for x in ${ROOT_LINKS}
|
|
|
|
do
|
|
|
|
if [ -L "${NEW_ROOT}/${FS_LOCATION}/${x}" ]
|
|
|
|
then
|
|
|
|
ln -s "$(readlink ${NEW_ROOT}/${FS_LOCATION}/${x})" "${x}" 2>/dev/null
|
|
|
|
else
|
|
|
|
# List all subdirectories of x
|
|
|
|
find "${NEW_ROOT}/${FS_LOCATION}/${x}" -type d 2>/dev/null | while read directory
|
|
|
|
do
|
|
|
|
# Strip the prefix of the FS_LOCATION
|
|
|
|
directory="${directory#${NEW_ROOT}/${FS_LOCATION}/}"
|
|
|
|
|
|
|
|
# Skip this directory if we already linked a parent directory
|
|
|
|
if [ "${current_parent}" != '' ]; then
|
|
|
|
var=$(echo "${directory}" | grep "^${current_parent}")
|
|
|
|
if [ "${var}" != '' ]; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
# Test if the directory exists already
|
|
|
|
if [ -e "/${NEW_ROOT}/${directory}" ]
|
|
|
|
then
|
|
|
|
# It does exist, link all the individual files
|
|
|
|
for file in $(ls /${NEW_ROOT}/${FS_LOCATION}/${directory})
|
|
|
|
do
|
|
|
|
if [ ! -d "/${NEW_ROOT}/${FS_LOCATION}/${directory}/${file}" ] && [ ! -e "${NEW_ROOT}/${directory}/${file}" ]; then
|
|
|
|
ln -s "/${FS_LOCATION}/${directory}/${file}" "${directory}/${file}" 2> /dev/null
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
else
|
|
|
|
# It does not exist, make a link to the livecd
|
|
|
|
ln -s "/${FS_LOCATION}/${directory}" "${directory}" 2>/dev/null
|
|
|
|
current_parent="${directory}"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
mkdir initramfs proc tmp sys run 2>/dev/null
|
|
|
|
chmod 1777 tmp
|
|
|
|
|
|
|
|
# have handy /mnt/cdrom (CDROOT_PATH) as well
|
|
|
|
_new_cdroot="${NEW_ROOT}${CDROOT_PATH}"
|
|
|
|
[ ! -d "${_new_cdroot}" ] && mkdir -p "${_new_cdroot}"
|
|
|
|
mount --bind "${CDROOT_PATH}" "${_new_cdroot}"
|
|
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Let Init scripts know that we booted from CD
|
|
|
|
export CDBOOT
|
|
|
|
CDBOOT=1
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Re-run this here, which makes sure that it at least had a chance
|
|
|
|
# to be called.
|
|
|
|
ensure_initramfs_mounts
|
|
|
|
|
|
|
|
splashcmd hasroot "${NEW_ROOT}"
|
|
|
|
|
|
|
|
# Execute script on the cdrom just before boot to update things if necessary
|
|
|
|
cdupdate
|
|
|
|
|
|
|
|
if [ "${SUBDIR}" != '' -a -e "${CHROOT}/${SUBDIR}" ]
|
|
|
|
then
|
|
|
|
good_msg "Entering ${SUBDIR} to boot"
|
|
|
|
CHROOT="${CHROOT}/${SUBDIR}"
|
|
|
|
fi
|
|
|
|
|
|
|
|
verbose_kmsg
|
|
|
|
|
|
|
|
good_msg "Booting (initramfs)"
|
|
|
|
|
|
|
|
cd "${CHROOT}"
|
|
|
|
mkdir "${CHROOT}/proc" "${CHROOT}/sys" "${CHROOT}/run" 2>/dev/null
|
|
|
|
|
|
|
|
is_udev && udevadm settle
|
|
|
|
|
|
|
|
if is_udev
|
|
|
|
then
|
|
|
|
udevadm control --exit || bad_msg "Unable to terminate udevd"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# If devtmpfs is mounted, try move it to the new root
|
|
|
|
# If that fails, try to unmount all possible mounts of devtmpfs as stuff breaks otherwise
|
|
|
|
for fs in /run /dev /sys /proc
|
|
|
|
do
|
|
|
|
if grep -qs "$fs" /proc/mounts
|
|
|
|
then
|
|
|
|
if ! mount --move $fs "${CHROOT}"$fs
|
|
|
|
then
|
|
|
|
umount $fs || \
|
|
|
|
bad_msg "Failed to move and unmount the ramdisk $fs!"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ ! -e "${CHROOT}/dev/console" ] || [ ! -e "${CHROOT}/dev/null" ]
|
|
|
|
then
|
|
|
|
bad_msg "ERROR: your real /dev is missing console and null"
|
|
|
|
elif [ -e /etc/initrd.splash -a ! -e "${CHROOT}/dev/tty1" ]
|
|
|
|
then
|
|
|
|
bad_msg "ERROR: your real /dev is missing tty1, required for splash"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Run debug shell if requested
|
|
|
|
rundebugshell "before entering switch_root"
|
|
|
|
|
|
|
|
exec /sbin/switch_root -c "/dev/console" "${CHROOT}" "${REAL_INIT:-/sbin/init}" "${INIT_OPTS}"
|
|
|
|
|
|
|
|
# If we get here, something bad has happened
|
|
|
|
splashcmd verbose
|
|
|
|
|
|
|
|
bad_msg "A fatal error has occured since ${REAL_INIT:-/sbin/init} did not"
|
|
|
|
bad_msg "boot correctly. Trying to open a shell..."
|
|
|
|
|
|
|
|
exec /bin/bash
|
|
|
|
exec /bin/sh
|
|
|
|
exec /bin/ash
|
|
|
|
exec /bin/dash
|
|
|
|
exec sh
|