Use CentOS to quickly build your own release

Source: Internet
Author: User
Editor's note: For many webmasters, it is very troublesome to resize the Linux system every time. Some IDC Technologies will not install Linux systems, or some will charge a certain amount for installing a system once. Therefore, it is important to create a simplified CentOS release. Let's take a look at the following...

Editor's note: For many webmasters, it is very troublesome to resize the Linux system every time. Some IDC Technologies will not install Linux systems, or some will charge a certain amount for installing a system once. Therefore, it is important to create a simplified CentOS release. Let's take a look at the specific production process.
I. specific LTOS production process
CD structure
* The isolinux Directory stores the installation interface information when the CD is started.
* The images directory contains the necessary startup image files.
* The CentOS Directory stores the installation package and information.
* The discinfo file is the identifier of the installation price.
* Lemp.tar.gz file storage system initialization and related program installation scripts.
"Environment description: CentOS 5.3-i386 Vmware Workstation.
1. install the basic software packages required to create the release
# Yum-y install anaconda-runtime createrepo yum-utils anaconda-help busybox-anaconda mkisofs2. create the ltos source folder
# Mkdir/ltos
# Mkdir/mnt/cdrom
# Mount-t iso9660-o loop/dev/cdrom/mnt/cdrom/Attach a CD image
Or mount the ISO file to/mnt/cdrom.
# Mount-t iso9660-o loop centos. xxx. iso/mnt/cdrom mount the ISO file of CentOS to the/mnt/cdrom Directory
# Cd/mnt/cdrom
# Tar-cf-. | (cd/ltos; tar-xvpf-) // Copy all files in/mnt/cdrom to the/ltsos Directory using tar.
# Cd/ltos // enter this directory to delete some irrelevant files, and continue to work later.
[Root @ server ltos] # ls-al
Total 88
Drwxr-xr-x 6 root 4096 Apr 11.
Drwxr-xr-x 27 root 4096 Apr 12 ..
Drwxr-xr-x 2 root 36864 Apr 8 CentOS
-Rw-r -- 1 root 97 Apr 8 16:43. discinfo
Drwxr-xr-x 4 root 4096 Mar 21 23:04 images
Drwxr-xr-x 2 root 4096 Apr 12 isolinux
-Rw-r -- 1 root 14371 Apr 11 lemp.tar.gz // This package is to be created later. you can analyze the ks later. the cfg script can understand its purpose.
Drwxr-xr-x 2 root 4096 Apr 11 repodata
-R -- 1 root 7048 Mar 21 TRANS. TBL3. custom package. list package list
For example, if you want to install a CentOS5.3 system, select a software package based on your needs. if you want your system to be small, we recommend that you select the minimum package. After the installation is complete, logs are generated in the system. The Japanese files are stored in/root/install. log.
# Cat install. log | grep Installing | sed's/Installing // g' | sed's/^ [0-9] \ +: // g'> packages. list
# Mkdir/ltos/CentOS: create a directory for storing rpm packages. create an automatic extraction rpm script:
# Vi cprpms. sh
#! /Bin/bash
DEBUG = 0
LT_CD =/mnt/cdrom
ALL_RPMS_DIR =/mnt/cdrom/CentOS # directory where the disk is attached
LT_RPMS_DIR =/ltos/CentOS # directory for storing RPM packages
Packages_list =/root/packages. list
Number_of_packages = 'cat $ packages_list | wc-L'
I = 1
While [$ I-le $ number_of_packages]; do
Line = 'head-n $ I $ packages_list | tail-n-1'
Name = 'echo $ line | awk' {print $1 }''
Version = 'echo $ line | awk' {print $3} '| cut-f 2-d :'
If [$ DEBUG-eq "1"]; then
Echo $ I: $ line
Echo $ name
Echo $ version
Fi
If [$ DEBUG-eq "1"]; then
Ls $ ALL_RPMS_DIR/$ name-$ version *
If [$? -Ne 0]; then
Echo "cp $ ALL_RPMS_DIR/$ name-$ version *"
Fi
Else
Echo "cp $ ALL_RPMS_DIR/$ name-$ version * $ LT_RPMS_DIR /"
Cp $ ALL_RPMS_DIR/$ name-$ version * $ LT_RPMS_DIR/
# In case the copy failed
If [$? -Ne 0]; then
Echo "cp $ ALL_RPMS_DIR/$ name-$ version *"
Cp $ ALL_RPMS_DIR/$ name * $ LT_RPMS_DIR/
Fi
Fi
I = 'expr $ I + 1'
Done executes the above script to copy the necessary rpm for customized ltos to the/ltos/CentOS Directory
Return to the/ltos directory and run the createrepo program to generate the comps. xml file under repodata.
# Cd/ltos
# Createrepo-g repodata/comps. xml. 4. configure the kickstart script
After the system is customized through CentOS5.3, a kickstart installation script (/root/anaconda-ks.cfg) will be generated in the system)
# Cp anaconda-ks.cfg/ltos/isolinux/ks. cfg
# Vi/ltos/isolinux/ks. cfg and modify the script as follows:
# Kickstart file automatically generated by anaconda.
# Install CentOS instead of Upgrade
Install
Text
# Install from cd-rom
Cdrom
Lang en_US.UTF-8
Keyboard us
# Skip the X Configuration
Skipx
Network -- device eth0 -- bootproto dhcp -- hostname ltos.linuxtone.org
Rootpw -- iscrypted $1 $ jPZf0P0r $ JRe7pd. 5wq9k. VZEMOgdq/
# Setup the firewall with SSH, HTTP/S, Syslog, Webmin, and Netflow enabled
Firewall -- enabled -- port = 22: tcp -- port = 69: udp -- port = 80: tcp -- port = 443: tcp
Authconfig -- enableshadow -- enablemd5
# Disable SELinux
Selinux -- disabled
Timezone -- utc Asia/Shanghai
# Clear the Bootloader and load it to the Master Boot Record
Bootloader -- location = mbr
Zerombr yes
# Set the Mouse
Mouse generic3ps/2
# The following is the partition information you requested
# Note that any partitions you deleted are not expressed
# Here so unless you clear all partitions first, this is
# Not guaranteed to work
Clearpart -- all -- initlabel
Part/boot -- fstype ext3 -- size = 100 -- asprimary
Part/-- fstype ext3 -- size = 25000
Part swap -- size = 4096
Part/data -- fstype ext3 -- size = 1 -- grow
# --- Reboot the host after installation is done
Reboot
% Packages
@ Development-libs
@ Editors
@ System-tools
@ Text-internet
@ Legacy-network-server
@ Dialup
@ Core
@ Base
@ Mail-server
@ Development-tools
Audit
Net-snmp-utils
Sysstat
Iptraf
Dstat
Tftp
Lynx
Device-mapper-multipath
Imake
-Zsh
-Vnc
-Zisofs-tools
-Xdelta
-Openldap-clients
-Samba-client
-Fetchmail
-Dovecot
-Spamassassin
#
# ------- Begin LEMP Install ---------
#
% Post -- nochroot
# Mount CDROM
Mkdir-p/mnt/cdrom
Mount-r-t iso9660/tmp/cdrom/mnt/cdrom
# Copy our tar file and extract it
Cp/mnt/cdrom/lemp.tar.gz/mnt/sysimage/tmp/lemp.tar.gz>/dev/null
Cd/mnt/sysimage/tmp/
Tar-zxvf lemp.tar.gz>/dev/null
# Move the contents of the tar into their new locations
Cp-R/mnt/sysimage/tmp/boot/*/mnt/sysimage/boot/>/dev/null 2>/dev/null
Cp-R/mnt/sysimage/tmp/etc/*/mnt/sysimage/etc/>/dev/null 2>/dev/null
# Unmount CDROM
Umount/mnt/cdrom
% Post
# Vim syntax on
Sed-I "8 s/^/alias vi = 'vim '/"/root/. bashrc 2>/dev/null
Echo 'syntax on'>/root/. vimrc 2>/dev/null
# Disable IPv6 until Cacti at least supports it
Echo "alias net-pf-10 off">/etc/modprobe. conf
Echo "alias ipv6 off">/etc/modprobe. conf
/Sbin/chkconfig -- level 35 ip6tables off
# Init_ssh
Ssh_cf = "/etc/ssh/sshd_config"
Sed-I-e '74 s/^/#/'-I-e '76 s/^/#/' $ ssh_cf
Sed-I "s/# UseDNS yes/UseDNS no/" $ ssh_cf
# Client
Sed-I-e '44 s/^/#/'-I-e' 48 s/^/#/'$ ssh_cf
# Remove the ISO File translation files
Find/-name TRANS. TBL-exec rm {}\;/dev/null 2>/dev/null
# Remove some unneeded services
#--------------------------------------------------------------------------------
Cat <EOF
+ -------------------------------------------------------------- +
| === Welcome to Tunoff services ===|
+ -------------------------------------------------------------- +
EOF
#---------------------------------------------------------------------------------
For I in 'ls/etc/rc3.d/S *'
Do
CURSRV = 'echo $ I | cut-c 15 -'
Echo $ CURSRV
Case $ CURSRV in
Crond | irqbalance | microcode_ctl | network | random | sendmail | sshd | syslog | local | mysqld)
Echo "Base services, Skip! "
;;
*)
Echo "change $ CURSRV to off"
Chkconfig -- level 235 $ CURSRV off
Service $ CURSRV stop
;;
Esac
Done
# File descriptors
Ulimit-HSn 65535
Echo-ne"
* Soft nofile 65536
* Hard nofile 65536 ">/etc/security/limits. conf5. enable the system to start from kickstart configuration
# Vi/ltos/isolinux. cfg
Default auto
Prompt 1
Timeout 600
Display boot. msg
F1 boot. msg
F2 options. msg
F3 general. msg
F4 param. msg
F5 rescue. msg
Label linux
Kernel vmlinuz
Append initrd = initrd. img
Label text
Kernel vmlinuz
Append initrd = initrd. img text
Label auto
Kernel vmlinuz
Append ks = cdrom:/isolinux/ks. cfg initrd = initrd. img
Label ks
Kernel vmlinuz
Append ks initrd = initrd. img
Label local
Localboot 1
Label memtest86
Kernel memtest
Append-

