(Copied from Manohar's gist: https://gist.github.com/mcastelino/74dc46bdfddc9943f2c04466d605a65b which is copied from https://gist.github.com/pacalet/660fa6472e0bcd53f71fc31f167c628f)
- Use a busybox based rootfs for ease of use
git clone https://github.com/mirror/busybox
cd busybox
make defconfig
make menuconfig (enable Busybox Settings ---> Build Options ---> Build BusyBox as a static binary (no shared libs) ---> yes)
make
make install
- Create the initramfs
mkdir $HOME/rootfs
cd $HOME/rootfs
mkdir -p bin sbin etc proc sys usr/bin usr/sbin
cp -a $BUSYBOX_BUILD/_install/* .
rm linuxrc
sudo mknod -m 644 dev/console c 5 1
sudo mknod -m 644 dev/loop0 b 7 0
- Create an init binary with appropriate contents with executeable perms
#!/bin/sh
mount -t proc none /proc
mount -t sysfs none /sys
echo -e "Hello World\n"
exec /bin/sh