Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1828702
  • 博文数量: 286
  • 博客积分: 3713
  • 博客等级: 少校
  • 技术积分: 2275
  • 用 户 组: 普通用户
  • 注册时间: 2012-01-11 09:47
个人简介

http://blog.chinaunix.net/uid/16979052.html

文章分类

全部博文(286)

文章存档

2018年(1)

2017年(16)

2016年(9)

2015年(17)

2014年(15)

2013年(112)

2012年(116)

分类: LINUX

2012-06-28 13:01:38

#!/bin/sh

echo "makeing rootdir"
mkdir rootfs
cd rootfs

echo "makeing dir: bin dev etc lib proc sbin sys usr"
mkdir bin dev etc lib proc sbin sys usr 
mkdir usr/bin usr/lib usr/sbin lib/modules
mkdir etc/init.d

#Don't use mknod, unless you run this Script as
mknod -m 600 dev/console c 5 1
mknod -m 666 dev/null c 1 3

echo "making dir: mnt tmp var"
mkdir mnt tmp var
chmod 1777 tmp
mkdir var/lib var/lock var/log var/run var/tmp
chmod 1777 var/tmp

echo "making dir: home root boot"
mkdir home root boot
echo "done"

echo "must have a init in root"

cat > etc/fstab  << EOF
proc /proc proc defaults 0 0
none /tmp ramfs defaults 0 0
mdev /dev ramfs defaults 0 0
sysfs /sys sysfs defaults 0 0
EOF

cat > etc/hostname << EOF
src-yinzh
EOF


cat > etc/profile << EOF
#/etc/profile: system-wide .profile file
export LD_LIBRARY_PATH=/lib:/usr/lib
PATH=/bin:/sbin:/usr/bin:/usr/sbin
export PATH
HOSTNAME=`/bin/hostname`
export PS1="\\e[32m[$USER@$HOSTNAME \\w\\a]\\$\\e[00;37m "
EOF

cat > etc/issue << EOF
linux version test
EOF
cat > etc/securetty <
# /etc/securetty: list of terminals on which root is allowed to login.
# See securetty(5) and login(1).
console
# Virtual consoles
tty1
tty2
tty3
tty4
tty5
tty6
tty7
# UART serial ports
ttyS0
ttyS1
ttyS2
# telnet login enable
pts/1
pts/2

EOF

cat > etc/inittab << EOF
#/etc/inittab

::sysinit:/bin/mount -t proc proc /proc
::sysinit:/bin/mkdir -p /dev/pts
::sysinit:/bin/mkdir -p /dev/shm
::sysinit:/etc/init.d/rcS

# Put a getty on the serial port
ttyS0::respawn:/sbin/getty -L ttyS0 115200 vt100
::respawn:/sbin/getty 38400 tty1
::respawn:/sbin/getty 38400 tty2
tty3::respawn:-/bin/sh

# Stuff to do for the 3-finger salute
::ctrlaltdel:/sbin/reboot

# Stuff to do before rebooting
::shutdown:/etc/init.d/rcK
::shutdown:/bin/umount -a -r
::shutdown:/sbin/swapoff -a
EOF

cat > etc/init.d/rcS << EOF
#!/bin/sh
echo "Processing etc/init.d/rcS"
/bin/mount -a
# Start all init scripts in /etc/init.d
# executing them in numerical order.

for i in /etc/init.d/S??* ;do
# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue

case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set start
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i start
;;
esac
done
EOF

cat > etc/init.d/rcK << EOF
#!/bin/sh
# Stop all init scripts in /etc/init.d
# executing them in reversed numerical order.

for i in $(ls -r /etc/init.d/S??*) ;do

# Ignore dangling symlinks (if any).
[ ! -f "$i" ] && continue

case "$i" in
*.sh)
# Source shell script for speed.
(
trap - INT QUIT TSTP
set stop
. $i
)
;;
*)
# No sh extension, so fork subprocess.
$i stop
;;
esac
done
EOF

cat > etc/init.d/S10mdev << EOF
#!/bin/sh
# Start mdev....
case "$1" in
  start)
echo "Starting mdev..."
/sbin/mdev -s
;;
  stop)
;;
  restart|reload)
;;
  *)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
EOF

cat > etc/init.d/S11hostname << EOF
#!/bin/sh
case "$1" in
start)
/bin/hostname -F /etc/hostname
;;
stop)
;;
restart|reload)
;;
*)
echo $"Usage: $0 {start|stop|restart}"
exit 1
esac
exit $?
EOF


cd rootfs;find . | cpio -o -H newc | gzip > ../image.cpio.gz
#qemu -kernel vmlinuz-2.6.32-5-686 -append "root=/dev/ram0"  -initrd image.cpio.gz

阅读(1603) | 评论(0) | 转发(0) |
0

上一篇:U盘上Linux rootfs

下一篇:nginx php cluster

给主人留下些什么吧!~~