构建根文件系统-initramfs

 用initramfs方式构建根文件系统
步骤:
0) set enveniment
a) $ export PATH=$PATH:/usr/local/arm/arm-2009q3/bin

1) make busybox.
a) $ cd busybox-1.20.2
b) $ make menuconfig
Busybox Settings
--> Build Options
 [*] select build busybox as a static binary
 (arm-none-linux-gnueabi-) Cross Compiler Prefix
c) $ make
d) $ make install
e) $ cd ..


2) create necessary directory and files
a) $ mkdir rootfs && cd rootfs
b) $ mkdir -p etc/init.d proc sys dev
c) $ sudo cp -a /dev/{null,zero,console} dev/
d) $ cp -rf ../busybox-1.20.2/_install/* ./
e) $ rm -f linuxrc && ln -s bin/busybox init
f) edit etc/fstab, add followings:
proc    /proc   proc    defaults    0   0
sysfs   /sys    sysfs   defaults    0   0
g) edit etc/inittab
::sysinit:/etc/init.d/rcS
console::respawn:-/bin/sh
::ctrlaltdel:/sbin/reboot
::shutdown:/bin/umount -a -r
h) edit etc/init.d/rcS
#!/bin/sh
mount -a
i) $ chmod +x etc/init.d/rcS
j) $ cd ..

3) create rootfs image.
a) $ dd if=/dev/zero of=rootfs.img bs=1k count=8192
b) $ sudo mke2fs -F -v -m0 rootfs.img
c) $ sudo mount -o loop rootfs.img /mnt/tmp/
mount: mount point /mnt/tmp/ does not exist 解决办法:sudo mount -o loop rootfs.img /mnt/
d) $ sudo cp rootfs/* /mnt/tmp/ -rf 替换为 sudo cp rootfs/* /mnt/ -rf
e) $ sudo umount /mnt/tmp/ 替换为 sudo umount /mnt/
f) $ gzip -9 rootfs.img
g) $ fastboot flash ramdisk rootfs.img.gz

4) modify bootloader
a) 由于要加入rootfs,kernel size指定时要超过编译后的大小
diff --git a/TC4_uboot/include/movi.h b/TC4_uboot/include/movi.h
index dc8906d..b62fb2d 100644
--- a/TC4_uboot/include/movi.h
+++ b/TC4_uboot/include/movi.h

/* partition information */
#define PART_SIZE_UBOOT                (480 * 1024)
+//[yeez_jinwei] 2012-10-17 中kernel+rootfs -> zImage size: 5.3M
-#define PART_SIZE_KERNEL       (4 * 1024 * 1024)
+//#define PART_SIZE_KERNEL       (4 * 1024 * 1024)
+#define PART_SIZE_KERNEL       (8 * 1024 * 1024) 
#define PART_SIZE_ROOTFS       (2 * 1024 * 1024)//  2M

5) modify kernel
a) modify kernel config
Kernel Setting
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support  
(rootfs)Initramfs source file(s) 或者vi arch/arm/configs/m8012_defconfig 修改CONFIG_INITRAMFS_SOURCE="rootfs"
[CONFIC_CMDLINE=console=ttySCA0 xxx即可]
6) 编译内核
$(KERNEL_ROOT)/build_kernel.sh new
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值