initramfs檔案系統的製作和移植
initramfs檔案系統——基於RAM的檔案系統
initramfs在編譯核心的同時被編譯並與核心生成一個映像檔案,可以壓縮也可以不壓縮,但是目前只支援cpio包格式。它是根檔案系統製作和製作的一種非常簡單的方法,由於initramfs使用cpio包格式,所以很容易將一個單一的檔案、目錄、node編譯連結到系統中去,這樣很簡單的系統中使用起來很方便,不需要另外掛接檔案系統。但是也有缺點,因為是基於RAM的檔案系統,掉電後文件丟失.
製作如下:
由於製作initramfs檔案系統啟動時會在根檔案系統中執行第一個init程式,它對uboot傳過來的引數init=/linuxrc不予理睬,所以需要在上面製作的根檔案系統裡的根目錄加入
[[email protected] rootfs]$ ln -s bin/busybox init
##建立busybox的軟連結,相當於快捷方式
[[email protected] linux-3.0]$ vt100
##完整命令為export TERM=vt100,可以自己在環境變數中設定別名,這裡表示環境變數TERM設定為終端機,防止出現亂碼!
[[email protected] linux-3.0]$ make menuconfig
General setup --->
[*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
(/opt/rootfs) Initramfs source file(s)
[[email protected] linux-3.0]$ make生成檔案linuxrom-s3c2440.bin,用sz命令將它放到Windows下的tftp資料夾下,
改名為uImage_initramfs.bin
移植過程:
啟動開發板,u-boot下的操作如下
[[email protected]]# set bkri 'tftp 30008000 uImage_initramfs.bin;nand erase 100000 f00000;nand write 30008000 100000 800000'
[ [email protected]]# set bootcmd_initramfs 'nand read 30008000 100000 800000;bootm 30008000'
[[email protected]]# set bootargs_initramfs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
[[email protected]]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
[[email protected]]# set bootcmd 'run bootcmd_initramfs'
[[email protected]]# save
[[email protected]]# run bkri
[[email protected]]# boot
說明
1 run bkri即執行tftp 30008000 uImage_initramfs.bin;nand erase 100000 f00000;nand write 30008000 100000 800000這三個命令
2 boot(對應bootcmd)即執行run bootcmd_initramfs,而bootcmd_initramfs對應nand read 30008000 100000 800000;bootm 30008000
3 bootargs_initramfs可設定也可不設定,主要為了方便記下引數
4 最關鍵的是bootargs,bootcmd,還有記得要save(即儲存到nandflash中).如果不儲存,重啟後設置就沒了,又要重新設定.
啟動過程省略,使用者登入root,無密碼
>: mount
rootfs on / type rootfs (rw)
proc on /proc type proc (rw,relatime)
tmpfs on /tmp type tmpfs (rw,relatime)
tmpfs on /dev type tmpfs (rw,relatime)
sysfs on /sys type sysfs (rw,relatime)
devpts on /dev/pts type devpts (rw,relatime,mode=600)
檔案系統已經掛載在根(/)下
移植完成!