Babylinux manufacturing process detailed

xiaoxiao2021-03-06  45

Babylinux manufacturing process detailed

BabyLinux explain the production process of: GuCuiwen email: win2linux @

163.COM copyright statement: This document can be reprinted in a non-commercial range on the network, please indicate if the reprinted layout contains commercial advertisements, please pay the author to the author's draft fee for a written, book form And publishing, please pay the author to the author, what is Babylinux, why do you want to read this document? I have to read this document. I have the knowledge of the document. I should have five, Linux system boot Introduction to the process, compile the kernel seven, compile BUSYBOX 8, make root file system nine, make RAMDISK image file ten, the core and busybox integration eleven, installation test and content adjustment twelve, Babylinux bugs BUG 13, next Things to do fourteen, reference 1, what is Babylinuxbabylinux is not a complete release, he uses the original set of complete Linux system, the original code and compilation tools, using the powerful features built by BusyBox, A small Linux system on a floppy disk. He has the basic characteristics of a Linux system, supporting the most commonly used commands in Linux systems, supporting multiple file systems, supporting networks, etc., you can do him One Linux boot disk and repair disk, you can also use the router software of him as a static route, of course, you can also show him as a Linux toy, how small it is to show off Linux to your friends. I put He is called Babylinux because he is very small, small is very cute, like a small Baby just born. I have to make such a Linux first talking about my thoughts. When I first touched Linux, I saw the book. Below, Linux usually needs only a space of about 60m, but I found that Redhat 6.0 installed on my hard drive is to occupy a few hundred m space. Why is my Linux so big? Later I found it, put it in my machine So many things only less than 30% is I usually use, and 30% is very useful, and the other 40% is basically not. So, I am like most beginners, start complaining Why can't Linux are unable to do?

So, I sprout my own idea. Unfortunately, I haven't heard of LFS and Debain. After I have accumulated enough Linux knowledge, I started to make such a small system. Make such a small system Significance is that you can learn about the LINUX startup process by making a system, learn RamDisk's use, let you learn more Linux knowledge in a short time. Of course, you will have a lot of fun. This project is just a basic Characteristic Linux system, if you want to be a full-featureful Linux, please read the Linux from Scratch (LFS) document. Third, what person is suitable for reading this document If you are a Linux fan, and I want to know Linux The basic structure of the startup process and the system, and it is a person who likes to work. Then, this document can meet your needs. If you just use Linux to do some ordinary daily work, not how your Linux works? Then this document may not be very suitable for you. In addition, if you are Linux enthusiasts, but is still a newbi just started, I suggest you learn the Linux command first. But I think I will use this document as much as possible. Write detailed, if you have enough perseverance, perhaps a newbi can also make a babylinux. Or, you encounter a very unfortunate thing, such as your wife is a holiday, your weekend will bubble, Then read this document and do a Linux small toys to send your time. I should have the knowledge you should have to use Linux's most common command before doing Babylinux. And at least once successfully compiled and install the system kernel. The experience will be installed by compiling the source code. If you have these conditions, then a small system will be smooth, if you haven't mastered these knowledge, you may have some difficulties. But as long as you have perseverance, You can also succeed. You don't need to have a programming knowledge, because my goal is to make this item with a medium or more Linux level can easily complete this project. There is also a very famous Linux on a floppy disk. Call LOAP (Linux on A Flopp) But he is made by a more professional staff to prepare a lot of programs to do. And there is no documentation on his production process. Five, Linux system guidance process introduction First, the motherboard's BIOS will read the hard disk Guide Record (MBR), MBR is stored in a small program, his function is to read the operating system core file from the hard disk and run because this applet is too small, so usually this applet does not have a direct boot system. The ability of the kernel, he first guides another slightly a little applet, and then boots the system kernel by this big small program. In the Linux system Such a small program has LILO and GRUB. In this project, I decided to use LILO to do system bootstrap. Start the Linux system on the floppy disk and the process of starting on the hard disk. LINUX system kernel is booted to load the kernel After running, the Linux core will detect the various hardware in the system. And do a good job in the initialization of various hardware, so that they can work normally after the system is officially run. The last job made by the kernel is to run / sbin under init. Program, init is the referred to as the English word initialization (initialization), the initial work is to read the instructions described in the / etc / inittab file, which is the initiation setting for the various hardware and software environments of the system. Finally running MINGETTY Waiting for user input Username login system. All work is so simple, although there are many contents when Linux started, it seems very high, but it is the expansion of this process. I understand this truth, you can write some script let him The specific time of the system starts to run the task. In fact, the system kernel does not care about the init is true in / sbin, as long as it is placed under / sbin named init, he can do it. You can do the following experiment : Writing a very simple C program: main () {printf ("Hello, World! / N");} Save him with init.c after saving, and compile with GCC. # Gcc --static -o init init.c The --static parameter tells GCC to connect this program static, so this program can run without relying on any library. Copy the compiled init program to / sbin, back up the original one. Restart the system's last system The result is: Hello, World! Then stop there. Before doing this experiment, make sure you know how to restore the system to its original state, there is a simple method, give him in head before the kernel starts.

