Making a floppy disk-based Linux system

xiaoxiao2021-03-06  43

Embedded Linux consists of a hundred KB of KERNEL (kernel) and some system modules customized as needed. Since Linux is an Open source operating system, it has its own advantages in the embedded field, which have its irreplaceable cost and high flexibility. It is the basis for making embedded Linux as long as a floppy disk is like DOS. There are many implementation methods on the Internet, but there are more problems or inconvenient in the practice process. We combine our own practical experience in this area, detail the floppy Linux system production process. Three basic elements A embedded Linux system requires only three basic elements below: boot programs, Linux microennucleus (consisting of memory management, process management, and transaction processing) and initialization processes. If you want it to have more features and maintain miniaturization, you can also add file system, TCP / IP network support, GUI (graphical user interface) and design streamlined applications, and put it in ROM, RAM, FLASH Or start in Disk on Chip. Due to the high flexibility of embedded Linux operating systems, developers can easily customize it or appropriately developed to meet the actual application needs. Cutting Linux system can start with a floppy disk, not only the basis of making embedded Linux, but also has a wide range of application prospects. These applications include simple router management, three-layer switch management, FLOPPY-BOOT firewall management, etc. There are special organizations with special organizations in this area, such as Loaf (Linux On A Floopy). Selecting the kernel to create a boot disk First, you must create the system kernel. Since the floppy disk capacity is limited, it is often used to manually configure the kernel, and the unnecessary module is used to cut the kernel. To reach the kernel size, you have to remove unnecessary features when you create it, such as the support of the network and support for unnecessary equipment. But be sure to keep the kernel support for RamDisk and EXT2, otherwise the boot disk will not work. The process is as follows: 1) Log in with the root super user, enter the directory / usr / src / linux. 2) Execute #make menuConfig to configure the kernel module (or run make Xconfig in X Window). 3) Perform #make dep and #make bzimage (if the kernel is not large, execute), after executing this command, the kernel file BZIMAGE will be generated under the / usr / src / linux / arch / i386 / boot directory (or Zimage). If the configuration is added to the configuration (option is M), #make modules and #make modules_install are required. 4) Use the command #CP usr / src / linux / arch / i386 / boot / bzimage / boot to copy the new core to / boot directory, modify files /etc/lilo.conf, join:

Image = / boot / bzimagelabel = newroot = / dev / hdxx (your own boot hard disk partition) Read-only

Execute command #LILO to load the new kernel, # reboot restart system, type New when "LILO:" appears. If the system is booted, the next step is performed. If it is not guided by the old kernel, go to step 1) Reconfigure the compiled kernel. 5) Insert the floppy disk

#dd BS = 1K if = / usr / src / linux / arch / i386 / boot / bzimage of = / dev / fd0

This copies the kernel to the floppy disk. 6) Use command #ls -s will get the size of the kernel in / usr / src / linux / arch / i386 / boot / bzimage (assuming 476), and record this size after reading. This makes a bootable Linux boot floppy disk containing a regenerative core. However, because there is no root file system, after using this floppy drive to start the system, "VFS: Cannot Open Root Device X: X" and "Kernel PANIC: VFS: UNALBE TO Boot Root FS ON X: X" are displayed. ROOT file system A root file system must include full things that support complete Linux systems, therefore, it should include: basic file system structure; at least directory / DEV, / PROC, / BIN, / ETC, / LIB, / USR, / TMP; most basic applications, such as SH, LS, CP, MV, etc., minimum profile, such as RC, ITTAB, FSTAB, etc. FD0; basic program runs the function library required. Since the above required documents are far more than 1.44m, we usually apply it to the floppy disk after preparing content. When started with a floppy disk, then extract the file to the memory, form a virtual disk (RAMDISK), start through the RAMDisk control system. If you use the LILO control start, check the size of the RAMDISK defined in LILO profile /etc/lilo.conf: ramdisk_size = nnn

