免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1318 | 回复: 0
打印 上一主题 下一主题

initramfs 使用 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-10-14 21:37 |只看该作者 |倒序浏览
initramfs usage
使用initramfs可以实现内核和文件系统在一个映像文件中,不过会增大内核体积,同时占用较多内存。
(1)准备根文件系统先准备好根文件系统,放到某个目录,不过为了方便和内核一起打包,可以放到内核源代码的usr/目录下,我的做法是在usr目录下建立了image目录,然后将可用的根文件系统的内容全部复制到image目录下:[chenxibing@localhost linux-2.6.27.8-smartarm3250]$ ls usr/imagebin   dev  hello.c       home  lib       mnt  proc  sbin  tmp  varboot  etc  hello_static  [color="#FF0000"]init  Makefile  opt  root  sys   usr
另外千万注意,initramfs识别的第一个进程名称为init,因此需要将原来根文件系统中busybox的linuxrc链接改名为init。
(2)配置内核配置内核,在General setup中使能initramfs,
  • Initial RAM filesystem and RAM disk (initramfs/initrd) support  (./usr/image) Initramfs source file(s)  
    同时在Userspace binary formats 中使能elf文件支持:
  • Kernel support for ELF binaries
    (3)编译内核,加载运行make make uImage
    编译出来后内核较大,由于根文件系统也比较大,我得到的内核有11M,加载后运行,解压的时间也变长了,但是内核运行之后很快就进入到shell界面了。
    U-Boot 1.3.3 (Sep  1 2009 - 12:31:06)
    DRAM:  64 MBFlash:  2 MBNAND:  256 MiBIn:    serialOut:   serialErr:   serialHit any key to stop autoboot:  0U-Boot$   ru nfsboot        HW MAC address:  00:01:90:00:C0:81ENET:auto-negotiation completeENET:Link status upENET:FULL DUPLEXENET:100MBaseTFTP from server 192.168.7.238; our IP address is 192.168.7.236Filename 'uImage'.Load address: 0x81000000Loading: #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #################################################################         #############################################doneBytes transferred = 12108228 (b8c1c4 hex)## Booting kernel from Legacy Image at 81000000 ...   Image Name:   Linux-2.6.27.8   Image Type:   ARM Linux Kernel Image (uncompressed)   Data Size:    12108164 Bytes = [color="#FF0000"]11.5 MB   Load Address: 80008000   Entry Point:  80008000   Verifying Checksum ... OK   Loading Kernel Image ... OKOK
    Starting kernel ...
    Uncompressing Linux.............................................................................................................................................................................................................................................................................................................................................. done, booting the kernel.Linux version 2.6.27.8 (chenxibing@localhost.localdomain) (gcc version 4.3.2 (crosstool-NG-1.3.1) ) #9 PREEMPT Thu Sep 3 09:55:52 CST 2009CPU: ARM926EJ-S [41069264] revision 4 (ARMv5TEJ), cr=00053177Machine: SmartARM3250 board with the LPC3250 MicrocontrollerMemory policy: ECC disabled, Data cache writebackCPU0: D VIVT write-back cacheCPU0: I cache: 32768 bytes, associativity 4, 32 byte lines, 256 setsCPU0: D cache: 32768 bytes, associativity 4, 32 byte lines, 256 setsBuilt 1 zonelists in Zone order, mobility grouping on.  Total pages: 16256Kernel command line: root=/dev/mtdblock4 console=ttyS0,115200 mem=64M rootfstype=yaffs2PID hash table entries: 256 (order: 8, 1024 bytes)Console: colour dummy device 80x30Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)Memory: 64MB = 64MB totalMemory: 50972KB available (3352K code, 238K data, 10296K init)Calibrating delay loop... 129.84 BogoMIPS (lpj=649216)Mount-cache hash table entries: 512CPU: Testing write buffer coherency: oknet_namespace: 288 bytesNET: Registered protocol family 16Invalid board descriptor!LPC32XX DMA driverSCSI subsystem initializedusbcore: registered new interface driver usbfsusbcore: registered new interface driver hubusbcore: registered new device driver usbNET: Registered protocol family 2IP route cache hash table entries: 1024 (order: 0, 4096 bytes)TCP established hash table entries: 2048 (order: 2, 16384 bytes)TCP bind hash table entries: 2048 (order: 1, 8192 bytes)TCP: Hash tables configured (established 2048 bind 2048)TCP reno registeredNET: Registered protocol family 1NetWinder Floating Point Emulator V0.97 (double precision)JFFS2 version 2.2. (NAND) © 2001-2006 Red Hat, Inc.yaffs Sep  3 2009 09:30:12 Installing.msgmni has been set to 99io scheduler noop registeredio scheduler anticipatory registeredio scheduler deadline registeredio scheduler cfq registered (default)CLCD: ZHIYUAN LCD hardware, XVGA portrait displayConsole: switching to colour frame buffer device 128x48Serial: 8250/16550 driver4 ports, IRQ sharing disabledserial8250.0: ttyS0 at MMIO 0x40090000 (irq = 9) is a 16550Aconsole [ttyS0] enabledserial8250.0: ttyS1 at MMIO 0x40080000 (irq = 7) is a 16550Aserial8250.0: ttyS2 at MMIO 0x40088000 (irq = 8) is a 16550Aserial8250.0: ttyS3 at MMIO 0x40098000 (irq = 10) is a 16550Alpc32xx_hsuart.0: ttyTX0 at MMIO 0x40014000 (irq = 26) is a lpc32xx_hsuartlpc32xx_hsuart.0: ttyTX1 at MMIO 0x40018000 (irq = 25) is a lpc32xx_hsuartlpc32xx_hsuart.0: ttyTX2 at MMIO 0x4001c000 (irq = 24) is a lpc32xx_hsuartloop: module loadedLPC32XX_mii_bus: probedeth0: LPC32XX mac at 0x31060000 irq 29eth0: attached PHY driver [Generic PHY] (mii_bus:phy_addr=0:00, irq=-1)Uniform Multi-Platform E-IDE driveride0 at 0xc4866020-0xc486602e,0xc486602e on irq 86Driver 'sd' needs updating - please use bus_type methodsNAND device: Manufacturer ID: 0xec, Chip ID: 0xda (Samsung NAND 256MiB 3,3V 8-bit)Scanning device for bad blocksBad eraseblock 627 at 0x04e60000Creating 5 MTD partitions on "lpc32xx_nand":0x00000000-0x00180000 : "smartarm3250-boot"0x00180000-0x001c0000 : "smartarm3250-ubt-prms"0x00200000-0x00600000 : "smartarm3250-kernel"0x00600000-0x01600000 : "smartarm3250-safefs"0x01600000-0x10000000 : "smartarm3250-rootfs"at25 spi0.0: 32 KByte at25256a eeprom, pagesize 64I2C device at address 0x2dISP1301 Vendor ID  : 0x04ccISP1301 Product ID : 0x1301ISP1301 Version ID : 0x0210usb-ohci usb-ohci: at 0xf3120000, irq 0usb-ohci usb-ohci: pnx4008 OHCIusb-ohci usb-ohci: new USB bus registered, assigned bus number 1usb-ohci usb-ohci: irq 59, io mem 0xf3120000usb usb1: configuration #1 chosen from 1 choicehub 1-0:1.0: USB hub foundhub 1-0:1.0: 2 ports detectedInitializing USB Mass Storage driver...usbcore: registered new interface driver usb-storageUSB Mass Storage support registered.mice: PS/2 mouse device common for all miceinput: LPC32xx Touchscreen as /class/input/input0rtc-pcf8563 3-0051: chip found, driver version 0.4.3rtc-pcf8563 3-0051: rtc core: registered rtc-pcf8563 as rtc0rtc-lpc32xx rtc-lpc32xx: rtc core: registered rtc-lpc32xx as rtc1i2c /dev entries driverPNX4008-WDT: PNX4008 Watchdog Timer: heartbeat 19 secmmci-pl18x: DMA buffer(10000 bytes), P:0x812b0000, V:0xffdc0000mmc0: MMCI rev 0 cfg 00 at 0x0000000020098000 irq 15,13usbcore: registered new interface driver usbhidusbhid: v2.6:USB HID core driverAdvanced Linux Sound Architecture Driver Version 1.0.17.ASoC version 0.13.2UDA1380 Audio Codec 0.6ALSA device list:  No soundcards found.TCP cubic registeredNET: Registered protocol family 17RPC: Registered udp transport module.RPC: Registered tcp transport module.ieee80211: 802.11 data/management/control stack, git-1.1.13ieee80211: Copyright (C) 2004-2005 Intel Corporation VFP support v0.3: implementor 41 architecture 1 part 10 variant 9 rev 1rtc-pcf8563 3-0051: setting system clock to 2009-09-03 10:09:04 UTC (1251972544)[color="#FF0000"]Freeing init memory: 10296K                                         #占用的内存很大init started: BusyBox v1.11.2 ()starting pid 326, tty '': '/etc/rc.d/rcS'Mounting /proc and /sysSetting the hostname to zlgMounting filesystemsRunning sysctlSetting up networking on loopback device:Setting up networking on eth0:Adding static route for default gateway to 192.168.7.1:Setting nameserver to 192.168.7.1 in /etc/resolv.conf:Starting inetd:Starting the port mapper:starting pid 369, tty '': '-/bin/sh'[root@zlg /]# lsMakefile      etc           init          proc          tmpbin           hello.c       lib           root          usrboot          hello_static  mnt           sbin          vardev           home          opt           sys[root@zlg /]# lsMakefile      etc           init          proc          tmpbin           hello.c       lib           root          usrboot          hello_static  mnt           sbin          vardev           home          opt           sys[root@zlg /]# free                  total         used         free       shared      buffers  Mem:        61328        [color="#FF0000"]44732        16596            0            0 Swap:            0            0            0Total:        61328        44732        16596
                   
                   
                   
                   

    本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/51797/showart_2070568.html
  • 您需要登录后才可以回帖 登录 | 注册

    本版积分规则 发表回复

      

    北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
    未成年举报专区
    中国互联网协会会员  联系我们:huangweiwei@itpub.net
    感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

    清除 Cookies - ChinaUnix - Archiver - WAP - TOP