Parameters, such as your original init by you into init.bak, just add init = / sbin / init.bak when starting, you can start the system with the original init program. After doing the above experiment, you will understand The relationship between the kernel and the init program. In addition, the init program is not necessarily a binary executable, he can be a Bash script, a join point to another program, his location is not necessarily in / sbin, As long as you start the kernel, add the init parameter to the kernel to be run, for example, add the init = / bash parameter to the kernel, the kernel is directly running the BASH directly, and does not have to log in to the system. You can enter the command. It features a single user mode startup system. / Sbin / init program is just the first program that is running by the kernel. Six, build a Linux system core 1, before compiling planning and prepare before compiling the kernel, please First determine your needs, list your needs to a detailed form. Do you need to make the kernel to support what hardware, support how many partition types and file systems, which network cards are supported, and more, please. Please do it in detail The contents of the columns, but you don't want too much, because all the space you can use is only 1440K, if you compile a kernel greater than 1440K or close this number, your project can't complete, you have no space. Put the ramdisk image file, unless you have a floppy disk, make a small Linux system for two floppy disks. For the sound card driver, I advise you to give up, because a sound card driver may only make your kernel Increased more than ten K, but you have a sound card driver to have a player, otherwise the sound card driver is meaningless, but the size of a player is not a floppy disk can be installed. On my previous The fabxylinux kernel made of Babylinux has more than 900 K, of which some of the file system stands most, because my goal is to make him a system repair disk. So I compiled 7 file systems in the kernel, each reduced one file The system can reduce the kernel size of several tens or even 200 K. More complex, the more secure file system, the larger the support module, such as only 32K in Linux, only 17K, but the module of EXT3 There are 86K, JFS reached 216K, the Reiserfs module is 224K, you can imagine, compile a 900 K kernel supporting 7 file systems, the file system part accounts for more than 600K, so if a file system is you fundamentally No, then don't compile into the kernel, this can save at least 100 K space. For other drivers, such as NIC, usually only 8,9k, the maximum is more than 10 K, so you can use common The drive of the network card chip is compiled. If you want your babylinux to support the U disk, the SCSI driver module is not small, he usually be close to 150K, because the U disk is driven by the SCSI device. In addition, you still need to let your kernel support Plug and play, these are not small space overhead, my suggestion is that you give up one or two file systems you don't have to use. In short, your last compiled kernel size is best not to exceed 900K, otherwise you can only in busybox Compiling very little commands. In my compile Busybox, I compile to more than 120 commands, basically include the commands supported by BusyBox into it. Plus the file system directory necessary for the small system, / dev equipment under / dev Document, and several required configuration files under / etc, the size of the RAMDisk compressed is more than 440 K, plus the kernel of 900K, just can put a 1440K floppy disk, please note that you should leave at least 50K Space, because we have to create an EXT2 file system on a floppy disk, and the file system life needs to occupy a probably 25K disk space. In addition, the size of the boot file boot.b is 5.7K, and it is automatically generated after LILO. The MAP file also has more than 10 K, the specific size of the MAP file is determined by the actual size of the kernel installation, usually does not exceed 30k. In summary, please follow the formula below: Nuclear size file system compressed impression file 50K <=

1440K Another point to explain: The above-listed file system module size is to see the module files under the RedHat 9 I use now, the actual compiled into the kernel size will be small, because we use make bzimage The kernel generated under the internal nuclear source code directory tree is compressed. If you don't know much about the above content, I will do a detailed explanation in the following content. 2, you must compile the contents of the kernel First of all, this small system we make is based on a floppy disk. Therefore, your kernel must support the floppy disk. In addition, support for IDE hard drives and CDROM is also indispensable, otherwise the Babylinux that has been made does not have practical value, because he can't Accessing the content on the hard disk and the disc can do smaller, but manufacturing a completely useless thing is a waste time. Other FrameBuffer, etc. If you need to support high resolution in the character interface, Seeing more screen content, then you must support the FrameBuffer to compile into the kernel, and 8x8 fonts used under high resolution also need to be compiled. Otherwise, even if you pass the VGA = parameter, the kernel will be available because there is no available. The small font is automatically jumped into low-resolution mode. This is the thing that I can't think about it in a few days. Later, I learned that it was the style of the font. Here, I will take care of what I need to pay attention to. When compiled in the next section, I will continue to explain some of the details .3, the version of the kernel I am built under the Redhat 9 Linux system. Used the 2.4.20 version of the redhat 9 comes with the REDHAT 9 The kernel. Why don't I use the latest 2.6 kernel? I also started with the latest kernel, but I found that I found an all-no in the case of the latest 2.6.9 kernel, I compiled an all-NO (ie all The content is selected n, do not support any hardware, only one of the most basic kernels) minimize the kernel to 460K, if I add several file systems and necessary drivers on this, then the size of the kernel cannot be installed A 1440K floppy disk, and I use the 2.4.20 kernel to compile a minimized kernel only need 217K. If you optimize the GCC parameter, he can also be some more. In this way, I will immediately save more than 200 K. Space, in the usual, more than 200 K is insignificant, but in Babylinux, this number is 1/7 of the entire space, which is equivalent to a REISERFS file system module size. Of course, I also tried 2.2 and older kernels. But they lack what I need, so I finally trade out the core of 2.4. If you use the 2.6 kernel's FC system, it is best to download a 2.4 version of the kernel, WWW. Kernel.org has a variety of kernels to download .4, kernel configuration If you are very familiar with the configuration and compilation of the Linux kernel, please skip this paragraph, directly look at BusyBox compilation. Log in to the system to enter / usr / src / linux directory [root @ gucuiwen root] # CD / usr / src / linux If you download a 2.4 version of the kernel, in order to avoid trouble, please copy him under / usr / src, then pick up, then do A link pointing to his name is Linux. Although this is not required, based on my past experience, if I put the Linux source code in other directories to unlock and compile, there will be some inexplicable small problems. #CP Linux-2.4.20.bz2 / usr / src / # CD / USR / SRC # tar xfvj Linux-2.4.20.bz2 If it is tar.gz format, you can unlock #TAR XFVZ Linux-2.4.20. Tar.gz For convenience, be a connection to the directory Linux-2.4.20: #LN -s Linux-2.4.20 Linux Enter Linux Source Chat Directory: #CD Linux Clean Source Code Tree: #make MRPROPER Run Configuration:

