initramfs文件系统制作和移植

initramfs文件系统制作和移植

本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2013-04/83557.htm



1.1. Initramfs的制作和移植
 
1.1.1. 对根文件系统进行修改
 
根文件系统制作可以参考这篇文档
 
由于制作initramfs文件系统启动时会在根文件系统中执行第一个init程序,它对uboot传过来的参数init=/linuxrc不予理睬,所以需要在制作的根文件系统里的根目录加入init程序,否则无法启动。init程序和linuxrc程序一样都是符号链接文件,它们都是指向/bin/busybox程序。
 
[lingyun@localhost rootfs]$ ll
 
total 60
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
 
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
 
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
 
lrwxrwxrwx 1 root    root        11 Apr 26 15:16 linuxrc -> bin/busybox
 
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
 
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
 
[lingyun@localhost rootfs]$ ln -s bin/busybox init
 
[lingyun@localhost rootfs]$ ll
 
total 60
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 apps
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 bin
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 data
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:51 dev
 
drwxr-xr-x 4 lingyun trainning 4096 Apr 26 14:16 etc
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 info
 
lrwxrwxrwx 1 lingyun trainning  11 Apr 27 21:19 init -> bin/busybox
 
drwxr-xr-x 3 lingyun trainning 4096 Apr 25 21:17 lib
 
lrwxrwxrwx 1 root    root        11 Apr 26 15:16 linuxrc -> bin/busybox
 
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 mnt
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 proc
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 root
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 26 15:16 sbin
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 sys
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:15 tmp
 
drwxr-xr-x 6 lingyun trainning 4096 Apr 25 20:15 usr
 
drwxr-xr-x 2 lingyun trainning 4096 Apr 25 20:57 var
 
[lingyun@localhost rootfs]$ 
 
1.1.2. 添加内核支持
 
[lingyun@localhost kernel]$ ls
 
build.sh  linux-3.0  linux-3.0.tar.bz2  patch
 
[lingyun@localhost kernel]$ cd linux-3.0
 
[lingyun@localhost linux-3.0]$ vt100
 
[lingyun@localhost linux-3.0]$ make menuconfig
 
。 。 。 。 。 。
 
General setup  --->
 [*] Initial RAM filesystem and RAM disk (initramfs/initrd) support
 (/opt/rootfs) Initramfs source file(s)    #输入根文件系统的所在目录  
 
。 。 。 。 。 。
 
[lingyun@localhost linux-3.0]$ ls
 
arch    crypto        fs      Kbuild  linuxrom-s3c2440.bin  modules.builtin  README          security    usr
 
block    Documentation  include  Kconfig  MAINTAINERS          modules.order    REPORTING-BUGS  sound      virt
 
COPYING  drivers        init    kernel  Makefile              Module.symvers  samples        System.map  vmlinux
 
CREDITS  firmware      ipc      lib      mm                    net              scripts        tools      vmlinux.o
 
[lingyun@localhost linux-3.0]$ du -h  linuxrom-s3c2440.bin 
 
6.9M    /tftp/linuxrom-s3c2440.bin
 
[lingyun@localhost linux-3.0]$ mv linuxrom-s3c2440.bin /tftp/
 
1.1.3. 制作映像文件
 
因为文件系统和内核是集成在一起的,所以不需要制作文件系统映像
 
1.1.4. 添加uboot支持
 
下面对uboot进行修改。
 
[ s3c2440@guowenxue ]# pri
 
bbl=nand erase 0 100000;tftp 30008000 u-boot-$cpu.bin;nand write 30008000 0 $filesize
 
norbbl=erase bank 1;tftp 30008000 u-boot-$cpu.bin;cp.b 30008000 0 $filesize
 
bkr=tftp 30008000 uImage-$cpu.gz;nand erase 100000 400000;nand write 30008000 100000 $filesize
 
bootcmd_rootfs=nand read 30008000 100000 400000;bootm 30008000
 
tpb=tftp 30008000 uImage-$cpu.gz;tftp 30800000 ramdisk-$cpu.gz;bootm 30008000 
 
mtdids=nand0=nand0
 
