Customization and release of Linux (i)

Source: Internet
Author: User
Tags posix

If you always look up to the mountains, it will dampen our courage to climb, so that we stand still. What we need to do is

is to take the step, take the first steps, let ' s go!

There are generally three ways to crop Linux:

1, based on an already installed system, remove unwanted software and files to reduce the overall system size;

2, from the beginning to customize the entire system according to needs;

3, install a complete Linux system, and then copy the necessary software, files, kernels, etc. to build a small system.

The first method is practically infeasible in practice. Because it is difficult to determine what needs to be removed, and those

Things can not be deleted, if deleted files should not be deleted, it is easy to cause system instability or some application error;

The second and third methods are similar, the third method is simpler, but it is limited by the host system, the latter method is more complex, but

More flexibility. We take the second approach.

The final ISO file will include three parts: a custom-built Linux, boot system, and installation script. guided in it

The system is composed of grub, INITRAMFS, kernel and three parts.

Principle

Boot Loader is required when the computer starts, and the boot Loader task is to set the onboard core from the boot,

boot the system to run, we are make with Grub to do the bootloader. Grub Loads the kernel, and all 2.6 versions of the Linux kernel have a

a special file system Rootfs, is kernel-initiated Initial start root file System, when the kernel boot is complete, the Initramfs

text pieces Copy to Rootfs, as the initial root filesystem of the kernel, its task is to mount the system's real root file system.

The boot system is equivalent to a miniature Linux, which is copied from the custom Linux, including the small part of the custom Linux

Sub-function, the difference is that the boot system is booted from CD directly to the Linux interface. After booting the boot system to the command line interface, I

First partition the hard disk, then unzip the custom Linux into the appropriate partition and modify the grub to boot from the hard disk. Rebooting the system

into a custom Linux environment.

Customization of Linux

Our approach to customizing Linux takes the second approach mentioned in the preamble, which is commonly referred to as LFS (Linux from Scratch).

This method is simply to manually download, compile, and install the software packages that are needed. Although this method is more "stupid", it has the following advantages:

1, it gives users more control over the system, rather than relying on some people's Linux implementation.

2, it can create a very compact Linux system, even small to a few megabytes.

3, it has reliable security. By compiling the entire system from the source, you are able to review everything and get all the security patches.

Below we introduce the process of LFS.

Preparatory work

1, in advance to download the required package source code, packages have dependencies between each other, download should pay attention to download all;

You can also use others have downloaded good, for example, some distributions have a variety of software package source code.

2, can choose to make on the virtual machine, also can be made on the real machine. If you create a virtual machine, you need to do

Configuration of the machine, such as SCSI adpters settings, the kernel configuration method is also different.

3, download a bootable CD as the environment for making LFS.

4, there are some useful articles on the http://www.linuxsir.org/website to guide the installation.

Building LFS Systems

The steps to build the LFS system are as follows:

1. Build a temporary compilation environment

2. Installation system basic software

3. Configuring the Kernel

4. Configure the System startup script

The 1th, 2 steps in Jin Bu's "Linux Thorough Customization Guide" has been described in detail, if necessary

I can provide it, or I can download it on the Internet. Following the methods provided on these networks is generally not a problem,

However, due to the different production environment may have some problems, as long as patience and perseverance can be solved.

Kernel configuration

Enter the following command:

CD linux-2.6.* //Enter the directory where the Linux source code resides

Make Mrproper

Make Menuconfig

In the interface, configure as follows:

Device Drivers--->
SCSI Device Support--->
<*> SCSI Device Support
<*> SCSI Disk Support
SCSI Low-level Drivers--->
<*> BusLogic SCSI Support

Device Drivers--->
ATA/ATAPI/MFM/RLL Support--->
<*> Enhanced Ide/mfm/rll disk/cdrom/tape/floppy support
<*> Include Ide/atapi CDROM Support
[*] PCI IDE chipset Support
[*] Generic PCI bus-master DMA Support
<*> Intel PIIXN chipsets support

File Systems--->
Cd-rom/dvd filesystems--->
<*> ISO 9660 CDROM File system support
[*] Microsoft Joliet CDROM Extensions

After saving exit, enter the following command:

Make

Make Modules_install

Cp-v arch/i386/boot/bzimage/boot/lfskernel-*

Cp-v system.map/boot/system.map-*

Cp-v. config/boot/config-*

Install-d/usr/share/doc/linux-*