2. customize your system (Q & A form)
1. how to customize the installation boot screen:
The startup screen is in a strange format, which limits the use of 16 colors, except that the foreground and background colors only have 14 colors. We need ppmtolss16 giftopnm and other programs. The system is generally installed by default.
Generally, gimp is used to generate an index-based gif image with a color limit of 14. then, convert it using the following method:
Install yum-y install syslinux
Giftopnm <splash.gif | ppmtolss16> splash. lss
In addition, you also need to modify the isolinux/boot. msg file to make some personalized prompts.
? How to generate high-quality graphs.
Open any image in photoshop, and select "Save as WEB and device format" in the drop-down menu of the file. then select gif and save it in 16 colors.
Still use giftopnm <splash.gif | ppmtolss16> splash. lss conversion.
2. how to generate GRUP xpm files?
(1) prepare a 640x480 16-color image in JPG format.
(2) convert grub.gif-colors 14-geometry 640x480! Splash. xpm & gzip-9 splash. xpm
(3) directly replace the/boot/grup/splash.xpm.gz file.
? Images generated using the above method may not be displayed, or the quality is not high. how can we generate high-quality grub images.
Replace the files in the/boot/grup directory directly.
3. how can I remove the words CentOS during installation?
The installation disc contains two. buildstamp files, one in stage2.img and the other in initrd. img,
When the installation disc is running, the. buildstamp file in initrd. img is read, so you only need to change the initrd. imgfile.
How to decompress the initr. dimg file:
In Kernel 2.6, initrd. img adopts cpio compression. it is no longer in the ext2 format used by kernel 2.4 and cannot be mounted using mount-o loop. You need to use gunzip to decompress and then use
Use cpio to unpackage img
# Cd/ltos/isolinux/
# Cp initrd. img/tmp/initrd.img.gz
# Cd/tmp
# Gunzip initrd.img.gz
# Mkdir initrd
# Mv initrd. img initrd
# Cd initrd
# Cpio-ivmd <initrd. img. modify the. buildstamp file and change CentOS to LTOS.
How to create an initrd. imgfile:
# Assume that the current directory is in the root directory of the prepared initrd file system.
# Find. | cpio-c-o> ../initrd. img
# Gzip ../initrd. img
# Mv initrd.img.gz initrd. img
# Cp initrd. img/ltos/isolinux/copy initrd. img to/ltos/isolinux/
4. how do I replace grub after installation?
Replace the splash.xpm.gz file in the ks.htm file of the installation disc.
5. how to remove "CentOS release 5 (Final)" from the startup process )"
Write the script in the ks. cfg file on the installation disc and replace/etc/redhat-release directly.
3. package and generate an ISO file for release
# Cd/ltos
# Declare-x discinfo = 'head-1. discinfo'
# Createrepo-u "media: // $ discinfo"-g repodata/comps. xml. generate an ISO file
# Mkisofs-R-J-T-r-l-d-allow-multidot-allow-leading-dots-no-bak-o/tmp/ltos-0.1-i386.iso \
-B isolinux/isolinux. bin-c isolinux/boot. cat-no-emul-boot-load-size 4-boot-info-table. Md5
/Usr/lib/anaconda-runtime/implantisomd5-tmp/ltos-0.1-i386.iso

IV. demo of the effect of installing the CD
Start the installation disc

 
Grub interface

 
System logon interface demonstration

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.