rc.sysinit became a mess for PUPMODE 2

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

rc.sysinit became a mess for PUPMODE 2

Karl Godt
Administrator
Not sure if I have the latest /etc/rc.d/rc.sysinit :

first it deletes entries in /tmp

then it does

exec 1>/tmp/bootsysinit.log 2>&1

then it mounts /tmp over the current /tmp

mount -t tmpfs -o size=${QTRFREERAM}k tmpfs /tmp

so the bootsysinitlog gets covered underneath by the new /tmp tmpfs




There is apparently much to do to rework the whole head .

I personally have put the mounts of rootfs rw, /proc, /sys, /dev into /sbin/init script .

first mount of rootfs as
mount -o remount,rw /dev/root /

then check if directory exists and mkdir /proc
mount -t proc proc /proc

same with /sys
then /dev
because running mdev -s needs /sys mounted :

test -f /etc/rc.d/PUPSTATE && . /etc/rc.d/PUPSTATE || PUPMODE=2

if [ -d /proc ] ; then
FINDPROC=`find /proc -maxdepth 1 -type f 2>/dev/null`
[ -z "$FINDPROC" ] && busybox mount -t proc none /proc  ###KRG put here for additional df check (wary094 frugal had written /initrd into full install) ###KRG
else
busybox mount -o remount,rw /dev/root /
mkdir /proc
busybox mount -t proc none /proc
fi

if [ -d /sys ] ; then
FINDSYS=`find /sys/* -maxdepth 0 -type d 2>/dev/null`
[ -z "$FINDSYS" ] && busybox mount -t sysfs none /sys
else
busybox mount -o remount,rw /dev/root /
mkdir /sys
busybox mount -t sysfs none /sys
fi


status_func() {
 if [ $1 -eq 0 ];then
  /bin/echo -e "\\033[72G\\033[1;32mdone\\033[0;39m" >/dev/console #green [done] msg.
 else
  /bin/echo -e "\\033[70G\\033[1;31mfailed\\033[0;39m" >/dev/console #red [failed].
  STATUS=0
 fi
 return $1 #return with same status as entry param.
}

#if [ "`rdev`" -o "`busybox df | grep 'initrd'`" = "" ] ; then
if [ "$PUPMODE" = 2 ]; then
busybox mount -o remount,rw /dev/root /
###+++2011-11-10
 if [ -d /tmp ] ; then
   rm -rf /tmp/* ; rm -rf /tmp/.[a-zA-Z0-9]*  ##2011-11-25 added rm of hidden temp files
 else
   mkdir /tmp
 fi
 chmod 1777 /tmp
###+++2011-11-10
mountpoint -q /dev || {
test "`which mdev`" && {
test -d /dev || mkdir /dev
mount -t ramfs devramfs /dev
        mdev -s; } ; } ###+++2014-06-25

else
STATUS=0
status_func $STATUS
fi

BUSYBOX_INIT_FUNC(){  ###KRG
busybox umount /sys
busybox umount /proc
exec busybox init
}

#if [ -d /initrd -a -n "`busybox df | grep '/initrd'`" ]; then
if [ "$PUPMODE" != 2 ]; then
BUSYBOX_INIT_FUNC
fi  ###KRG

I mount /dev as ramfs , not devtmpfs if old kernels are not configured for devtmpfs ( look at HELP in menuconfig or Documentation ) .
test -e /proc/mounts is likely much more easy than find for files to check if mounted .
I use the existence of /etc/rc.d/PUPSTATE and source it for PUPMODE instead test -d /initrd .
/etc/rc.d/PUPSTATE should always exist either created by /init or rc.sysinit except probably in fresh full install PUPMODE 2 .

Since I managed to boot into PUPMODE 2 using initrd , which would create a /initrd folder , I am thinking of adding PUPMODE 22 (twenty-two) for full install PUPMODE 2 with initialramdisk support .



Here is another code snip i have put into /init script of initrd to populate /dev :
##130612 detect CONFIG_DEVTMPFS=y and CONFIG_DEVTMPFS_MOUNT=y...
#DEVTMPFSFLG=`gunzip -c /proc/config.gz | grep 'CONFIG_DEVTMPFS.*=y' | wc -l`
DEVTMPFSFLG=0 #130618 set it from 3builddistro.

_do_devtmpfs(){
# always use DEVTMPFS now.
if grep $Q "[[:blank:]]\+devtmpfs$" /proc/filesystems; then
DEVTMPFSFLG=1 #130618 set it from 3builddistro.
 if grep $Q ' /dev ' /proc/mounts; then
 DEVTMPFSFLG=2
 elif [ "`which mdev`" -o "`which mknod`" ]; then
  mount -t devtmpfs devtmpfs /dev
  if [ $? = 0 ]; then
   if [ "`which mdev`" ]; then
    mdev -s
   else
     oldIFS="$IFS"
     IFS=$'\n'
     find /sys -type f -name uevent -perm 644 |
     while read oneFILE
     do
     unset K MAJOR MINOR DEVPATH DEVNAME DEVTYPE DRIVER DEVICE PRODUCT TYPE BUSNUM DEVNUM INTERFACE MODALIAS DEVMODE
     source "$oneFILE" 2>>$ERR  || continue
     test "$MAJOR" -a "$MINOR"      || continue
     test "$DEVNAME" && { test -e /dev/$DEVNAME && continue; } || { DEVNAME=${oneFILE%/uevent*}; DEVNAME=${DEVNAME##*/}; test -e /dev/$DEVNAME && continue; }
     test "$DEVMODE" && DEVMODE=-m\ $DEVMODE
     test -e /dev/$DEVPATH/$DEVNAME || {
     test "$DEVTYPE" = disk -o "$DEVTYPE" = partition && K=b || K=c
     test ${DEVNAME%/*} = $DEVNAME || { test -d /dev/$DEVPATH/${DEVNAME%/*} || mkdir $VERB -p /dev/$DEVPATH/${DEVNAME%/*}; }
     mknod $DEVMODE /dev/$DEVPATH/$DEVNAME $K $MAJOR $MINOR
      }
     done
     IFS="$oldIFS"
   fi
  else
   DEVTMPFSFLG=0
  fi
 else
  DEVTMPFSFLG=0
 fi
fi
#DEVTMPFSFLG=1 #130618 set it from 3builddistro.
}
_do_devtmpfs
for devtmpfs handling .
Loading...