Lightweight LINUX: use old hardware to break the software and hardware upgrade cycle

Source: Internet
Author: User
Article Title: lightweight LINUX: use old hardware to break the software and hardware upgrade cycle. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
   Policies and Suggestions
I plan to use this laptop for writing and remote access to my more powerful desktop development system. Therefore, I need the system to have network support, shell, text editors like vi, CVS for document version control, and SSH for secure remote access. In terms of resources, I have 12 MB memory and 540 MB hard drive available.
  
As I entered a field that I have not fully studied, I have chosen many milestones. I used this method in this article. Frequent milestones help me determine if I have made some progress in solving the problem. Frequent milestones can help you debug the process when a step is not as effective as it is declared. I encourage you to try out your system even if the system is not complete. These tests can help you determine whether the work at that point is correct.
  
My first suggestion is not to consider using any existing Linux distribution. I initially wanted to install an existing Linux distribution to avoid starting from scratch. But soon they all need more resources than available resources. Even if Slackware (which has long been known to support low-memory systems) needs at least 12 MB of memory to install the distribution edition, it can barely work in that case.
  
Before starting to build the system, you may need to consider the possibility of using the existing "single disk" Linux distribution edition-such as tomsrtbt (single disk emergency floppy disk distribution edition), Trinux (Linux security toolbox on a single disk), or even Tin Foil Hat Linux (a Secure Linux distribution version designed to encrypt, sign, and erase files)-start and then expand it.
  