#make xconfigcode maturity level options first select N, when we configure regular things, add this to FrameBuffer to support this, because in 2.4.20, FrameBuffer support is still experimental code. If not in Code Maturity Level Options Select Y, FrameBuffer.Loadable Module Support Select N, in order to simplify the system's production, I don't choose to load the kernel module in this project. Processor Type and FeatureSprocessor Family Select the CPU type you need. If you want old to 386, new to P4's CPU can run babaylinux, please select 386CPU, otherwise, please choose to choose your own actual situation. Other options Select N. These are not needed in Babylinux .General SetupNetworking Support Choose Y PCI Support Select Y Unless you don't have to use a PCI device, it is needed, because now the network card is mostly PCI. System V IPC Select YSYSTRL Support Select Ykernel Support for ELF Select Y the rest of the content can be selected, if there is Special needs, such as the network card is ISA, then select the corresponding content. But can't be greedy, always keep in mind, the space we can use is only 1440K, the size of the kernel cannot exceed 900K, any unnecessary things should be from removing the core contents of all .memory technology devices (MTD) Parallel port three major items in the above supportPlug and Play configuration selection Nblock devicesNormal floppy disk supportLoopback device support RAM disk support initial RAM disk (initrd) support Per partition statics in / proc / Several choice Y, the rest of the options N. The options here are important, I want to focus on explaining. For the support of the floppy disk, it is not necessary, it is a must .loopback device is looping equipment, we usually use Command # mount -o loop somecd.iso / mnt / cdrom hanging light The disk image file, or other file system image file, use the loopback module in the kernel. If you do not compile this module, you will not be able to use the above command to mount the disc image and the file system image. Personally think this The function is very important, so compiled into it. Lam Disk support is a memory disk (more appropriately is a virtual disk, that is, all of the memory is used as a disk). This is the core content of the Babylinux project, due to a floppy disk The space is limited, Babylinux's root file system is highly compressed with Gzip compression, when the decompressed file is copied to a RAM DISK, so you are actually in the root file system. It is done on memory. But in the form and running on a real disk. Only all content placed on the RAM DISK will disappear after the system is turned off. Not only is RamDisk when running Babylinux, we are Use RamDisk when making compressed root file systems, learning Ramdisk's use is one of the important purposes of Babylinux. In Linux, another virtual disk is also supported, called SHM, this virtual The disk mechanism is more advanced than RAMDisk, and the size of RAMDisk is fixed. The default Ram Disk size is determined by compiled kernel. The default is 4096K (4M), or it can be added to RAMDISK_SIZE = before the kernel is loaded.

The parameter determines his size, but once the system starts, the size of the RAMDisk cannot be changed, while the size of the SHM changes. By default, it is half the physical memory. When the system needs more memory, he will automatically Reduce. When the system memory is surplus, he automatically increases, so it can fully flexibly use memory space, SHM is usually used as a system's disk cache, and the temporary file in the system run. Reedaht Linux is available by default. SHM support, you can use Mount and DF to look at his flushing point and size, as follows: [root @ gucuiwen linux] # mount / dev / hda1 on / type ext3 (rw) None ON / PROC TYPE PROC (RW) USBDEVFS ON / proc / bus / usb type USBDEVFS (RW) None ON / DEV / PTS TYPE DEVPTS (RW, GID = 5, MODE = 620) / DEV / HDA6 ON / HOME TYPE EXT3 (RW) / DEV / HDA5 ON / ORACLE TYPE EXT3 (RW) None ON / DEV / SHM TYPE TMPFS (RW) / DEV / HDA7 ON / VAR TYPE EXT3 (RW) [root @