Cp-r documentation/*/usr/share/doc/linux-*

Many of the problems in making LFS are due to improper kernel configuration, please note!

Configuring the System startup script

/etc/fstab file:

/dev/ ext3 Defaults 1 1
/dev/sda1Swap swap Pri=1 0 0
PROC/PROC proc Defaults 0 0
Sysfs/sys Sysfs Defaults 0 0
Devpts/dev/pts devpts gid=4,mode=620 0 0
SHM/DEV/SHM TMPFS Defaults 0 0

The part marked in red please note, please follow your own situation to modify. Typical SATA drives are sda1 and sda2,

IDE hard drives are hda1 and hda2. The file system format of the root directory is as specific as it should be.

/boot/grub/menu.lst file:

Default 0
Timeout 5
Color Green/black Light-green/black
Title Gwlinux 1.0
Root (hd0,1)
kernel/boot/lfskernel-* root=/dev/sda2

The part marked in red please note, please follow your own situation to modify. How to represent a disk in grub

Not quite the same as in/dev,/dev/hda2 is represented as (hd0,1) in grub, and/DEV/HDB1 is represented as (hd1,0),

The way SCSI is represented is also different/dev/sda2 is also represented as (hd0,1).

The method of recovering the working state of each stage in LFS process

The production time of the LFS is long, and sometimes must not be shut down and then restarted and restored to work

The following are the recovery methods for each stage of the LFS process.

Http://www.linuxsir.org/bbs/thread322895.html

Paste as follows:

Start ~4.4. Setting up the environment
All right, there's nothing to be regretted.
4.5. About sbus~5.33. Stripping
From now until the end of chapter fifth, that is, completing the stripping intermediate step if you restart the recovery step:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
4. Create a link to the tool chain
LN-SV $LFS/tools/
5. Create LFS Users
Groupadd LFS
Useradd-s/bin/bash-g lfs-m-k/dev/null LFS
passwd LFS
Chown-v LFS $LFS/tools
Chown-v LFS $LFS/sources
Su-lfs
6. Setting up the environment for LFS users
Cat > ~/.bash_profile << "EOF"
EXEC env-i home= $HOME term= $TERM ps1= ' \u:\w\$ '/bin/bash
Eof
Cat > ~/.BASHRC << "EOF"
Set +h
Umask 022
Lfs=/mnt/lfs
Lc_all=posix
Path=/tools/bin:/bin:/usr/bin
Export LFS Lc_all PATH
Eof
SOURCE ~/.bash_profile
7. Check
Export command to view the output, which should be
Declare-x home= "/home/lfs"
Declare-x lc_all= "POSIX"
Declare-x lfs= "/mnt/lfs"
Declare-x oldpwd
Declare-x path= "/tools/bin:/bin:/usr/bin"
Declare-x ps1= "\\u:\\w\\\$"
Declare-x pwd= "/home/lfs"
Declare-x shlvl= "1"
Declare-x term= "Linux"
Basically, it's back to work.
6.1. Introduction
This time maybe you want to sleep shutdown, then back to work after rebooting the steps are:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
Relevant knowledge points:
Now that the toolchain has been created, it is not necessary to establish tools links in the root directory.
6.2. Mounting Virtual Kernel File systems~6.8. Populating/dev
This time if you shut down or reboot, then the steps to return to work after rebooting are:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
4. Loading the necessary file system
Mount-v--bind/dev $LFS/dev
MOUNT-VT devpts devpts $LFS/dev/pts
MOUNT-VT Tmpfs SHM $LFS/DEV/SHM
MOUNT-VT proc proc $LFS/proc
MOUNT-VT Sysfs Sysfs $LFS/sys
5.Chroot to target system
Chroot "$LFS"/tools/bin/env-i \
Home=/root term= "$TERM" ps1= ' \u:\w\$ ' \
Path=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/tools/bin/bash--login +h
6.9. linux-libc-headers-2.6.11.2~6.59. Stripping Again
From now on until the sixth chapter of stripping again, this phase if you shut down or reboot, then the steps back to the working state after rebooting are:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
4. Loading the necessary file system
Mount-v--bind/dev $LFS/dev
MOUNT-VT devpts devpts $LFS/dev/pts
MOUNT-VT Tmpfs SHM $LFS/DEV/SHM
MOUNT-VT proc proc $LFS/proc
MOUNT-VT Sysfs Sysfs $LFS/sys
5.Chroot to target system
Chroot "$LFS"/tools/bin/env-i \
Home=/root term= "$TERM" ps1= ' \u:\w\$ ' \
Path=/bin:/usr/bin:/sbin:/usr/sbin:/tools/bin \
/bin/bash--login +h
6. Go to the compilation directory
Cd/sources

6.61. Stripping Again
If you restart now, then the steps to return to work after rebooting are:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
4. Loading the necessary file system
Mount-v--bind/dev $LFS/dev
MOUNT-VT devpts devpts $LFS/dev/pts
MOUNT-VT Tmpfs SHM $LFS/DEV/SHM
MOUNT-VT proc proc $LFS/proc
MOUNT-VT Sysfs Sysfs $LFS/sys
5.Chroot to target system
Chroot "$LFS"/tools/bin/env-i \
Home=/root term= "$TERM" ps1= ' \u:\w\$ ' \
Path=/bin:/usr/bin:/sbin:/usr/sbin \
/tools/bin/bash--login

6.62. Cleaning up~ End
From now until the end of production, the steps to return to the working state after rebooting are:
1. Restart the computer and boot from LiveCD
2. Loading partitions
Export Lfs=/mnt/lfs
MKDIR-PV $LFS
Mount/dev/sda2 $LFS
3. Load the Swap partition (skip this step if you do not want to swap the partition or have no swap partition)
Swapon/dev/sda1
4. Loading the necessary file system
Mount-v--bind/dev $LFS/dev
MOUNT-VT devpts devpts $LFS/dev/pts
MOUNT-VT Tmpfs SHM $LFS/DEV/SHM
MOUNT-VT proc proc $LFS/proc
MOUNT-VT Sysfs Sysfs $LFS/sys
5.Chroot to target system
Chroot "$LFS"/usr/bin/env-i \
Home=/root term= "$TERM" ps1= ' \u:\w\$ ' \
Path=/bin:/usr/bin:/sbin:/usr/sbin \
/bin/bash--login
6. Go to the compilation directory
Cd/sources

Customization and release of Linux (i)

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.