1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
| #!/bin/bash sudo rm -rf rootfs mkdir rootfs cd rootfs
cp -r ../_install/* . mkdir dev usr bin sbin lib etc proc tmp sys var root mnt cd etc cat > inittab <<- EOF ::sysinit:/etc/init.d/rcS ::respawn:-/bin/login ::restart:/sbin/init ::ctrlaltdel:/sbin/reboot ::shutdown:/bin/umount -a -r ::shutdown:/sbin/swapoff -a EOF
cat > profile <<- EOF # /etc/profile: system-wide .profile file for the Bourne shells echo # echo -n "Processing /etc/profile..." # no-op # Set search library path # echo "Set search library path in /etc/profile" export LD_LIBRARY_PATH=/lib:/usr/lib # Set user path # echo "Set user path in /etc/profile" PATH=/bin:/sbin:/usr/bin:/usr/sbin export PATH # Set PS1 # Note: In addition to the SHELL variable, ash supports \u, \h, \W, \$, \!, \n, \w, \nnn (octal numbers corresponding to ASCII characters) # And \e[xx;xxm (color effects), etc. # Also add an extra '\' in front of it! # echo "Set PS1 in /etc/profile" export PS1="\\e[00;32m[$USER@\\w\\a]\\$\\e[00;34m" # echo "Done" alias ll='ls -al' EOF
cat > fstab <<- EOF proc /proc proc defaults 0 0 none /tmp tmpfs defaults 0 0 mdev /dev tmpfs defaults 0 0 sysfs /sys sysfs defaults 0 0 EOF
cat > passwd <<- EOF root:x:0:0:root:/root:/bin/sh EOF
cat > group <<- EOF root:x:0:root EOF
cat > shadow <<- EOF root:4rs6NCNMjYULk:19366:0:99999:7::: EOF
mkdir init.d cd init.d
cat > rcS <<- EOF #! /bin/sh #echo "----------mount all" /bin/mount -a #echo "----------Starting mdev......" #/bin/echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s echo "********************************************************" echo " mini Rootfs" echo "********************************************************" EOF
cd ../../dev sudo mknod -m 666 console c 5 1 sudo mknod -m 666 null c 1 3 cd ../
sudo chmod 777 etc/init.d/rcS
ln -s bin/busybox init cd ../ sudo chown -R root:root rootfs cd rootfs find .| cpio -o -H newc | gzip > ../busybox_rootfs.cpio.gz
|