From 86967ea40035bc89392e5adc2bba72e65bbc30be Mon Sep 17 00:00:00 2001 From: Fabio Erculiani Date: Mon, 5 Aug 2013 23:10:25 +0200 Subject: [PATCH] linuxrc: move livecd initialization code to livecd_init() --- defaults/initrd.scripts | 57 ++++++++++++++++++++++++++++++++++++++ defaults/linuxrc | 61 ++--------------------------------------- 2 files changed, 59 insertions(+), 59 deletions(-) diff --git a/defaults/initrd.scripts b/defaults/initrd.scripts index 0c0ab32..b737e1b 100644 --- a/defaults/initrd.scripts +++ b/defaults/initrd.scripts @@ -1550,6 +1550,63 @@ setup_squashfs_aufs() { mount --bind "${CDROOT_PATH}" "${new_cdroot}" } +livecd_init() { + good_msg "Making tmpfs for ${NEW_ROOT}" + mount -n -t tmpfs tmpfs "${NEW_ROOT}" + + local dirs= + + dirs="dev mnt proc run sys tmp mnt/livecd" + dirs="${dirs} mnt/key tmp/.initrd mnt/gentoo" + for i in ${dirs}; do + mkdir -p "${NEW_ROOT}/${i}" + chmod 755 "${NEW_ROOT}/${i}" + done + [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}" + [ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3 + [ ! -e "${NEW_ROOT}/dev/console" ] && \ + mknod "${NEW_ROOT}"/dev/console c 5 1 + + # For SGI LiveCDs ... + if [ "${LOOPTYPE}" = "sgimips" ]; then + [ ! -e "${NEW_ROOT}/dev/sr0" ] && \ + mknod "${NEW_ROOT}/dev/sr0" b 11 0 + [ ! -e "${NEW_ROOT}/dev/loop0" ] && \ + mknod "${NEW_ROOT}/dev/loop0" b 7 0 + fi + + # Required for splash to work. Not an issue with the initrd as this + # device isn't created there and is not needed. + if [ -e /dev/tty1 ]; then + [ ! -e "${NEW_ROOT}/dev/tty1" ] && \ + mknod "${NEW_ROOT}/dev/tty1" c 4 1 + fi + + if [ "${REAL_ROOT}" != "/dev/nfs" ] && \ + [ "${LOOPTYPE}" != "sgimips" ]; then + bootstrap_cd + fi + + if [ "${REAL_ROOT}" = '' ] + then + warn_msg "No bootable medium found. Waiting for new devices..." + COUNTER=0 + while [ ${COUNTER} -lt 3 ]; do + sleep 3 + let COUNTER=${COUNTER}+1 + done + sleep 1 + bootstrap_cd + fi + + if [ "${REAL_ROOT}" = '' ] + then + # leave stale mounts around, make possible to debug + bad_msg 'Could not find CD to boot, something else needed!' + CDROOT=0 + fi +} + get_mounts_list() { awk ' /^[[:blank:]]*#/ { next } diff --git a/defaults/linuxrc b/defaults/linuxrc index 9967ffa..1e717dc 100644 --- a/defaults/linuxrc +++ b/defaults/linuxrc @@ -292,65 +292,8 @@ CHROOT="${NEW_ROOT}" # Run debug shell if requested rundebugshell "before setting up the root filesystem" -if is_livecd -then - good_msg "Making tmpfs for ${NEW_ROOT}" - mount -n -t tmpfs tmpfs "${NEW_ROOT}" - - for i in dev mnt proc run sys tmp mnt/livecd mnt/key tmp/.initrd mnt/gentoo - do - mkdir -p "${NEW_ROOT}/${i}" - chmod 755 "${NEW_ROOT}/${i}" - done - [ ! -d "${CDROOT_PATH}" ] && mkdir -p "${CDROOT_PATH}" - [ ! -e "${NEW_ROOT}/dev/null" ] && mknod "${NEW_ROOT}"/dev/null c 1 3 - [ ! -e "${NEW_ROOT}/dev/console" ] && mknod "${NEW_ROOT}"/dev/console c 5 1 - - # For SGI LiveCDs ... - if [ "${LOOPTYPE}" = "sgimips" ] - then - [ ! -e "${NEW_ROOT}/dev/sr0" ] && mknod "${NEW_ROOT}/dev/sr0" b 11 0 - [ ! -e "${NEW_ROOT}/dev/loop0" ] && mknod "${NEW_ROOT}/dev/loop0" b 7 0 - fi - - # Required for splash to work. Not an issue with the initrd as this - # device isn't created there and is not needed. - if [ -e /dev/tty1 ] - then - [ ! -e "${NEW_ROOT}/dev/tty1" ] && mknod "${NEW_ROOT}/dev/tty1" c 4 1 - fi - - if [ "${REAL_ROOT}" != "/dev/nfs" ] && [ "${LOOPTYPE}" != "sgimips" ] - then - bootstrap_cd - fi - - if [ "${REAL_ROOT}" = '' ] - then - warn_msg "No bootable medium found. Waiting for new devices..." - COUNTER=0 - while [ ${COUNTER} -lt 3 ]; do - sleep 3 - let COUNTER=${COUNTER}+1 - done - sleep 1 - bootstrap_cd - fi - - if [ "${REAL_ROOT}" = '' ] - then - # Undo stuff - umount "${NEW_ROOT}/dev" 2>/dev/null - umount "${NEW_ROOT}/sys" 2>/dev/null - umount /sys 2>/dev/null - - umount "${NEW_ROOT}" - rm -rf "${NEW_ROOT}/*" - - bad_msg 'Could not find CD to boot, something else needed!' - CDROOT=0 - fi -fi +# Setup Live system mounts +is_livecd && livecd_init # Determine root device good_msg 'Determining root device...'