commit d9a7bef3e57b69053af12a0d6d92b17b3e0a94e1
parent 5cb23ba9c0ffe180e41910ee61ae78df9309f087
Author: oblique <psyberbits@gmail.com>
Date: Thu, 20 Jun 2013 15:19:05 +0300
Add `busybox_initramfs.sh'
With this script you can create an initramfs that has busybox only.
Diffstat:
1 file changed, 51 insertions(+), 0 deletions(-)
diff --git a/busybox_initramfs.sh b/busybox_initramfs.sh
@@ -0,0 +1,51 @@
+#!/bin/sh
+
+SRC=n
+BUSYBOX_VERSION=1.16.1
+
+if [ $SRC = "y" ]; then
+ # build statically linked busybox
+ if [ ! -d busybox-${BUSYBOX_VERSION} ]; then
+ wget -c http://busybox.net/downloads/busybox-${BUSYBOX_VERSION}.tar.bz2
+ tar jxvf busybox-${BUSYBOX_VERSION}.tar.bz2
+ fi
+ cd busybox-${BUSYBOX_VERSION}
+ make defconfig
+ make CONFIG_STATIC=y
+ cp busybox ..
+ cd ..
+else
+ wget -O busybox -c http://www.busybox.net/downloads/binaries/${BUSYBOX_VERSION}/busybox-$(uname -m)
+fi
+
+echo "building initramfs"
+rm -rf initramfs
+mkdir -p initramfs/{bin,sbin,usr/bin,usr/sbin,etc,proc,sys}
+cp busybox initramfs/bin
+chmod +x initramfs/bin/busybox
+ln -s busybox initramfs/bin/sh
+touch initramfs/etc/mdev.conf
+
+cat << EOF > initramfs/init
+#!/bin/sh
+
+busybox mount -t proc proc /proc
+busybox mount -o remount,rw /
+/bin/busybox --install
+
+mount -t sysfs sysfs /sys
+mknod /dev/null c 1 3
+mknod /dev/tty c 5 0
+mdev -s
+
+while :; do
+ sh
+done
+EOF
+
+chmod +x initramfs/init
+
+cd initramfs
+find . | cpio --quiet -H newc -o | gzip -9 -n > ../initramfs.img
+rm -rf initramfs
+echo Done