mtdparts=mtdparts=nand0:1M@0x0(u-boot),5M@0x100000(kernel),10M@0x600000(ramdisk),10M@0x1000000(cramfs),20M@0x1a00000(yaffs2),20M@0x2e00000(ubifs),-(users)
 
bootdelay=1
 
baudrate=115200
 
ethaddr=08:00:3e:26:0a:6b
 
ethact=dm9000
 
bcramfs=tftp 30800000 rootfs.cramfs;nand erase f00000 600000;nand write 30800000 f00000 600000
 
bjffs2=tftp 30008000 rootfs.jffs2;nand erase 1e00000 1400000;nand write.jffs2 30008000 1e00000 1400000
 
bootargs_jffs2=noinitrd root=/dev/mtdblock4 rootfstype=jffs2 init=/linuxrc console=ttyS0,115200
 
bootargs_cramfs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
 
bootargs_ubifs=console=ttyS0,115200 mem=64M ubi.mtd=6 root=ubi0:rootfs rootwait rootfstype=ubifs rw
 
bubifs=tftp 30008000 ubifs-$cpu.img;nand erase 6e00000 900000;nand write 30008000 6e00000 900000
 
cpu=arm920t
 
brdfs=tftp 30008000 ramdisk.gz;nand erase 500000 a00000;nand write 30008000 500000 500000
 
bootcmd_ramdisk=nand read 30008000 100000 400000;nand read 30800000 500000 500000;bootm 30008000
 
bootargs_ramdisk=console=ttyS0,115200 mem=64M initrd=0x30800000,16M root=/dev/ram0 rw loglevel=7
 
ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
 
bootargs_nfs=noinitrd console=ttyS0,115200 init=/linuxrc mem=64M loglevel=7 root=/dev/nfs rw nfsroot=192.168.1.3:/opt/rootfs ip=192.168.1.111:192.168.1.3:192.168.1.1:255.255.255.0:localhost.com:eth0:off
 
bootargs=noinitrd root=/dev/mtdblock3 rootfstype=cramfs init=/linuxrc console=ttyS0,115200
 
filesize=4DF000
 
fileaddr=30800000
 
netmask=255.255.255.0
 
ipaddr=192.168.1.111
 
serverip=192.168.1.3
 
bootcmd=run bootcmd_rootfs
 
stdin=serial
 
stdout=serial
 
stderr=serial
 


Environment size: 2064/131068 bytes
 
[ s3c2440@guowenxue ]# 
 
[ s3c2440@guowenxue ]# set bkr 'tftp 30008000 linuxrom-s3c2440.bin;nand erase 100000 800000;nand write 30008000 100000 800000'
 
[ s3c2440@guowenxue ]# set bootargs 'console=ttyS0,115200 mem=64M init=/linuxrc rw loglevel=7'
 
[ s3c2440@guowenxue ]# set bootcmd_initramdisk 'nand read 30008000 100000 800000;bootm 30008000'
 
[ s3c2440@guowenxue ]# set bootcmd 'run bootcmd_initramdisk'
 
[ s3c2440@guowenxue ]# save
 
Saving Environment to NAND...
 
Erasing Nand...
 
Erasing at 0x60000 -- 100% complete.
 
Writing to Nand... Done
 
[ s3c2440@guowenxue ]# run bkr
 
dm9000 i/o: 0x20000300, id: 0x90000a46 
 
DM9000: running in 16 bit mode
 
MAC: 08:00:3e:26:0a:6b
 
could not establish link
 
operating at 100M full duplex mode
 
Using dm9000 device
 
TFTP from server 192.168.1.3; our IP address is 192.168.1.111
 
Filename 'linuxrom-s3c2440.bin'.
 
Load address: 0x30008000
 
Loading: T T #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        #################################################################
 
        ###################################
 
done
 
Bytes transferred = 7187832 (6dad78 hex)
 


NAND erase: device 0 offset 0x100000, size 0x800000
 
Erasing at 0x8e0000 -- 100% complete.
 
OK
 


NAND write: device 0 offset 0x100000, size 0x800000
 
 8388608 bytes written: OK


本篇文章来源于 Linux公社网站(www.linuxidc.com)  原文链接:http://www.linuxidc.com/Linux/2013-04/83557.htm

你可能感兴趣的:(initramfs文件系统制作)