戻る

init

#!/bin/sh

export PATH=/bin

mount -t proc proc /proc
mount -t sysfs sys /sys

# squashfs.ko needs xz_dec.ko
for i in aufs squashfs ; do
 insmod /lib/modules/$i.ko
done

# nls_euc-jp.ko needs vfat.ko
for i in isofs nls_iso8859-1 nls_ascii nls_cp932 cdrom loop sr_mod sg \
    fat vfat nls_euc-jp ; do
  insmod /lib/modules/$i.ko
done

# for keyboard operation
for i in hid usbhid hid-generic ; do
  insmod /lib/modules/$i.ko
done
#### にゃんたろう の改悪 ここから
echo "MODULE OK ?????"
sleep 15
#### にゃんたろう の改悪 ここまで

mount_ok=0

# check USB device first
if [ $mount_ok -eq 0 ] ; then
  sleep 5
  echo -n "trying USB device:"
  for i in sda sdb sdc sdd sde sdf sdg sdh ; do
    if [ -d /sys/block/$i ] && [ `cat /sys/block/$i/removable` -eq 1 ] ; then
      echo -n " $i"
      mount /dev/${i}2 /cdrom 2> /dev/null
      if [ $? -eq 0 ] ; then
        if [ -f /cdrom/isolinux/rootimg.squash ] ; then
          echo ; echo -n "found P-Plamo image on /dev/${i}2"
          CD_DEV=/dev/${i}2
          mount_ok=1
          break
        else
          umount /cdrom
        fi
      fi
    fi
  done
  echo
fi
#### にゃんたろう の改悪 ここから 
#    上記で  ${i}2 に なっている所 は 元は ${i}1 
#    USBの 2番目 に ファイルを 置くので ${i}1 を ${i}2 に 置き換えた
#
echo "$CD_DEV FOUND OK ???"  
sleep 15
#### にゃんたろう の改悪 ここまで
# check CD device
if [ $mount_ok -eq 0 ] ; then
  sleep 10
  echo -n "trying CD device:"
  for i in sr0 sr1 sr2 ; do
    if [ -d /sys/block/$i ] ; then
      echo -n " $i"
      mount /dev/$i /cdrom 2> /dev/null
      if [ $? -eq 0 ] ; then
        sleep 3
        if [ -f /cdrom/isolinux/rootimg.squash ] ; then
          echo ; echo -n "found P-Plamo image on /dev/$i"
          CD_DEV=/dev/$i
          mount_ok=1
          break
        else
          umount /cdrom
        fi
      fi
    fi
  done
  echo
fi

# cannot find any CD device
if [ $mount_ok -eq 0 ] ; then
  echo "cannot find partition include squashfs, cannot continue booting, exit"
  exec sh
fi
#### にゃんたろう の改悪 ここから 
 echo " NOW TRY mount squashfs'ed !!!!!"
sleep 15
#### にゃんたろう の改悪 ここまで
# mount squashfs'ed rootfs image into /loop
losetup /dev/loop0 /cdrom/isolinux/rootimg.squash
mount -t squashfs /cdrom/isolinux/rootimg.squash /loop
mount -t tmpfs none /loop/tmp
for i in var bin etc lib run usr boot home sbin root opt srv misc net \
  install ; do
  mkdir -p /loop/tmp/ow/$i
  mount -t aufs -o br:/loop/tmp/ow/$i:/loop/$i none /loop/$i
done
mkdir -p /loop/dev
mount -t tmpfs tmpfs /loop/dev
cp -a /dev/console /loop/dev

echo "CD_DEV: $CD_DEV"
echo $CD_DEV > /loop/etc/cd_dev
mount --bind /proc /loop/proc
mount --bind /sys /loop/sys

echo "pivot_root to /loop"
sleep 5
cd /loop
pivot_root . loop
exec chroot . /loop/sbin/init

にゃんたろう 拝!

2014年 3月 1日 土曜日 21:18:12 JST 作成


戻る

Copyright © 2006.-2014. nyantarou All Rights Reserved.