[BusyBox] Changing from ramdisk to ramfs: nothing but busybox

Vadim Berkgaut berk at rc.ru
Tue Jun 5 00:57:57 UTC 2001


#!/bin/busybox sh

# This linuxrc script changes root fs from ramdisk to ramfs using nothing
# but busybox. Tested with kernel 2.4.5 and current (end of May) busybox
# and uClibc, sh = hush.

busybox mount -t ramfs ramfs /mnt
busybox cp -a bin dev etc lib sbin usr var mnt
cd /mnt
busybox mkdir proc initrd
busybox pivot_root . initrd
busybox mount /proc /proc -t proc
busybox --install -s 

# It is better to return control to the kernel now. First, busybox shell
# (both hush and lash) cannot cope with "exec chroot . /sbin/init <dev/console
# >dev/console 2>&1". Second, if we run this from ash, we finish with
# init having pid 7 or something. It works, but it is ugly, and it breaks 
# busybox reboot. But before exiting let's tell the kernel not to remount root:

echo 0x100 >/proc/sys/kernel/real-root-dev

# We cannot umount initrd and freeramdisk /dev/ram0 yet, because it is busy.
# Let busybox init do it.





More information about the busybox mailing list