Before I officially started building my own system, I studied several of these mini-distribution versions and learned a lot. Although none of the distributions I studied specifically target hardware with limited resources (such as my laptop, but they all have a common goal-to put as many features as possible into as little space as possible. Although many of the trade-offs they have made to achieve this goal are unacceptable to me, I have noticed uClibc and BusyBox and eventually I used them.
  
UClibc
Each Linux system requires a C library. Library C provides common file operations (open, read, and write), memory management operations (malloc and free), and many other functions that make a Linux system a real name. Glibc is used in most Linux systems. Glibc is mature and well tested and is under active development. Unfortunately, it uses a relatively large amount of memory, which is unacceptable for my machine.
  
I do not recommend Glibc, but uClibc, a modern, stable, and highly compatible Glibc alternative. UClibc is developed for embedded systems, so it strives to become a complete but lightweight C library. The trade-off between speed and size is determined by the size. However, in most cases, the applications and tools compiled for uClibc are not different from those compiled for glibc. The uClibc website (see references) lists over one hundred applications that are known or reported to use uClibc. The list includes standard utilities such as Gzip and Lilo, and utilities less commonly used such as Lame (MP3 encoder) and Freeswan (VPN implementation. Because I measure the effectiveness of a system by running tools and application maturity on the system, for me, it is very important that the C library I selected can support the tools I need.
  
Dietlibc is another C library that can replace Glibc. My research shows that although Dietlibc requires less memory than uClibc, it achieves this by sacrificing its compatibility with Glibc. Finally, I chose to use uClibc because it seems to support more applications I need.
  
BusyBox
Linux users need a working environment composed of a large number of command line tool sets. Because building all the necessary tools one by one seems to be a time-consuming task, I once again borrowed the experience of the embedded system and chose BusyBox, which is an "everything" application, in a binary file, it provides the implementation of most tools you want to see in Linux.
  
By using BusyBox, I keep valuable resources and save a lot of time investment. I cannot find other tool sets like this.
  
   Components and preparations
To continue, you need to have the right to use an existing Linux system-it is better that the microprocessor used to run the system is the same series as that of your target system. An older Linux-running portable computer is an excellent environment for writing and editing, but it cannot compete with modern hardware when compiling software packages. We will use the existing Linux system to build the kernel and support software, and create a disk necessary to boot the target system into Linux. After installing Linux on the target system, we will continue to use the existing system to build applications before transferring the finished products to the target system. I call the existing Linux system "build system" and the other Linux system "Target System ".
  
First download the following software package (see references for links ):
  
Linux-2.4.19.tar.gz (kernel)
UClibc-0.9.15.tar.gz (C Library)
Busybox-0.60.4.tar.gz (useful command line tools)
Util-linux-2.11u.tar.gz (fdisk executable files)
E2fsprogs-1.27.tar.gz (for file system creation)
Lilo-22.3.2.tar.gz (boot loader)
  
To build and link BusyBox with uClibc, you need to install the uClibc development environment in the/usr directory of the target system. Therefore, you need write access to this directory.
  
Part of this process includes building a simple root file system. I simplified this step by providing the appropriate root file system framework, along with the required configuration files and device files. You can download the file framework skeleton.tar.gz from references.
  
You need to read and understand the necessary documents, including the README and INSTALL documents. Because there are too many options and special cases, we cannot introduce all the permutation and combination in this article. In the following sections, I will introduce the recommended configurations.
  
Let's build the kernel.
  
Build a Linux Kernel
It is possible to build an effective Linux kernel without changing the default configuration. However, several carefully considered changes will generate systems that are more suitable for our needs. In particular, I always remember the network connection requirements. The following table lists the options for my changes and provides suggestions for system changes that you may wish to make.
  
   Kernel configuration
    
Note: You may need PCMCIA to connect your laptop to IOT platform. Older laptops do not support newer Carton (32-bit) cards, but this is usually not a problem because there are still many 16-bit NICs available. If you plan to connect to the network through a cable, select the appropriate driver under PCMCIA network device support, which is not included in the above table. I use a wireless connection. Many 16-bit PCMCIA cards use the Hermes chipset. You may need to slightly change the configuration to match your PCMCIA controller chipset and PCMCIA card.
  
The kernel should be configured to support your CPU. If you build a kernel for an older machine on the new machine, you need to select an appropriate processor, such as Intel 386 or 486. To save space, you may want to disable all options that you don't think are needed, especially the SCSI support.
  
Follow these steps to build the kernel:
  
Make xconfig
Make dep
Make bzImage
Make modules
  
I will describe how to install the kernel later.
  
Build uClibc
Building uClibc is more challenging than building a kernel. The uClibc Software Package constructs two related components. The first component is the Runtime Library that supports the utilities and Applications of your target system. The second component is a development environment. The uClibc development environment makes building utilities and applications that use uClibc simple, even in systems that do not use uClibc themselves. UClibc creates and installs the package for gcc and related tools. Once the uClibc development environment is installed, You can compile and link most applications for uClibc instead of glibc.
  
   UClibc Configuration
    
The three options in the Table above make it possible to build and install software such as SSH and NFS (if you choose to do so later. You also need to specify the location of the Linux kernel source file.
  
The following steps describe how to build a uClibc package. Take these steps on premise that you have decompressed the compressed document to a directory named uClibc-0.9.15:
  
Cd uClibc-0.9.15
Ln-s./extra/Configs/Config. i386./Config
Edit the Config file. Enable the options specified in the preceding table.
Make
  
The preceding instructions assume that you are building uClibc for the Intel microprocessor. If you build uClibc for another microprocessor, you can create a link to the appropriate Config file in step 2 above.
  
Make command to build the software package. To use uClibc to compile and link other utilities and applications, you must install the development environment. Run the make install command to install the development environment.
  
Once the development environment is installed, you can change the PATH environment variable and use the uClibc development tool to replace the standard Glibc-based development tool, as shown below:
  
Export PATH = /Usr/bin: $ PATH
  
Once you change the PATH environment variable, you will find that most development commands (gcc, ld, ldd, etc.) today point to the uClibc package. However, the command should still work as usual. It is important to set the PATH environment variable correctly before building any of the following software.
  
On my Redhat 7.3 system, you cannot build the latest uClibc version (version 0.9.15 ). The technology used to locate the gcc header has changed in release version 0.9.12. If you cannot build uClibc on your system, you can apply the uclibc patch provided in reference section of this article. It migrates previous technologies to the latest release of uClibc.
  
I will describe how to install the runtime environment on the boot disk and the root file system disk later.
  
Build BusyBox
If you have a task that simplifies the process of building a Linux system from scratch, you can build and install the BusyBox package. BusyBox is an executable file that provides functions of many other commonly used command line tools. All these functions are integrated. BusyBox documents claim that all you need to build an effective system is BusyBox and "/dev,/etc and kernel"-and they are not joking.
  
The following table describes your changes to the Config. h file.
  
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.