个人主页https://xugaoxiang.com,微信公众号: Dev_Club 或者搜索 程序员Club
全部博文(229)
分类: LINUX
2009-12-25 11:26:29
The BIOS loads the MBR (Master Boot Record) from CD into memory and executes it. The place on the CD where the BIOS looks for the MBR is determined by the ISO9660 standard. Generally speaking the boot loader software provides the binary code for the MBR. This is usually written is assember as it runs in Real mode. In this mode your pc still thinks it's a 286 with only 640k of memory. Once the kernel is booted, the system switches into protected mode where it can address its memory properly using 32 bit addressing, and run to it's full potential (helped by linux of course).
ISOLinux is the bootloader used when GeeXboX boots from CD. In the ISOLinux configuration (/GEEXBOX/boot/isolinux.cfg) the important parameters are the path to the kernel (vmlinuz), the path to the root file system (initrd.gz) and the file system type (ramfs). Here is where the file system wrappers start to play a part.
The kernel is loaded and uncompressed into memory. The bootloader knows how to uncompress the gzip format of the root file system (initrd.gz) and uncompresses that into memory and mounts it. At this point we can say we have an operating system that can do something useful. As we will see, there is a lot of functionality here already.
Once the initial file system is mounted, the kernel hands control to a user program. We say we are in user space from now on. In our case the command that is run is:
/bin/sh /linuxrc
This looks simple, but there is quite a lot happening here. The initrd contains a symlink for /bin/sh that sends control to /bin/busybox.
Busybox is the swiss army coat hanger of embedded linux and a very powerful tool. It can be compiled to contain any of a long list of standard GNU programs. When invoked, it examines the command used and responds as if it was that command. Eg:
/bin/busybox tar xzf somefile.tar.gz
This will cause busybox to act just like GNU tar and uncompress the specified file. This is why it is called a Multi call binary, it can be called by many names and takes on the role of whatever you call it.
The busybox present in the initrd is quite simplified and it only knows the commands needed to perform the bootstrapping required to get the main file system mounted. It does not know ls, for example, and is not realy suitable for interactive use unless you really know what you are doing. In general this stage will pass transparently as the system boots.
Linuxrc is a shell script that contains the first real user-space logic we have encountered so far. It's job is to deal with the devices that the kernel has discovered, in a sensible way, and to mount the main file system.
To run through quickly what linuxrc does:
This is a compressed file system. Basically a tar archive with extra-good compression on it. As it expandes it creates files and directories as necessary. In this file system are all the important binaries and shared libraries needed to use the hardware of your computer. A very wide range of hardware is able to be used. This file system also contains a number of scripts that provide interfaces to various functions like: tvon, tvoff. This way the software is more modular. If you are interested in customising your GeeXboX for specific hardware, this is where your hardware libraries and binary drivers will be stored.
linuxrc continues...
We are now at stage II of the bootstrapping and things start to look
more like a "normal" linux boot process. Amoung other things, init
starts to run the scripts in /GEEXBOX/etc/init.d, very much like a
debian style linux.
三、在双系统(winXP+ubuntu9.04)安装运行GeeXbox
1、准备磁盘分区
我这里是sda7,格式化分区
mkfs.ext3 /dev/sda7
文件系统最好是FAT16、FAT32、NTFS或EXT*
mount /dev/sda7 /media
2、下载GeeXboX ISO
mount -o loop geexbox-1.2.3-custom-zh_CN.i386.iso /mnt
cd /mnt
3、拷贝整个文件夹GEEXBOX
cp -rf * /media
4、vi /boot/grub.menu.lst
增加如下语句
title GeeXboX
root (hd0,6)
kernel /GEEXBOX/boot/vmlinuz root=/dev/ram0 rw rdinit=linuxrc boot=UUID=$my_uuid lang=en keymap=qwerty splash ...
initrd /GEEXBOX/boot/initrd.gz
quiet
5、reboot
重启后在GRUB中就可以看到GeeXboX这个启动选项了。
四、添加软件包(译)
什么是GeeXboX软件包
软
件包是GeeXboX发行版的一个组成部分。它可以以库、驱动甚至是软件的形式存在。在GeeXboX代码结构中,它是SHELL的集合,利用
GeeXboX自己的工具链来编译,安装并打上相应的补丁,最后最加入到ISO文件中。工具链支持软件包的依赖关系,这就意味着你可以自己去定义这样的依
赖关系。每个新的软件包都必须放在代码的packages目录下。
包定义文件
以下是工具链用到的简单包定义文件列表:
-unpack:这个文件定义了当软件包被解开之后要做的动作,通常是对配置文件进行的操作,这个文件是可选的。
-build:这个文件的作用是如何编译这个软件包。通常是带参数的./configure和make操作。
-install:这个文件定义了如何将编译文件加到ISO文件中。通常仅仅是将编译出的二进制文件和配置文件拷贝到ISO文件中的正确位置。
请注意这三个文件都必须要有可执行的属性。
每
当上述文件之一被成功执行后,build.arch/.stamps/package/就会产生一个文件,当此文件执行完毕而又被另一脚本文件调用,则被
调用的文件仅执行一次。如unpack执行后,再执行build,而build里调用了unpack,则unpack仅会被执行一次。
为了用户测试的方便,可以手动执行上述这些脚本文件:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|