scripts

misc scripts and tools
git clone git://git.2f30.org/scripts
Log | Files | Refs

busybox-initramfs (1169B)


      1 #!/bin/bash
      2 
      3 SRC=n
      4 BUSYBOX_VERSION=1.16.1
      5 
      6 if [ $SRC = "y" ]; then
      7     # build statically linked busybox
      8     if [ ! -d busybox-${BUSYBOX_VERSION} ]; then
      9 	wget -c http://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2
     10 	tar jxvf busybox-${BUSYBOX_VERSION}.tar.bz2
     11     fi
     12     cd busybox-${BUSYBOX_VERSION}
     13     make defconfig
     14     make CONFIG_STATIC=y
     15     cp busybox ..
     16     cd ..
     17 else
     18     wget -O busybox -c http://www.busybox.net/downloads/binaries/${BUSYBOX_VERSION}/busybox-$(uname -m)
     19 fi
     20 
     21 echo "building initramfs"
     22 rm -rf initramfs
     23 mkdir -p initramfs/{bin,sbin,usr/bin,usr/sbin,etc,proc,sys}
     24 cp busybox initramfs/bin
     25 chmod +x initramfs/bin/busybox
     26 ln -s busybox initramfs/bin/sh
     27 touch initramfs/etc/mdev.conf
     28 
     29 cat << EOF > initramfs/init
     30 #!/bin/sh
     31 
     32 busybox mount -t proc proc /proc
     33 busybox mount -o remount,rw /
     34 /bin/busybox --install
     35 
     36 mount -t sysfs sysfs /sys
     37 mknod /dev/null c 1 3
     38 mknod /dev/tty c 5 0
     39 echo /sbin/mdev > /proc/sys/kernel/hotplug
     40 mdev -s
     41 mkdir /dev/pts
     42 mount -t devpts devpts /dev/pts
     43 
     44 while :; do
     45 	sh
     46 done
     47 EOF
     48 
     49 chmod +x initramfs/init
     50 
     51 cd initramfs
     52 find . | cpio --quiet -H newc -o | gzip -9 -n > ../initramfs.img
     53 rm -rf initramfs
     54 echo Done