構建檔案系統rootfs
一 工具準備
(1)工具包
工具 mkfs.jffs2 package zlib-1.2.3.tar.gz mtd-utils-05.07.23.tar.bz2 mkyaffs2image package yaffs_source_util_large_small_page_nand.tar.bz2 tool-chain arm-linux-gcc-3.4.5
(2)工具mkfs.jffs2編譯
#tar xzf zlib-1.2.3.tar.gz #cd zlib-1.2.3 #./configure --shared --prefix=/usr #make #make install error: mkfs.jffs2.c:71:21: fatal error: sys/acl.h: No such file or directory sudo apt-get install uuid-dev libacl1-dev liblzo2-dev
#tar xjf mtd-utils-05.07.23.tar.bz2 #cd mtd-utils-05.07.23/util #make #make install
(3)工具mkyaffs2image編譯
#tar xjf? yaffs_source_util_large_small_page_nand.tar.bz2 #cd Developement_util_ok #cd yaffs2 #cd utils #make #cp mkyaffs2image /usr/local/bin #chmod +x /usr/local/bin/mkyaffs2image
二 檔案系統目錄
mkdir ~/mini2440/rootfs/rootfs -p
三 編譯Busybox-1.7.0
vim Makefile ARCH ?= arm CROSS_COMPILE ?= /usr/local/bin/3.4.5/bin/arm-linux-
make make CONFIG_PREFIX=~/mini2440/rootfs/rootfs install
四 建立重要目錄
(1)console 和 null
否則報錯: Warning: unable to open an initial console. #mkdir dev #cd dev #mknod console c 5 1 #mknod null c 1 3 #ls -l 顯示: crw-r--r-- 1 root root 5, 1 2015-05-06 20:39 console crw-r--r-- 1 root root 1, 3 2015-05-06 20:40 null 表示建立成功
(2)/etc/inittab
#cd rootfs #mkdir etc #vim etc/inittab 輸入: console::askfirst:-/bin/sh
(3)安裝c庫
#cd rootfs #mkdir lib #cp /usr/local/bin/3.4.5/arm-linux/lib/*.so* ~/mini2440/rootfs/rootfs/lib/ -d
(4)製作根檔案系統
#mkfs.jffs2 -n -s 2048 -e 128KiB -d rootfs -o rootfs.jffs2 #mkyaffs2image rootfs rootfs.yaffs2
nfs燒錄 fs-yaffs2: #nfs 30000000 192.168.1.133:/home/flinn/mini2440/bin/rootfs.yaffs2 #nand erase root #nand write.yaffs 30000000 0x260000 85b540
fs-jffs2 #nfs 30000000 192.168.1.133:/home/flinn/mini2440/bin/rootfs.jffs2 #nand erase root #nand write.jffs2 30000000 260000 $filesize #set bootargs console=ttySAC0,115200 root=/dev/mtdblock3 rootfstype=jffs2
五 優化
當前不支援PROC
(5)支援PROC
#vim etc/inittab console::askfirst:-/bin/sh ::sysinit:/etc/init.d/rcS
建立/etc/init.d/rcS 檔案 #mkdir /etc/init.d #vim /etc/init.d/rcS +mount -t proc none /proc #chmod +x /etc/init.d/rcS
(6)使用mount -a
#vim /etc/init.d/rcS #mount -t proc none /proc mount -a
mount -a 依賴/etc/fstab #vim /etc/fstab + # device mount-point type option dump fsck order + proc /proc proc defaults 0 0
(6)支援mdev
#cd rootfs #mkdir sys #vim etc/fstab +sysfs /sys sysfs defaults 0 0 +tmpfs /dev tmpfs defaults 0 0
#vim etc/init.d/rcS mount -a mkdir /dev/pts/ mount -t devpts devpts /dev/pts echo /sbin/mdev > /proc/sys/kernel/hotplug mdev -s