This article mainly introduces several methods to reduce Linux core, which can be used for core configurations of embedded systems and embedded servers.
1. General PC Kernel configuration
For general users, Linux kernel efficiency and size requirements are not high. Therefore, kernel re-configuration is generally not performed.
Because the Linux installer performs default settings for most of the settings according to the installation requirements and the actual hardware. This way
The kernel is more redundant than actually needed. Many modules are useless after being loaded, but the current PC memory is generally
Both are hundreds of MB, and the size of a Linux kernel is several hundreds of KB. Therefore, for general users
Nuclear.
Install red-Hat 7.2 On A P3-566 Dell machine with kernel version 2.4.6
The following are some machine configurations:
Loadable module support: Y
Networking Support: Y
PCI support: Y
System v ipc: Y can be used as a system V-based program.
Kernel support for A. Out Binaries: Y
Kernel support for elf Binaries: Y
Block devices
Module. For example, loopback device support
Networking options:
PACKET socket: Y
TCP/IP networking: Y
Network firewils: Y
The IPX protocol: Y
Network Device Support:
Network Device Support: Y
Ethernet (10/100 Mb/s): Y
Character Device
Virtual terminal: Y
Support for console on virtual terminal: Y
Filesystems
Second extended FS Support: Y
Vfat FS Support: m I sometimes use vfat partitions on this machine
/Proc filesystem support y
Iso9660 CDROM filesystem support: m
Network File Systems
NFS filesystem support: Y
SMB filesystem support: m
Console drivers
VGA text Console: Y
Video mode selection support: Y
Vesa vga graphics Console: Y
Kernel hacking
Magic sysrq key: Y
I have not changed some default settings. In this way, the compiled version is 700k. After debugging, nothing has happened.
Problem.
2. PDA kernel settings
Personal Digital assist (PDA), such as mobile phones, quick translation, and wenquxing. This type of system requires system stability and Kernel
Small and efficient, and special hardware support is often required. Single Process Scheduling and file system requirements, some of which are single processes
System. Network support depends on your needs. The RedHat kernel cannot be used directly to design PDAs with special requirements.
You also need to add specific hardware modules.
Make the following settings:
Networking Support: Y: Generally, PDAs support Internet update.
Kernel support for elf Binaries: Y
Compile as elf-if your GCC is ELF-GCC: Y these two settings make the system's execution files both
Elf
Advanced Power Manager BIOS support: Y
Block devices: special hardware support modules should be added.
Networking options
PACKET socket
Filesystem
Second extended FS Support: Y
Some other functions are N. Of course, some functions must be used to support the above modules. After compilation, the value is 100kb---400kb.
3. Kernel configuration for small Embedded Systems
A small embedded Linux system only requires the following three basic elements:
Guide tool
The Linux microkernel consists of memory management, process management, and transaction processing.
Initialization Process
If you want it to do something and keep it small, you need to add:
Hardware driver
One or more applications that provide the required features.
To add more features, you may need these: A File System (maybe in ROM or RAM) TCP/IP network stack pair
Different settings are made for this system:
Do not floppy; Do not SMP, mtrr; Do not networking, SCSI; remove all Block devices,
Only the IDE device is left; all character devices are removed; All filesystems are removed, leaving only
Minix; do not support sound. In this way, all options have been removed. After doing this, we get a 188 K
Core.
Replace-O3 and-O2 in the following two files with-OS.
./Makefile
./ARCH/i386/kernel/
Makefile
In this way, the entire core becomes 9 K and becomes 179 K.
However, I am afraid this core is difficult to use the Linux function, so I can add the network back. In general setup
Network support is added and re-compiled. The core is 189 KB. Add a TCP/IP stack at 10 K. Yes
Stack without driver is also a waste, add the rtl8139 driver commonly used in the embedded board back, 195 K.
If you need a DOS file system, the size is 213 KB. If minix is replaced by ext2, the value is
Length: 222 KB.
Linux requires about KB of memory ~ Between 800 KB. 1 MB memory may be able to boot, but it is not very useful because
Connecting to the C library is difficult. 2 MB memory should be able to do something, but a ratio of 4 MB or more can be executed
Complete system.
Because Linux's filesystem is quite large, it is about 230 K, accounting for 1/3 of the volume. Memory management accounts
80 K, similar to the sum of other core parts. TCP/IP stack accounts for 65 k, and drivers account for 120 K. Sysv IPC
It accounts for 21 KB. If necessary, it can be removed. The core file should be smaller than 10 KB.
What if we want to crop the core size? The answer is obvious, of course, the file system. Linux VFS simplification
The file system design, buffer cache, and directory cache increase the system efficiency. But these embedded system roots
It is of little use. If you can remove them, the core can be reduced to about 20 K. If you skip the entire VFS, directly
Write the file system as a driver type and reduce the size of 230 K to about 50 K. The entire core is reduced to 100 K
Left and right.
4. Computer Kernel configuration
For the IPC kernel, the kernel size requirements are not strict. The key is correctness, robustness, and real-time performance (Requirements for some computers ).
High real-time performance). The file system has a single requirement, but ensures correctness. The network is set as needed.
The following configurations are available:
Invalid Ric multi-processing support: Y
Loadable module support: N Industrial Computer generally loads all modules that may be used into the memory.
Networking Support: Y
System v ipc: Y
Kernel supply for elf Binaries: Y
Block devices: based on the specific hardware configuration
Networking options
PACKET socket: Y
Generally, an industrial computer is connected through a LAN and isolated from the outside world. Therefore, the IPX protocol is required. In addition, TCP/IP is also required.
QoS and/or Fair Queueing: Y
QoS (Quality of Service) and fair queueling is a network thread that schedules certain packets to be sent first.
Table, which can be processed by multiple network packets at the same time and sorted by the priority processing order. This function is called packet schedulers.
It is especially important for real-time systems. When multiple packets are sent to network devices at the same time, the kernel can determine which packet is required.
Priority is required. Therefore, the kernel provides several packet scheduling algorithm.
Filesystems
Second extended FS Support: Y
The remaining configurations are slightly different from those of small embedded systems. The size of the kernel compiled on the same machine is more than 800 KB.
5. Server Kernel configuration:
The server kernel is critical to network settings and process scheduling. perform the following Configuration:
Invalid Ric multi-processing support: Y
Loadable module support: Y
Networking Support: Y
Networking Option
PACKET socket: Y.
TCP/IP networkeing: Y
Network firewils: whether to use a network firewall. If the computer wants
In the network structure of the TCP/IP communication protocol, select [Y].
Network aliasing [Y/M/n/?] : A computer on a network can have multiple IP addresses. If you want to have more
IP addresses, select [Y].
IP: Forwarding/gatewaying [Y/M/n/?] : If you want to be a vro, select [Y], but the prerequisite is that there are "two"
Network Adapter, a pair of external networks, a pair of internal networks, and the end of the ISP must also be set routing, allowing the user
Only available for vrouters.
IP: multicasting: transfers a packet to several computers at a time.
IP: syn_cookies: a protection measure that encrypts various TCP/IP communication protocols to prevent attacker from attacking users.
It can also record the IP addresses of computers that attempt to attack users.
IP: firewalling: whether the computer is a firewall server.
IP: Firewall packet logging: whether the klogd records the packages received by the firewall server.
IP: Masquerading: Packets sent from computers in the internal network can be directly transmitted to remote networks through the firewall server.
The remote computer sees the packets sent from the received firewall server, rather than from the internal
Sent by the computer. In this way, if only one computer can access the Internet, other machines can access the Internet through the firewall server of this machine.
The server is connected externally. To select this option, you must first confirm the previous
Network firewils IP: Forwarding/gatewaying IP: select [y] for the three options of firewalling. And the next one
Item IP: also select [y] For always deframent.
IP: ICMP masquerading: Generally, masquerading only processes TCP and UDP packages.
Masqurerading can also process ICMP packets. Select [y] for this option.
IP: Always defragment: You can combine the received packet fragments back to the original package.
IP: Accounting: Collects IP packet traffic, that is, network traffic.
IP: optimize as router not host: Copy & checksum technology can be disabled to prevent high-traffic Server
IP packets is lost.
IP: tunneling: Linux can be used in different domains, and you can directly access the Internet without changing the IP address. Suitable for cost-effective models
Computer user.
IP: reverse ARP: It mainly provides the bootp function to enable the computer to start from the boot ram of the NIC.
IP: Disable path MTU discovery: whether to cancel path MTU discovery. MTU helps
Crowded network.
The IPX protocol: IPX is the communication protocol used by Netware.
Set other parameters as needed. The compiled kernel is 800 KB.
Server kernel:
The server kernel is critical to network settings and process scheduling. perform the following Configuration:
Invalid Ric multi-processing support: Y
Loadable module support: Y
Networking Support: Y
Networking Option
PACKET socket: Y.
TCP/IP networkeing: Y
Network firewils: whether to use a network firewall. If the computer wants to use firewallserver or a network structure in a TCP/IP communication protocol, select [y]
Network aliasing [Y/M/n/?] : A computer on a network can have multiple IP addresses. If the computer wants to have multiple IP addresses, select [Y].
IP: Forwarding/gatewaying [Y/M/n/?] : If you want to be a vro, select [Y], but the prerequisite is that there are two NICs, one for the external network and the other for the internal network, in addition, you must set the routing at the end of the ISP.