3、初始化rootfs脚本--创建小型linux


#!/bin/bash
# function:Initalize the system script
source /scripts/automount.sh

ROOTFS () {
[ -d $N ] && (mount |grep $N) || echo "ERROR,The $N is not mounted";read -p "Do you want to continue.(y/n)" ANSWER
if [ "$ANSWER" = "n" -o "$ANSWER" = "N" ];then
       exit
fi
 rm -rf $N/*
 mkdir -pv $N/{boot,proc,sys,dev,home,root,etc/{rc.d,sysconfig,init.d},bin,sbin,lib,usr/{bin,sbin,lib,include},var/{log,run},tmp,mnt,opt,media}
 echo "mkdir directory sucessful."
 chmod 1777 $N/tmp
 echo "change the tmp type sucessful."
 cat >> $N/etc/inittab << EOF
id:3:initdefault:
si::sysinit:/etc/rc.d/rc.sysinit
EOF
[ $? -eq 0 ] &&  echo "$N/etc/inittab is sucessful."
 cat >> $N/etc/rc.d/rc.sysinit << EOF
       #!/bin/bash
       echo -e "Welcome to fish linux."
       mount -n -o remount,rw /
       mount -n -a
       /bin/bash
EOF
[ $? -eq 0 ] && echo "$N/etc/rc.d/rc.sysinit is sucessful."
  chmod +x $N/etc/rc.d/rc.sysinit
  cat >> $N/etc/fstab << EOF
       /dev/sda2       /       ext3    defaults        0 0
       /dev/sda1       /boot   ext3    defaults        0 0
       sysfs           /sys    sysfs   defaults        0 0
       proc            /proc   proc    defaults        0 0
EOF
[ $? -eq 0 ] && echo "The $N/etc/fstab is sucessful."

}
ROOTFS $N

本文出自 “fish” 博客,请务必保留此出处http://seeds.blog.51cto.com/1501815/1396132

3、初始化rootfs脚本--创建小型linux,布布扣,bubuko.com

3、初始化rootfs脚本--创建小型linux

上一篇:4、拷贝命令以及命令所对应的库文件脚本--创建小型linux


下一篇:linux-pppoe