Gucuiwen Linux] # DF -H file system capacity has been used with available% mount point / DEV / HDA1 2.9G 2.7G 26M 100% // dev / hda6 3.8G 1.8G 1.8G 50% / Home / dev / hda5 5.7 G 677M 4.8G 13% / ORACLENONE 125M 0 125M 0% / dev / shm / dev / hda7 711m 91m 584m 14% / var Although SHM has so many advantages, I still chose Ramdisk because ramdisk can be convenient in the system Loading, while SHM is not so easy, let's talk about the related content of the RAMDisk image when the kernel is started. Initial Ram Disk (Initrd) Support is initialized RAMDisk support, this option makes the kernel capacity to load in kernel loading The stage can be loaded into ramdisk and run the content, otherwise it can only be used in the system running stage. We usually compile a new kernel. If your root file system is used, you did not compile EXT3 Enter the kernel, but only as a module, you need to use the mkinitrd command to be used as an initrd (Initialization RamDisk), this RamDisk puts the EXT3 module, which can correctly identify the EXT3 file system before loading the root file system. Otherwise, the last step of the kernel will appear errors in the Kernel Panic Cant Not Find Init .... In the Babylinux project, this option is required, the role is to load the decompressed root file system image to ramdisk. Per Partition Statics IN / Proc / Partitions This option is not required, but I found that if I don't compile this function into the kernel, then when I am playing the file system, there will be some small problems when I don't put the file system, such as I can't hool. The command is to mount the file system. I am not sure is the relationship between this option, but compiling this option into the kernel and only increases a little kernel space, so in order to avoid trouble, I compile him in. Multi-Device Support RAID AND LVM) Cryptography Support (CRYPTOAPI) These two big items all select N, because in the PC in PC, and less involve these two items, if you really have a RAID device or LVM, then you will find it. Bar .Networking Options, only need to put the following items Compile into the kernel: Packet Socket: Mmapped Iotcp / IP NetWorking For IP: Advanced Router, if you want to focus on using Babylinux to do static routing software, then this compile in, and for Network Packet Filtering (Replace Ipchains) One, there is no need to compile it, because Busybox does not provide iptables tools to set pack filtration firewalls. Similarly, UNIX Domain sockets don't have to choose, only if you run x, you need to select this .Telephony Support Select Nata / IDE / MFM / RLL Support Select Y, then the following 'IDE, ATA and ATAPI block devices'