Create a root file system Back to the root directory or user's default directory, with #mkdir flop, build a work directory FLOP. Built the following directorys in this directory: / dev, device; / proc - proc, file system, required directory; / ETC, system profile; / sbin, important system program; / bin, basic application; / LIB, shared functions library; / MNT, load other disk nodes; / usr, attach applications. Where / proc, / mnt, and / usr are empty in this case, just create them with MKDIR. The rest of the directory should be created separately as needed. They will be described in detail below.

/ DEV: This directory contains an indispensable device file. You can copy the files / dev files in the existing system and delete unnecessary files. But be sure to keep Console, KMEM, MEM, NULL, RAM, TTY * and other files. The rest can be deleted as needed. / etc: This directory contains some essential system profiles. It can generally contain rc.d / * (system start scripts), FSTAB (listing file system to log in), inittab (including startup parameters), passwd (username and directory), group (user group), shadow (user encryption) password). If INIT is not used as a login process, then the init link to / bin / bash, then any file can be free in the / etc directory. / bin and / sbin: This catalog contains an indispensable application such as LS, MV, CAT, CP, Getty (MINGETTTTY). You can also choose according to your own needs, but you must remember the following procedures: init, getty, login, mount, bash. / lib: This directory contains the shared function library required during your boot disk startup. There must be a function library loader in the / lib directory, this loader or ld.so (a.out library) or LD-Linux.so (for the ELF library).

Module If there is a modular kernel, you have to consider the modules that need to be loaded. They are all in / lib / modules. You can put it on another disk that is not a very important module, and then load it after the system starts so that the space of the boot disk will save. Package 1) Establish a temporary mount point for LOOP devices and a temporary file with a size of 4.6 megabits (size adjustable), and clear it: #mkdir / mnt / loop 2> / dev / null # dd if = / dev / ZERO OF = / TMP / LOOP_TMP BS = 1K count = 4600> / dev / null

2) Link the LOOP device with the temporary file

#LOSetup / dev / loop0 / tmp / loop_tmp

3) Linux kernel identification two file systems that can directly copy to RAMDISK, they are Minix and EXT2, EXT2 performance is better:

# MKE2FS -M 0 / dev / loop0 2> / dev / null

# MKE2FS will automatically determine the size of the device capacity and configure itself, -m 0 parameters prevent it from resermitting space to the root, which will make more useful space. 4) Next, hook the virtual disk on the node / MNT:

#mount / dev / loop0 / mnt / loop -t ext2

5) Copy the produced root file system to the node hung, remove the hook, remove the established hookpoint, and cancel the connection between the LOOP device and the temporary hint.

#cp -a ./tree/* / mnt / loop # umount / mnt / loop # RMDIR / MNT / LOOP 2> / dev / null # ilosetup -d / dev / loop0

6) After compressing the file system, it has a compressed root file system to delete the established temporary file.

#dd if = / tmp / loop_tmp | gzip -9> rootfs.gz # rm -f / tmp / loop_tmp

7) Check the size of the compressed root file system, if big, have to remove something.

#ls -s ./zimage|cut -f2 -d

After integrating the root file system and kernel, the last job is to integrate them together. First check the size of the total file, including the already produced kernel and packaged root file system. If it exceeds 1.44M, you have to consider recreation. All the files required by the root file system are ready, you can run it, running results should not have errors, otherwise you should check it carefully. The real embedded Linux system is ready for the floppy Linux disk here. The rest of the work is to test the correctness of this disk. If there is a problem, you have to come again. Now many Linux issued kits have manufacturers in the launch disk, their formulation principle and the above introduction, but they often use many different techniques because they have to face more hardware and various possibilities. Case. Real IA-based embedded Linux must also join the GUI (graphical user interface) and design streamlined applications, such as web browsers, etc. GUI open source, there are MicroWindows (visiting www.microwindows.org), with MiniGUI in China. Their source code can be found online. Browser is widely used by viewml (www.viewml.org), which is also open source. Combined with some of the above tools, plus the development of the hardware driver, a set of embedded Linux operating systems can be formed.

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

New Post(0)