歡迎您光臨本站 註冊首頁

使用busybox-1.13.3 創建Linux根文件系統(2)

←手機掃碼閱讀     火星人 @ 2014-03-09 , reply:0

  8、創建一個空的mdev.conf文件,在掛載根文件系統時會用到的

  [~etc]# touch mdev.conf

  9、從本機拷貝passwd、shadow、group文件.

  [~ etc]# cp /etc/passwd .

  [~etc]# cp /etc/shadow .

  [~etc]# cp /etc/group .

  修改passwd文件,把第一行和最后一行的bash修改成ash.

  10、把busybox默認安裝目錄中的文件全部複製到這裡的rootfs中.

  會發現多了linuxrc -> bin/busybox文件,這是掛載文件系.

  [~etc]# cd ..

  [~rootfs]# cp -Rfv /opt/develop/lyj/common/porting/rootfs/busybox-1.12.2/_install/* ./

  OK,以上用busybox創建了一個基本的文件系統.

  PS:

  如果編譯busybox時選擇動態庫方式編譯,則需要查看生成的busybox使用哪些動態庫,然後把它們拷貝到rootfs/lib目錄下.

  [~lib]# arm-linux-readelf -d ../bin/busybox

  Dynamic section at offset 0xc1014 contains 21 entries:

  Tag Type Name/Value

  0x00000001 (NEEDED) Shared library: [libm.so.6]

  0x00000001 (NEEDED) Shared library: [libc.so.6]

  0x0000000c (INIT) 0xc2ec

  0x0000000d (FINI) 0xa96b8

  0x00000004 (HASH) 0x80e8

  0x00000005 (STRTAB) 0xa4c4

  0x00000006 (SYMTAB) 0x8b64

  0x0000000a (STRSZ) 3505 (bytes)

  0x0000000b (SYMENT) 16 (bytes)

  0x00000015 (DEBUG) 0x0

  0x00000003 (PLTGOT) 0xd10e4

  0x00000002 (PLTRELSZ) 3112 (bytes)

  0x00000014 (PLTREL) REL

  0x00000017 (JMPREL) 0xb6c4

  0x00000011 (REL) 0xb674

  0x00000012 (RELSZ) 80 (bytes)

  0x00000013 (RELENT) 8 (bytes)

  0x6ffffffe (VERNEED) 0xb5a4

  0x6fffffff (VERNEEDNUM) 2

  0x6ffffff0 (VERSYM) 0xb276

  0x00000000 (NULL) 0x0

  可以看出,使用了libm.so.6和libc.so.6兩個庫.發現只拷貝這兩個庫還不夠,還需要ld-linux.so.2和libgcc_s.so.1,也就是我編譯出來的這個busybox需要4個動態庫文件.

  # cp /opt/crosstools/gcc-3.4.6-glibc-2.3.6/lib/libm.so.6 .

  # cp /opt/crosstools/gcc-3.4.6-glibc-2.3.6/lib/libc.so.6 .

  # cp /opt/crosstools/gcc-3.4.6-glibc-2.3.6/lib/ld-linux.so.2 .

  # cp /opt/crosstools/gcc-3.4.6-glibc-2.3.6/lib/libgcc_s.so.1 .

  這樣,使用動態庫可以節省一半左右的空間,不過效率有所降低.

  準備鏈接庫

  #cd ${OBJ_LIB}/lib (${OBJ_LIB}是交叉編譯環境的目錄)

  #for file in libc libcrypt libdl libm

  >libpthread libresolv libutil

  >do

  >cp $file-*.so /home/fortis/rootfs/lib

  >cp -d $file.so.[*0-9] /home/fortis/rootfs/lib

  >done

  #cp -d ld*.so* /home/fortis/rootfs/lib

  11.測試

  1)、在本機修改/etc/export文件,重啟NFS服務:

  [root@vm-dev root]# vi /etc/exports

  /opt/lyj 192.168.1.*(rw,insecure,sync,no_root_squash)

  /opt/develop/lyj/common/porting/rootfs/root_stand/reset/rootfs 192.168.1.*(rw,insecure,sync,no_root_squash)

  [root@vm-dev root]# service nfs restart

  2)、在Bootloader中傳遞以下參數給Kernel:

  root=/dev/nfs rw nfsroot=192.168.1.152:/opt/develop/lyj/common/porting/rootfs/root_stand/reset/rootfs ip=192.168.1.155:192.168.1.152:192.168.1.254:255.255.255.0:Jacky:eth0:off console=ttySAC0,115200 init=/linuxrc noinitrd

  3)、啟動目標板,串口輸出顯示根文件系統已經載入成功:

  U-Boot 1.3.2 (Nov 27 2016 - 17:43:03)

  DRAM: 64 MB

  Flash: 512 kB

  NAND: 64 MiB

  In: serial

  Out: serial

  Err: serial

  Found DM9000 ID:90000a46 at address 10000000 !

  DM9000 work in 16 bus width

  bd->bi_entaddr: 08:00:3e:26:0a:5b

  [eth_init]MAC:8:0:3e:26:a:5b:

  Hit any key to stop autoboot: 0

  NAND read: device 0 offset 0x80000, size 0x1b0000

  1769472 bytes read: OK

  ## Booting image at 30008000 ...

  Image Name: Linux-2.6.24.4

  Created: 2016-11-27 7:24:11 UTC

  Image Type: arm Linux Kernel Image (uncompressed)

  Data Size: 1697964 Bytes = 1.6 MB

  Load Address: 30008000

  Entry Point: 30008040

  Verifying Checksum ... OK

  test:hdr->ih_type:2

  test:hdr->ih_comp:0

  XIP Kernel Image ... OK

  test:hdr->ih_type:2

  test:hdr->ih_os:5

  Starting kernel ...

  test:machid:805306624

  test: bi_boot_params:0x33f5bfb8

  test:starting 1

  Uncompressing Linux............................................................................................................ done, booting the kernel.

  Linux version 2.6.24.4 (root@vm-dev) (gcc version 3.4.6) #94 Thu Nov 27 10:02:26 CST 2008

  CPU: ARM920T [41129200] revision 0 (armv4T), cr=00007177

  Machine: SMDK2410

  Memory policy: ECC disabled, Data cache writeback

  CPU S3C2410A (id 0x32410002)

  S3C2410: core 202.800 MHz, memory 101.400 MHz, peripheral 50.700 MHz

  S3C24XX Clocks, (c) 2004 Simtec Electronics

  CLOCK: Slow mode (1.500 MHz), fast, MPLL on, UPLL on

  CPU0: D VIVT write-back cache

  CPU0: I cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

  CPU0: D cache: 16384 bytes, associativity 64, 32 byte lines, 8 sets

  Built 1 zonelists in Zone order, mobility grouping on. Total pages: 16256

  Kernel command line: root=/dev/nfs rw nfsroot=192.168.1.152:/opt/develop/lyj/common/porting/rootfs/root_stand/reset/rootfs ip=192.168.1.155:192.168.1.152:192.168.1.254:255.255.255.0:Jacky:eth0:off console=ttySAC0,115200 init=/linuxrc noinitrd

  irq: clearing subpending status 00000002

  PID hash table entries: 256 (order: 8, 1024 bytes)

  timer tcon=00500000, tcnt a509, tcfg 00000200,00000000, usec 00001e4c

  Console: colour dummy device 80x30

  console [ttySAC0] enabled

  Dentry cache hash table entries: 8192 (order: 3, 32768 bytes)

  Inode-cache hash table entries: 4096 (order: 2, 16384 bytes)

  Memory: 64MB = 64MB total

  Memory: 61324KB available (3088K code, 316K data, 132K init)

  Mount-cache hash table entries: 512

  CPU: Testing write buffer coherency: ok

  net_namespace: 64 bytes

  NET: Registered protocol family 16

  S3C2410 Power Management, (c) 2004 Simtec Electronics

  S3C2410: Initialising architecture

  S3C24XX DMA Driver, (c) 2003-2004,2006 Simtec Electronics

  DMA channel 0 at c4800000, irq 33

  DMA channel 1 at c4800040, irq 34

  DMA channel 2 at c4800080, irq 35

  DMA channel 3 at c48000c0, irq 36

  SCSI subsystem initialized

  usbcore: registered new interface driver usbfs

  usbcore: registered new interface driver hub

  usbcore: registered new device driver usb

  NET: Registered protocol family 2

  IP 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 registered

  NetWinder Floating Point Emulator V0.97 (double precision)

  yaffs Nov 27 2008 09:58:27 Installing.

  io scheduler noop registered

  io scheduler anticipatory registered (default)

  io scheduler deadline registered

  io scheduler cfq registered

  Console: switching to colour frame buffer device 80x30

  fb0: s3c2410fb frame buffer device

  lp: driver loaded but no devices found

  ppdev: user-space parallel port driver

  Serial: 8250/16550 driver $Revision: 1.90 $ 4 ports, IRQ sharing enabled

  s3c2410-uart.0: s3c2410_serial0 at MMIO 0x50000000 (irq = 70) is a S3C2410

  s3c2410-uart.1: s3c2410_serial1 at MMIO 0x50004000 (irq = 73) is a S3C2410

  s3c2410-uart.2: s3c2410_serial2 at MMIO 0x50008000 (irq = 76) is a S3C2410

  RAMDISK driver initialized: 16 RAM disks of 4096K size 1024 blocksize

  loop: module loaded

  DM9000: dm9k_init_module

  Board init for dm9000a finished!

  <DM9KS> I/O: c480e000, VID: 90000a46

  eth0: at 0xc480e000 IRQ 18

  eth0: Ethernet addr: 08:00:3e:26:0a:5b

  Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2

  ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx

  Driver 'sd' needs updating - please use bus_type methods

  S3C24XX NAND Driver, (c) 2004 Simtec Electronics

  s3c2410-nand s3c2410-nand: Tacls=3, 29ns Twrph0=7 69ns, Twrph1=3 29ns

  NAND device: Manufacturer ID: 0xec, Chip ID: 0x76 (Samsung NAND 64MiB 3,3V 8-bit)

  NAND_ECC_NONE selected by board driver. This is not recommended !!

  Scanning device for bad blocks

  Creating 4 MTD partitions on "NAND 64MiB 3,3V 8-bit":

  0x00000000-0x00080000 : "Boot Agent"

  0x00080000-0x00280000 : "S3C2410 kernel"

  0x00280000-0x00680000 : "S3C2410 rootfs"

  0x00680000-0x04000000 : "user"

  usbmon: debugfs is not available

  116x: driver isp116x-hcd, 03 Nov 2005

  s3c2410-ohci s3c2410-ohci: S3C24XX OHCI

  s3c2410-ohci s3c2410-ohci: new USB bus registered, assigned bus number 1

  s3c2410-ohci s3c2410-ohci: irq 42, io mem 0x49000000

  usb usb1: configuration #1 chosen from 1 choice

  hub 1-0:1.0: USB hub found

  hub 1-0:1.0: 2 ports detected

  Initializing USB Mass Storage driver...

  usbcore: registered new interface driver usb-storage

  USB Mass Storage support registered.

  mice: PS/2 mouse device common for all mice

  s3c2410 TouchScreen successfully loaded

  input: s3c2410 TouchScreen as /class/input/input0

  S3C24XX RTC, (c) 2004,2006 Simtec Electronics

  s3c2410-rtc s3c2410-rtc: rtc disabled, re-enabling

  s3c2410-rtc s3c2410-rtc: rtc core: registered s3c as rtc0

  i2c /dev entries driver

  s3c2410-i2c s3c2410-i2c: slave address 0x10

  s3c2410-i2c s3c2410-i2c: bus frequency set to 99 KHz

  s3c2410-i2c s3c2410-i2c: i2c-0: S3C I2C adapter

  S3C2410 Watchdog Timer, (c) 2004 Simtec Electronics

  s3c2410-wdt s3c2410-wdt: watchdog inactive, reset disabled, irq enabled

  TCP cubic registered

  NET: Registered protocol family 1

  RPC: Registered udp transport module.

  RPC: Registered tcp transport module.

  s3c2410-rtc s3c2410-rtc: hctosys: invalid date/time

  IP-Config: Complete:

  device=eth0, addr=192.168.1.155, mask=255.255.255.0, gw=192.168.1.254,

  host=Jacky, domain=, nis-domain=(none),

  bootserver=192.168.1.152, rootserver=192.168.1.152, rootpath=

  Looking up port of RPC 100003/2 on 192.168.1.152

  Looking up port of RPC 100005/1 on 192.168.1.152

  VFS: Mounted root (nfs filesystem).

  Freeing init memory: 132K

  init started: BusyBox v1.12.2 (2016-11-27 14:55:55 CST)

  starting pid 785, tty '': '/etc/init.d/rcS'

  Processing etc/init.d/rc.S

  Mount all

  Start mdev....

  ****************************************************

  rootfs by NFS, s3c2410

  Created by lyj_uptech @ 2008.11.28

  Good Luck

  www.up-tech.com

  ****************************************************

  Please press Enter to activate this console.

  starting pid 790, tty '': '-/bin/sh'

  Processing /etc/profile... Done

  Processing /etc/profile

  Set search library path

  Set user path

  Set PS1

  All done!

  [root@up-tech /]# ls

  bin dev home linuxrc proc sbin tmp var

  boot etc lib mnt root sys usr

  [root@up-tech /]#

  已經直接進入了nfs文件系統!

  本文來自CSDN博客,轉載請標明出處:http://blog.csdn.net/itismine/archive/2009/11/05/4772284.aspx


[火星人 ] 使用busybox-1.13.3 創建Linux根文件系統(2)已經有490次圍觀

http://coctec.com/docs/linux/show-post-52038.html