The button is activated as a few items, please select Y, the rest can be n.enhanced IDE / MFM / RLL Disk / CDROM / TAPE / FLOPPORTINCLUDE IDE / ATA-2 Disk SupportAuto-Geometry Resizing SupportInclude IDE / ATA CDROM Support If you The kernel should be run on a very old Pentium or 486, please compile the CMD640 ChipFix / Support, because the motherboard's CMD640 IDE control chip has many inexplicable bugs, and fix this bug. Bush. Several big items: SCSI SupportFusion Mpt Device Supportie 1394 (firewire) SUPPORTI2O Device Support All Select n, here you have a good thing, such as 1394 interface driver, but in babylinux is not big, and our space is only 1440K The following big item: NetWork Device Support Select Y, so you can support the NT card, the rest of you choose N. Then the point Ethernet (10 or 100 mbit) button selections you need the network card driver, you can put the most common reelk8139 NE2000, 3COM and other network cards compiled into the kernel. Although the driver of the network card is usually very small, don't be too greedy, choose 2 ~ 3, it is enough, otherwise your kernel will take a few tens of K. I have previously In the compiled Babylinux kernel, I compiled the Via-Rhine network card, because I creating the Babylinux machine only has a network card of the chip. If you find that the network card you need is gray, you can't, then make sure him first The first-level option is already, for example, you want to choose the NE2000 network card, you must first select ELSA, VLB, PCI and On Board Controllers. If you can't, please make sure you have selected the PCI's support option, ( In Geneal Setup. Without PCI support, PCI's network card will not be able to choose. Maybe you are a rich man, use Gigabit network card on your own PC, then please choose in the Gigabit Net card. Next Big Up: Amateur Radio Supportirda (Infrared) Supportisdn Subsystemold CD-ROM Drivers (NOT SCSI, Not IDE) Input Core Support Department Select N. The next Charcter Devices is an important one. He is as important as BloAck Devices, I will focus on the details. In addition to the Virtual Terminal and Support for Console on Terminal, other all-in-one N.Virtual Terminal is a virtual terminal This is a general linux necessary option. Otherwise, after you start, you can't see anything on the screen. It is also responsible for keyboard input information. Only don't this option in some embedded Linux applications, because of these Linux usually does not have to operate. Support for console on Terminal on the console on the virtual terminal. He supports the output of various information on the terminal, which is also necessary. Next few big items: MultiMedia Devices Crypto Hardware Support Choose N. The part of the file, which is next, can be a heavy action. This part doesn't have to be too much to be too arrogant, what you need to support, but there are three things that you must choose: / proc file system support is missing He, many commands and software can not run. Seconded Fs Support Babylinux basic file system. ISO 9660 CDROM FileSytem Support Unless you don't want to use CD. In addition, Quota Support, Reiserfs Debug Mode (Enable Reiserfs Debug Mode If you don't compile it, you don't have to compile it. These things are not significant, and if you don't have endless kernel size. Please keep in mind that the compiled kernel size should not exceed 900K.tip:

Is it very tired? I wrote more tired, don't worry, the kernel configuration section is better. The last console driver is the kernel module that supports Linux high resolution display in character mode. Years Years Y The Frame-Buffer Suppirl button is a gray unable to choose, don't worry, go back to the first big option: Code Maturity Level Options Select Y, you can activate this button. The following options need to choose Y: Support for FrameBuffer Devices VESA VGA Graphics Console You can also choose other graphics drivers, such as NVIDIA, but VESA and VGA are the best versatility, as long as it is not a black and white video card decades (I only have heard, I have never seen it), it is compatible. VESA and VGA, so, in order to make good Babylinux versatility, select this driver. Support Only 8 Pixels Wide Fonts must be selected, do you pass VGA = 788 parameters to the kernel, let Linux high resolution under the character interface When the rate is displayed, the system will return to the low resolution mode because of the appropriate small font. Ok! All the kernels are all completed here, and the remaining big items are selected. After saving, the configuration program will automatically generate a hidden profile. The following is the content I configured .config file content. If you are lazy you go to configure, then you copy this .config to your source code directory can be directly used. (already removed the comment lines beginning with #) CONFIG_X86 = yCONFIG_UID16 = yCONFIG_EXPERIMENTAL = yCONFIG_M586 = yCONFIG_X86_WP_WORKS_OK = yCONFIG_X86_INVLPG = yCONFIG_X86_CMPXCHG = yCONFIG_X86_XADD = yCONFIG_X86_BSWAP = yCONFIG_X86_POPAD_OK = yCONFIG_RWSEM_XCHGADD_ALGORITHM = yCONFIG_X86_L1_CACHE_SHIFT = 5CONFIG_X86_USE_STRING_486 = yCONFIG_X86_ALIGNMENT_16 = yCONFIG_X86_PPRO_FENCE = yCONFIG_NOHIGHMEM = yCONFIG_NET = Yconfig_PCI = YCONFIG_PCI_GODIRECT = YCONFIG_PCI_DIRECT = YCONFIG _SYSVIPC = yCONFIG_SYSCTL = yCONFIG_KCORE_ELF = yCONFIG_BINFMT_ELF = yCONFIG_BLK_DEV_FD = yCONFIG_BLK_DEV_LOOP = yCONFIG_BLK_DEV_RAM = yCONFIG_BLK_DEV_RAM_SIZE = 4096CONFIG_BLK_DEV_INITRD = yCONFIG_PACKET = yCONFIG_INET = yCONFIG_IP_MULTICAST = yCONFIG_IDE = yCONFIG_BLK_DEV_IDE = yCONFIG_BLK_DEV_IDEDISK = yCONFIG_IDEDISK_MULTI_MODE = yCONFIG_BLK_DEV_IDECD = yCONFIG_BLK_DEV_IDE_MODES = yCONFIG_NETDEVICES = yCONFIG_NET_ETHERNET = yCONFIG_INPUT_MOUSEDEV_SCREEN_X = 1024CONFIG_INPUT_MOUSEDEV_SCREEN_Y = 768CONFIG_VT = yCONFIG_VT_CONSOLE = yCONFIG_REISERFS_FS = Yconfig_ext3_fs = yconfig_jbd = YCONFIG_FAT_FS =

yCONFIG_VFAT_FS = yCONFIG_RAMFS = yCONFIG_ISO9660_FS = yCONFIG_JFS_FS = yCONFIG_NTFS_FS = yCONFIG_PROC_FS = yCONFIG_EXT2_FS = yCONFIG_MSDOS_PARTITION = yCONFIG_NLS = yCONFIG_NLS_DEFAULT = "iso8859-1" CONFIG_VGA_CONSOLE = yCONFIG_VIDEO_SELECT = yCONFIG_VIDEO_IGNORE_BAD_MODE = yCONFIG_FB = yCONFIG_DUMMY_CONSOLE = yCONFIG_FB_VESA = yCONFIG_VIDEO_SELECT = yCONFIG_FBCON_CFB8 = yCONFIG_FBCON_CFB16 = yCONFIG_FBCON_CFB24 = yCONFIG_FBCON_CFB32 = yCONFIG_FBCON_FONTWIDTH8_ONLY = yCONFIG_FONT_8x8 = YCONFIG_FONT_8X16 = Y5, compile core #make dep # make bzimage The following is the last compile results: boot sector 512 Bytes.SETUP IS 4733 BYTES.SYSTEM IS 845 KBMAKE [1]: Leaving Directory `/usr/src/linux-2.4.20 -8 / arch / i386 / boot 'I have obtained an 845K kernel with the above configuration. Compile-compiled kernel placed under /usr/src/linux-2.4.20-8/Arch/i386/boot. Copy him In a safe place. Create a directory for the Babylinux material #mkdir / babylinux to create a directory for Babylinux root file system #mkdir / babylinux / rootfs backup core #CP /usR/src/linux-2.4.20-8 / Arch / i386 / boot / bzimage / babylinux / seven All this features are only about 1m of the zone. We usually use those Linux commands that are as a dependent electronic component, while busybo X is a way to be an integrated circuit that integrates the commonly used tools and commands in an executable file, the function is basically constant, and the size is small, in the embedded Linux application, busybox has a very wide application, and Most Linux distributions have a busybox figure in the installer, when installing Linux, CTRL Alt

F2 can get a console, and all commands in this console refer to the link of Busybox. Busybox's small body, bringing a linux that makes a floppy disk brings and great convenience. 2, busybox usage You can use the busybox # busybox ls His feature to run the LS command the most common usage is to establish a link to the busybox, different link names complete different features. # Ln-s busybox ls # ln-s busybox rm # ln - S BusyBox Mkdir then runs these three links: #. / ls #. / rm #. / mkdir can complete the functionality of the LS RM and MKDIR commands, respectively. Although they all point to the same executable program busybox but as long as the link name Different, the completed function is different. Busybox is such a magical. Many Linux websites offer BusyBox source code downloads. The current version is the official version of BusyBox 1.0.3, configuring BusyBoxyBox configuration programs and Linux kernel menus configuration methods simply exactly the same. Friends who are familiar with the use of Make MenuConfig methods easy. # Cp busybox-1.00.tar.gz / babylinux # cd / babylinux # tar xvfz busybox-1.00.Tar.gz # cd busybox-1.00 # make menuconfig below compiled into busybox functional options, others can be optional according to need, but is also not greedy .General Configuration option should be selected Show verbose applet usage messagesRuntime SUID / configuration via SGID /etc/busybox.conf Build OptionsBuild BusyBox as a static binary ( No Shared Libs This option is to select, so you can compile Busybox into a static link executable file, run independent of other function libraries, otherwise other library files can be run, in a single Linux kernel can't make He is working properly. This option must be selected. Otherwise, the busybox will be installed in the original system / usr after Make Install, which will overwrite the original command. Select this option, make install Will build in the busybox directory A directory called _install, there is a link to his link. Other options are some Linux basic command options, which commands you need to compile, usually use the default, you can exit and save .4 After compiling and installing busybox # make # make install Compile after building subdirectory _INSTALL, inside, inside 15:28 Linuxrc -> Bin / BusyBoxDrwxr-XR-X 2 Root Root 4096 November 24 15:28 Sbin where the executable BUSYBOX In the bin directory, the other points point to his symbolic link. I compiled busybox The execution file is 935K, coupled with the symbolic link, the entire _install directory is 952K. Does the 845K kernel don't have more than 1440K?

Don't worry, we will significantly compress the entire root file system. Eight, produce root file system 1, basic directory structure #CD / babylinux / rootfs # mkdir etc usr var TMP Proc home root dev where ETC, Proc and DEV are It must be built, bin and sbin are not built, because there is already the busybox. Other built a few can be built. Copy busybox # cp -r /babylinux/busybox-1.00/_install/* / babylinux / Rootfs / 2, create device file name #CD / babylinux / rootfs / dev You can use MKNOD to create, you can also copy it directly from the original system / dev directory. Hand-established method: #LS -L / dev / consolecrw ------ 1 Root root 5, 1 November 30 09:02 / dev / console This will check that the main device number of the Console device is 5, the auxiliary standby number is 1, which is a character device that is tagged as C. So, we can use MKNOD to create a different device file: #mknod console c 5 1 But the manual method is too much trouble, usually copy the required device files directly from / dev. These device files are special files, When copying, you must add -R parameters to copy. # Cp -r / dev / console ./#cp -r / dev / null ./#cp -r / dev / zero. / ... The following is what I think the device name: cdrom fd0 hda14 hda4 hdb11 hdb19 hdc hdc16 hdc6 hdd13 hdd3 loop2 ram2console fd0H1440 hda15 hda5 hdb12 hdb2 hdc1 hdc17 hdc7 hdd14 hdd4 loop3 tty0fb hda hda16 hda6 hdb13 hdb3 hdc10 hdc18 hdc8 hdd15 hdd5 loop4 tty1fb0 hda1 hda17 hda7 hdb14 hdb4 hdc11 hdc19 hdd hdd16 HDD6 LOOP5 TTY2FB1 HDA10 HDA18 HDA8 HDB15 HDB5 HDC12 HDC2 HDD1 HDD17 HDD7 NULL TTY3FB2 HDA11 HDA19 HDB HDB16 HDB6 HDC1 3 hdc3 hdd10 hdd18 hdd8 ram tty4fb3 hda12 hda2 hdb1 hdb17 hdb7 hdc14 hdc4 hdd11 hdd19 initctl ram0 tty5fb4 hda13 hda3 hdb10 hdb18 hdb8 hdc15 hdc5 hdd12 hdd2 loop1 ram1 zero wherein, fd0, hda, ram, ram1, tty1, null, zero, loop1, fb0 , FB is essential. Other HDA, HDA1, HDB, etc. can be decided according to actual needs. But the choice in the table is relatively reasonable, that is, most of the needs, there is no space for equipment, pay attention Don't copy the equipment under / dev, which will generate approximately 420K / dev directory, which is too big for Babylinux .3, establish the configuration file in the ETC directory BusyBox.conf Group inittab Motd Passwd Resolv .conf shadow-fstab init.d issue MTAB profile shadow wherein INIT.D is a directory that is copied from the busybox-1.00 source code. # cp -r /babylinux/busybox-1.00/examples/bootflopypyp/etc/init. D /BABYLINUX/rootfs/etc/busybox.conf is an empty file. The contents of other files are as follows:

FSTAB / DEV / FD0 / EXT2 DEFAULTS 0 0 0none / Proc Proc Defaults 0 0 0 / DEV / CDROM / MNT / CDROM UDF, ISO9660 NOAUTO, OWNER, KUDZU, RO 0 0 0 / DEV / FD0 / MNT / FLOPPY AUTO NOAUTO, OWNER, KUDZU 0 0grouproot: x: 0: rootinittab :: sysinit: /etc/init.d/rcs: first2tty3 :: respawn: / bin / getty 38400 TTY3TTY4 :: Respawn : / bin / getty 38400 TTY4 # stuff to do when restarting the init process :: restart: / bin / bin / reboot :: shutdown: / bin / umount -a -r :: shutdown: / bin / swapoff -aissueBaby Linux release 0.1motdmtabpasswdroot :: 0: 0: root: / root: / bin / ashprofile # / etc / profile: system-wide .profile file for the Bourne shellsechoechoexport PS1 = "[/ u @ / h / w] / $ "echo" done "alias ll = 'ls -l'alias du =' du -h'Alias ​​DF = 'DF-H'Alias ​​RM =' RM-I '

echoresolv.confnameserver 202.96.209.5nameserver 202.96.209.6shadowroot: $ 1 $$ adltAB9Sr / MSKqylIvSJT /: 12705: 0: 99999: 7 ::: shadow-root: $ 1 $ DWU.tenP $ B7ANiXoGoiZMwJR6Ih8810: 12705: 0: 99999: 7: :: Many of them are copied from the original system / etc, if you are a Linux enthusiast with medium or above, then you should understand, of course, you can modify these according to your needs. Document. The most important of which is the syntax of the initTab file in the initTab, Busybox built-in initTab file and generally different. You cannot copy the original system / etc initTab file. You can put the busybox-1.00 directory. The sample file copy comes to modify it. Please see the busybox document. Busybox's initTab. But there is a very strange bug in the process of making Babylinux. All / sbin busybox links are made into a compressed root File system, you can't run normally after decompression, you can't find this command. Only when I do these links under / bin, I can run. The reason is not too clear, so you need to do the following work: #CD / babylinux / rootfs / sbin # lschroot getty ifconfig losetup pivot_root reboot swapoff sysctlfdisk halt init mkswap poweroff route swapon telnetd view that there is at the above link to bin sbin under #cd / babylinux / rootfs / bin redo these links: #ln -s busybox chroot #LN -s busybox getty # ln-s busybox ifconfig ... then remove the link under the sbin to save space #RM-RF / BABYLINUX / ROOTFS / SBIN / * change all the Sbin in the original initTab to bininit. Downloaded: RCS Please make sure this file is executable, otherwise please change: #CHMOD u x rcsrcs content: #! / bin / shmount -o remount, rw // bin / mount -a > / etc / mtabecho ech OecHoechoecho -EN "/ T / TWELCOM to // 033 [0; 32MBabylinux /// 033 [0; 39m / n" echo -en "// 033 [0; 36M / N" echoecho -en " / T / T / N "Echo -en" this is a tiny linux system based on a floppy.it contains / t / t / n "echo -en" more Than 100 Basic Linux Commands and Tools.The Kernel Of / T / T / N "Echo -en" this Tiny System Support All Kinds of Normal FileSystems. / T / T / N "

echo -en " Linux EXT2, EXT3, JFS, Reiserfs and Windows Fat, VfAT, NTFS [Readonly] / T / T / N" echo -en " is supported! SO IT IS A Powerful Small System you can use IT / T / T / N "echo -en" as a linux and windows rescue disk.beside this, The Kernel Also / T / T / N "Echo -en" Contains the Drivers of Reltek8139, Ne2000, Via-Rhine Ethernet / T / T / N "echo -en" adpater. You can configure the ipaddress and netmask with tools / t / t / n "echo -en" 'ifconfig' and config the default Gateway with command 'Route'. / t / t / n "echo -en" is there is a telnet server build-in / t / t / n "echo -en" you can type 'telnetd' to startd it and thies your friends CAN / T / T / N "echo -en" logon to your system to help you solve the problem) // 033 [0; 32mall the Great Features Are Powered by Busybox 1.0 // 033 [0; 36M / T / T / N "Echo -en" this is a free system tool development by gucuiwen./t/t/n "echo -en " Run Your OWN RISK OF USING IT! If you have anyproblem please / t / t / n "echo -en" mailto: win2linux@163.com e Njoy !! / t / t / n "echo -en" / T / T / N "Echo -en" // 033 [0; 39M / n "Hostname Babylinux can make a corresponding modification yourself. The above is all the contents of the Babylinux root file system, and his total size should be around 1m. [root @

Gucuiwen Baby] # du -hs1.1m. Nine, making the RamDisk Image File Babylinux Root File System All things are placed under / babylinux / rootfs, we will use Ramdisk to make these contents into the RAMDisk image file and compress him. Mainly Ramdisk's usage, after reading the following, you should learn Ramdisk's use. [Root @ Gucuiwen Babylinux] # DD if = / dev / zero of = / dev / ram1dd: Writing '/ dev / ram1': device There is no space to read 8193 0 blocks 8192 0 block ZERO is a special device that represents all 0 characters. The above command means that the first RAMDisk of the system is all 0 data fill, because the default size of the RAMDisk is 4m, so when it is full of 8192 blocks (512 bytes per block), there is no space on the 'device'. This is normal, / dev / ram1 has been filled. If the size of the specified block: [root @ gucuiwen babylinux] # DD if = / dev / zero of = / dev / ram1 bs = 1M count = 4 reads 4 0 blocks output 4 0 blocks do not have Error prompt, here demonstrate the general usage of DD, then use the DD command frequently. There are many ramdisk devices, RAM1, RAM2, RAM3 .... Generally used the first one. Fill There is room for RAM1, you can create a file system on this space: [root @ gucuiwen babylinux] # mkfs.ext2 -m0 / dev / ram1mke2fs 1.32 (09-NOV-2002) FileSystem label = OS type: LinuxBlock size = 1024 (log = 0) Fragment size = 1024 (log = 0) 1024 inodes, 4096 blocks0 blocks (0.00%) reserved for the super userFirst data block = 11 block group8192 blocks per group, 8192 fragments per group1024 inodes per groupWriting inode tables: DONEWRITITING SuperBlocks and FileSystem Account ING INFORMATION: DONETHIS FILESYSTEM WILL BE Automatical CHECKED EVERY 37 Mounts Or180 Days, Whichever Comes first. Use tune2fs -c or -i to override. Plug the RAM1 into the file system: create a hovering point: #mkdir / mnt / ram Hanging Ram1: #mount / dev / ram1 / mnt / RAM Copy the previous Babylinux root file system to RAM1. # Cp -r / babylinux / rootfs / * / mnt / RAM has completed the above steps, you should It is white in the meaning of the RamDisk device. He is the same as HDA1, HDB1, the same block device, and you can visit it with mount, put things on the file system, but all things are in memory. Turn off all things. Copying the Babylinux root file system After uninstalling Ram1: #umount / dev / ram1, although it cannot access the content in RAM1 by / mnt / ram, he is cut in memory. Use DD to take this RAM1 in a picture mode: [root @ gucuiwen babylinux] # DD if = / dev / ram1 of = / babylinux / ramdisk.img reads 8192 0 block output 8192 0 block validation The content taken out: [root @

Gucuiwen Babylinux] # file ramdisk.imgramdisk.img: Linux Rev 1.0 ext2 filesystem data he is an EXT2 file system, similar to an ISO disc image file. Because we can use loop devices to reinite him into the file system : [Root @ Gucuiwen Babylinux] # mount -o loop ramdisk.img / mnt / ram / For convenience, I still hang him under / mnt / ram, so, I have to take / dev / ram1 umount to view / The content under MNT / RAM should be the same as / babylinux / rootfs, otherwise it is wrong: [root @ gucuiwen babeux] # ls / mnt / rambin dev etc home Lost Found MNT Proc Root Sbin Tmp USR Var, We got a Ramdisk root file system image: ramdisk.img dropped him umount: #umount / mnt / ram If it is the first time to get in RamDisk, you may confuse the above content, if so, please read it repeatedly Understand the above, you can understand it multiple times, you can understand. Compress RamDisk.img Impression Documents: [Root @ Gucuiwen Babylinux] # Gzip -v9 ramdisk.imgramdisk.img: 87.9% - Replaced with ramdisk.img. GZ View the size of the compressed: [root @ gucuiwen babylinux] # ls -lh ramdisk.img.gz-rw-r - r - 1 root root 495k November 30 11:32 Ramdisk.img.gz I get the compression The Ramdisk Image file is 495K. Plus the number of 845K, is 1340K compliant formula: kernel size file system compressed impression file 50K <= 1440K If you made kernel and ramdisk.img.gz too big, please re- Make kernel or ramdisk.img.gz, do some of them, if your kernel and ramdisk.img.gz are too small, then add some content, so that your babylinux is more functional. 10, kernel and Busybox's integration prepares a good blank floppy disk creates a file system that is slightly larger than the kernel size: ratio If the kernel size is 845K, then I created a 920K file system: # mkfs.ext2 -m0 / dev / fd0 920 If space allows, it can be more large, but must guarantee 1440K-file system size> = ramdisk.img .gz size. Mounting floppy disk #mount / dev / fd0 copies the kernel to floppy disk: #CP / babylinux / bzimage / mnt / floppy / boot file 文件 Boot.b copy to floppy #CP /Boot/boot.b / mnt / floppy lilo.conf a new profile: prompttimeout = 60default = linuxboot = / dev / fd0map = / mnt / floppy / mapinstall = / mnt / floppy / boot.blinearimage = / mnt / floppy / bzImagelabel = linuxread-onlyvga = 788Root = / dev / fd0append = "load_ramdisk = 1 ramdisk_start = 940" VGA = 788 indicates that the high resolution display of the kernel support the character interface, you can change to VGA = ASK, which can choose the resolution when startup. Red line It is the key, load_ramdisk = 1 tells the kernel to reprint the compressed RamDisk impression file when starting, ramdisk_start =

转载请注明原文地址:https://www.9cbs.com/read-79713.html

New Post(0)