2007年2月6日 星期二

Howto initramfs on linux-2.6.x

@Create external cpio archie


1.Create root file system on $BUSYBOX/ramdisk
2.cd $BUSYBOX/ramdisk
3.find . | cpio -o -H newc > ../initramfs.cpio
4.cp $BUSYBOX/initramfs.cpio $KERNEL/usr
5.cd $KERNEL
6.Set kernel config -> CONFIG_INITRAMFS_SOURCE="usr/initramfs.cpio"
7.make zImage

Note:Busybox can be dynamic linked, but be sure shared libraries in /lib

        /*
         * check if there is an early userspace init.  If yes, let it do all
         * the work
         */

        if (!ramdisk_execute_command)
                ramdisk_execute_command = "/init"; <- Symblic link /init to /bin/sh. We can run into shell and never return

        if (sys_access((const char __user *) ramdisk_execute_command, 0) != 0) {
                ramdisk_execute_command = NULL;
                prepare_namespace();
        }


@Create cpio archie by script


1.Create script file $KERNEL/usr/cpio_list


dir /dev 755 0 0
nod /dev/ram0 644 0 0 b 1 0
nod /dev/null 644 0 0 c 1 3
nod /dev/zero 644 0 0 c 1 5
nod /dev/random 644 0 0 c 1 8
nod /dev/urandom 644 0 0 c 1 9
nod /dev/tty0 644 0 0 c 4 0
nod /dev/tty1 644 0 0 c 4 1
nod /dev/tty2 644 0 0 c 4 2
nod /dev/tty 644 0 0 c 5 0
nod /dev/console 644 0 0 c 5 1
nod /dev/loop0 644 0 0 b 7 0
nod /dev/rtc 644 0 0 c 10 135
nod /dev/dsp 644 0 0 c 14 3
slink /dev/sound/dsp /dev/dsp 644 0 0
nod /dev/mtdblock0 644 0 0 b 31 0
nod /dev/mtdblock1 644 0 0 b 31 1
nod /dev/mtdblock2 644 0 0 b 31 2
nod /dev/mtd0 644 0 0 c 90 0
nod /dev/mtd1 644 0 0 c 90 1
nod /dev/mtd2 644 0 0 c 90 2
nod /dev/ttySAC0 644 0 0 c 204 64
nod /dev/ttySAC1 644 0 0 c 204 65
nod /dev/ttySAC2 644 0 0 c 204 66
dir /dev/pts 644 0 0


 


dir /bin 755 1000 1000
file /bin/busybox /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/bin/busybox 755 0 0
slink /bin/sh /bin/busybox 777 0 0
slink /bin/login /bin/busybox 777 0 0
slink /bin/mount /bin/busybox 777 0 0
slink /bin/umount /bin/busybox 777 0 0
slink /bin/hostname /bin/busybox 777 0 0
slink /bin/ifconfig /bin/busybox 777 0 0
slink /bin/ping /bin/busybox 777 0 0
slink /bin/netstat /bin/busybox 777 0 0
slink /bin/date /bin/busybox 777 0 0
slink /bin/ls /bin/busybox 777 0 0
slink /bin/ln /bin/busybox 777 0 0
slink /bin/mkdir /bin/busybox 777 0 0
slink /bin/mv /bin/busybox 777 0 0
slink /bin/rm /bin/busybox 777 0 0
slink /bin/cat /bin/busybox 777 0 0
slink /bin/echo /bin/busybox 777 0 0
slink /bin/kill /bin/busybox 777 0 0
slink /bin/killall /bin/busybox 777 0 0
slink /bin/ps /bin/busybox 777 0 0
slink /bin/df /bin/busybox 777 0 0
slink /bin/free /bin/busybox 777 0 0


 


dir /sbin 755 0 0
slink /sbin/init /bin/busybox 755 0 0
slink /sbin/getty /bin/busybox 755 0 0
slink /sbin/poweroff /bin/busybox 755 0 0
slink /sbin/halt /bin/busybox 755 0 0
slink /sbin/reboot /bin/busybox 755 0 0
slink /sbin/hwclock /bin/busybox 755 0 0
slink /sbin/insmod /bin/busybox 755 0 0
slink /sbin/rmmod /bin/busybox 755 0 0
slink /sbin/lsmod /bin/busybox 755 0 0
slink /sbin/modprobe /bin/busybox 755 0 0
slink /sbin/syslogd /bin/busybox 755 0 0
file /sbin/ftpd /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/sbin/ftpd 755 0 0



slink /init /bin/sh 755 0 0



dir /etc 755 0 0
file /etc/inittab /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/inittab 644 0 0
file /etc/fstab /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/fstab 644 0 0
file /etc/passwd /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/passwd 644 0 0
file /etc/group /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/group 644 0 0
file /etc/resolv.conf /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/resolv.conf 644 0 0
file /etc/hosts /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/hosts 644 0 0
file /etc/host.conf /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/host.conf 644 0 0
file /etc/services /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/services 644 0 0
dir /etc/init.d 755 0 0
file /etc/init.d/rcS /home/gigijoe/S3C2410/busybox-1.2.1/ramdisk/etc/init.d/rcS 755 0 0


 


dir /proc 755 0 0
dir /sys 755 0 0
dir /mnt 755 0 0
dir /tmp 755 0 0
dir /var 755 0 0
dir /var/log 755 0 0


2.Set kernel config -> CONFIG_INITRAMFS_SOURCE="usr/cpio_list"


3.make zImage


沒有留言:

張貼留言