Busybox与根文件系统的构造
来源:互联网 发布:网易邮箱163 smtp端口 编辑:程序博客网 时间:2024/05/29 19:29
嵌入式linux系统的构成
0 确认交叉编译环境已经设置好,我的为arm-linux-
1 编译安装Busybox
[root@localhost busybox]# cd /root/embed-2010/embedded-xmu/tools/busybox/
[root@localhost busybox]# make menuconfig
// 以下设置是我自己的设置情况,仅供参考
// 详细设置参考 实验文档Lab3[1].linux+内核裁减及文件系统构建.pdf 附录二
Busybox Settings -->
Build Options -->
编译成静态库
跨平台编译 arm-linux-
Coreutils -->
Init Utilities -->
Linux System Utilities -->
Shells -->
保存退出
[root@localhost busybox]# make
[root@localhost busybox]# make install PREFIX=/root/embed-2010/embedded-dev/fs
2 构建根文件系统
[root@localhost busybox]# cd /root/embed-2010/embedded-dev/fs
[root@localhost fs]# ls
bin linuxrc sbin usr
[root@localhost fs]# mkdir etc dev proc tmp lib var sys
[root@localhost fs]# ls
bin dev etc lib linuxrc proc sbin sys tmp usr var
创建设备节点
[root@localhost fs]# cd dev/
[root@localhost dev]# mknod ram0 b 1 0
[root@localhost dev]# mknod console c 5 1
[root@localhost dev]# mknod null c 1 3
[root@localhost dev]# mknod zero c 1 5
NOTE:
摘自:http://linux.about.com/library/cmd/blcmdl1_mknod.htm
mknod - make block or character special files
mknod [OPTION]... NAME TYPE [MAJOR MINOR]
类型 主 次 设备号
b
create a block (buffered) special file
c, u
create a character (unbuffered) special file
mknod console c 5 1
console为设备文件名,自己随便取
c是指字符型设备 (可选b,块设备)
5是主设备号 /dev/devices里面记录现有的设备
找个没有用的就可以了
1是次设备号,当你要给两个同样的设备上一个驱动的时候就要分了,从0开始,1就是第二个了
Definition:
/dev/null: On UNIX, this is a virtual-file that can be written to. Data written to this file gets discarded.
/dev/zero is a special file that provides as many null characters (ASCII NUL, 0x00) as are read from it.
设备文件:对于每种硬件设备,系统内核有相应的设备驱动程序负责对它的处理。而在Unix中,使用设备文件的方式来表示硬件设备,每种设备驱动程序都被抽象为设备文件的形式,这样就给应用程序一个一致的文件界面,方便应用程序和操作系统之间的通信。
[root@localhost dev]# ls
console null ram0 zero
创建inittab P134, inittab 是init程序读取的配置文件。Init是内核启动后运行的第一个程序。
[root@localhost dev]# cd ..
[root@localhost fs]# ls
bin dev etc lib linuxrc proc sbin sys tmp usr var
[root@localhost fs]# cd etc/
[root@localhost etc]# vim inittab
::sysinit:/etc/init.d/rcS # 系统初始化时执行的内容
::askfirst:/bin/ash # 启动shell
建立sysinit(执行指定的程序进行系统初始化)动作项 执行的命令脚本
[root@localhost etc]# mkdir init.d
[root@localhost etc]# vim init.d/rcS
#!/bin/ash
mount -t proc proc/proc
mount -t sysfs sysfs/sys
ifconfig lo 127.0.0.1
ifconfig eth0 192.168.0.100
[root@localhost etc]# chmod +x init.d/rcS
3 创建根文件系统映像文件
[root@localhost etc]# cd ../../
[root@localhost embedded-dev]# ls
fs
[root@localhost embedded-dev]# mkdir initrd
[root@localhost embedded-dev]# cd initrd/
[root@localhost initrd]# dd if=/dev/zero of=initrd bs=1k count=2048
读入了 2048+0 个块
输出了 2048+0 个块
NOTE:这将以1024字节为单位,从/dev/zero读取2048字节的数据null characters (ASCII NUL, 0x00),保存到名字为initrd的文件中,
[root@localhost initrd]# mkfs.ext2 initrd -F
mke2fs 1.32 (09-Nov-2002)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
256 inodes, 2048 blocks
102 blocks (4.98%) reserved for the super user
First data block=1
1 block group
8192 blocks per group, 8192 fragments per group
256 inodes per group
Writing inode tables: done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 22 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
NOTE:
摘自 http://linux.die.net/man/8/mkfs http://linux.die.net/man/8/mkfs.ext2
mkfs - build a Linux file system
In actuality, mkfs is simply a front-end for the various file system builders (mkfs.fstype) available under Linux.
-F
Force mke2fs to run, even if the specified device is not a block special device, or appears to be mounted.
[root@localhost initrd]# mkdir initrd_mnt
[root@localhost initrd]# mount initrd initrd_mnt -o loop
NOTE:
摘自:http://www.csulb.edu/~pnguye11/loopbackDev.html
Loopback Devices in Linux
Purpose
The purpose for using a loopback device is to fake out some piece of software so that you can "mount" a file as a disk and read the filesystem in it; the thing that the loopback device points to does not have to be a separate drive, but it can be a file! Once you mount your blank file, you can store individual files in it, and even copy it to a new volume, instantly filling that volume with the directory tree and all that it contains!
-o
Options are specified with a -o flag followed by a comma separated string of options. Some of these options are only useful when they appear in the /etc/fstab file. The following options apply to any file system that is being mounted (but not every file system actually honors them - e.g., the sync option today has effect only for ext2, ext3, fat, vfat and ufs):
摘自: http://linux.die.net/man/8/mount
the Loop Device
One further possible type is a mount via the loop device. For example, the command
mount /tmp/fdimage /mnt -t msdos -o loop=/dev/loop3,blocksize=1024
will set up the loop device /dev/loop3 to correspond to the file /tmp/fdimage, and then mount this device on /mnt.
This type of mount knows about three options, namely loop, offset and encryption, that are really options to losetup(8). (These options can be used in addition to those specific to the filesystem type.)
If no explicit loop device is mentioned (but just an option '-o loop' is given), then mount will try to find some unused loop device and use that. If you are not so unwise as to make /etc/mtab a symbolic link to /proc/mounts then any loop device allocated by mount will be freed by umount. You can also free a loop device by hand, using 'losetup -d', see losetup(8).
[root@localhost initrd]# cp -a /root/embed-2010/embedded-dev/fs/* initrd_mnt/
[root@localhost initrd]# umount initrd
[root@localhost initrd]# ls
initrd initrd_mnt
4.skyeye上测试根文件系统
[root@localhost skyeyetest]# cp initrd /root/embed-2010/embedded-xmu/skyeyetest/initrd2010
[root@localhost skyeyetest]# cd /root/embed-2010/embedded-xmu/skyeyetest/
[root@localhost skyeyetest]# vim skyeye.conf
mem_bank: map=M, type=RW, addr=0xc1000000, size=0x01000000, file=./initrd2010
[root@localhost skyeyetest]# ./skyeye -e vmlinux-xmu-2010
arch: arm
cpu info: xscale, pxa25x, 69052100, fffffff0, 2
mach info: name pxa_lubbock, mach_init addr 0x807ced0
uart_mod:0, desc_in:, desc_out:
SKYEYE: use xscale mmu ops
Loaded RAM ./initrd2010
exec file "vmlinux-xmu-2010"'s format is elf32-little.
……….
……….
……….
Starting pid 657, console /dev/console: '/etc/init.d/rcS'
Bummer, could not run '/etc/init.d/rcS': No such file or directory
Bummer, could not run '/etc/init.d/rcS': No such file or directory
Please press Enter to activate this console.
Starting pid 658, console /dev/console: '/bin/ash'
BusyBox v1.2.2 (2010.03.27-09:16+0000) Built-in shell (ash)
Enter 'help' for a list of built-in commands.
/bin/ash: can't access tty; job control turned off
# ls
bin lib myspace sys var
dev linuxrc proc tmp
etc lost+found sbin usr
#
内核运行成功,根文件系统基本正确。
Bummer, could not run '/etc/init.d/rcS': No such file or directory
/bin/ash: can't access tty; job control turned off
这两个还不知道怎么解决。
- Busybox与根文件系统的构造
- 使用Busybox构造cramfs根文件系统
- 使用Busybox构造cramfs根文件系统
- 移植Busybox与构建Linux根文件系统
- 移植Busybox与构建根文件系统
- busybox制作根文件系统时的问题
- 基于busybox的根文件系统制作
- 构建根文件系统-busybox的编译
- busybox根文件系统mdev的详解
- BusyBox制作根文件系统
- busybox 基本根文件系统
- busybox构建根文件系统
- busybox 根文件系统制作
- busybox制作根文件系统
- 根文件系统的构建与分析(四)之瑞士军刀busybox生成系统基本命令
- 根文件系统的构建与分析(四)之瑞士军刀busybox生成系统基本命令
- RAM,内核、文件系统、busybox的制作与安装
- busybox文件系统的启动顺序
- 一名平庸程序员的自白
- windows主机的IIS连接数限制,Linux的Apache连接限制,PHP的CPU限制!
- C++程序设计之四书五经
- 嵌入式工程师是怎样炼成的(三)---- 初涉职场
- 思考
- Busybox与根文件系统的构造
- 创建共享连接的封装
- Notes中几个处理多值域的通用函数
- 推荐系统与协作过滤面临的主要问题
- Ad-hoc Test的测试介绍
- 句柄
- 2010年小学生学习全能托管
- MIDlet的生命周期
- 如何升软件开发项目的利润