Custom CentOS5.1 (RedhatAS5.1) mounting disk

Source: Internet
Author: User
CentOS (Redhat) provides a complete set of automatic installation mechanisms. with this mechanism, we can customize the unattended automatic installation CD, or perform system reduction, you can even create system installation disks for your own software system based on CentOS. The following content is subject to CentOS5.1 & nbsp; custom installation disk CentOS (Redhat) provides a complete set of automatic installation mechanisms, we can customize the unattended automatic installation CD, cut the system, and even create the system installation disk of our software system based on CentOS.
All of the following content is subject to CentOS 5.1
 
Follow these steps to create a custom disk:
1. select necessary services to remove unnecessary RPM packages
2. Custom automatic installation process
3. Custom Installation Interface (optional)
4. generate a new installation disk
 
1. create a source disk
First, we need to create the source disk from the complete dvd version of CentOS 5.1. if we already have a complete CentOS5.1 dvd in the optical drive and the source disk is/disk, perform the following operations:
1. mount the dvd
# Mkdir/cdrom
# Mount? O loop/dev/cdrom
 
2. copy the CD content
# Mkdir/disk
# Cp? R/cdrom/./disk
 
3. clear non-essential RPM
Note: At this time, the/disk directory is actually a DVD backup scene. we need to select the RPM package required for custom disk installation based on the content in section 5th, then delete all unnecessary RPM in the/disk/CentOS directory to reduce the size of the installation disk.
 
After the above steps are completed, we already have a source disk that is basically the same as the original version, but completely removes the useless RPM Package. Subsequent customization work will be carried out in this path.
 
In a typical CentOS installation disk, the following directories and files are mainly related to CD customization:
/CentOS
/Isolinux
/Repodata
. Discinfo
Ks. cfg (not created yet)
 
The CentOS Directory stores all the RPM packages required during installation.
The isolinux Directory stores the installation interface information when the CD is started.
The repodata directory is the dependency information related to RPM Package installation.
. Discinfo is the identification information of CentOS, which is obtained directly from the CentOS DVD version. If this file is lost, the system prompts that the CentOS CD cannot be found during installation.
Ks. cfg is the master configuration file for automatic installation.
 
The automatic installation process of CentOS is as follows:
1. the CD is automatically guided to call the information in isolinux to generate the startup interface.
2. select ks. cfg as the installation control file based on user input.
3. go to the automatic installation process, install the RPM Package, configure the network, and perform hard disk partitioning based on ks. cfg.
4. after the system is installed, perform the customized installation process according to ks. cfg.
5. the installation is complete and the system restarts.
 
 
 
2. Custom startup interface
In isolinux, there are three files related to the custom installation interface.
Boot. msg defines how the startup interface is displayed
Isolinux. cfg determines how to process user input and execute the corresponding installation process
Splash. lss is the background image of the startup interface.
2.1 boot. msg
The content of boot. msg is roughly as follows:
 
^ L
^ Xsplash. lss
-XXXX auto-instiall, press the ^ O0f ^ O07 key to begin.
 
Use ctrl + X to input ^ X in the document.
 
^ Xsplash. lss indicates that splash. lss is used as the background image of the startup interface.
The following is the prompt message ^ content between O0f and ^ O07 on the startup page as highlighted.
 
2.2 isolinux. cfg
How does the system process user input after the isolinux. cfg settings go to the startup page.
The main content is as follows:
Default auto
Install auto segments by default
Prompt 1
Timeout 6000
Set the user input timeout time in seconds. Run the default installation process
Display boot. msg
Use boot. msg as the displayed startup interface
F1 boot. msg
F2 options. msg
F3 general. msg
F4 param. msg
F5 rescue. msg
F7 snake. msg
Label auto
Kernel vmlinuz
Append ks = cdrom:/ks. cfg initrd = initrd. img ramdisk_size = 8192 acpi = off noapic skipddc
Mark the auto segment and use the ks. cfg file under the root directory of the optical drive as the configuration file for kickstart.
Label manual
Kernel vmlinuz
Append ks = cdrom:/ks_manual.cfg initrd = initrd. img ramdisk_size = 8192 acpi = off noapic skipddc
Mark the manual segment and use the ks_manual.cfg file under the root directory of the optical drive as the configuration file for kickstart. If you enter manual on the startup interface
 
2.3 splash. lss
Splash. lss is the background image of the startup interface. this graphic file is special and can only be generated with 14 colors (standard 16 colors except black and white.
First, create a 16-color GIF file, named splash.gif.
Convert the file to lss format
# Giftopnm <splash.gif | ppmtolss16> splash. lss
 
3. customize the installation process
CentOS installation is mainly implemented by anaconda. it controls the entire installation process through the kickstart configuration file to achieve unattended installation.
For more information about the configuration of the kickstart file, see:
Http://www.redhat.com/docs/manuals/enterprise/RHEL-5-manual/en-US/RHEL510/Installation_Guide/ch-kickstart2.html
 
Before configuration, you need to create the target ks file
# Cd/disk
# Vi ks. cfg
 
The ks file is divided into three parts:
1. system installation and configuration
2. Custom installation preparation (% post -- nochroot)
3. Custom Installation (% post)
 
3.1 installation and configuration of the system
The kickstart file first sets the system, such as the machine language, time zone, keyboard, and other parameters, then checks whether the required RPM for installation is complete, and then formatted according to the partition information.
This part of configuration information is written at the beginning of the ks file, ending with "% post -- nochroot". The typical configuration information is as follows:
# System language
# Simplified Chinese system language
Lang zh_CN
# Language modules to install
# Language module to be installed and default language
Langsupport zh_CN -- default = zh_CN
# System keyboard
# System keyboard type
Keyboard us
# System mouse
Mouse
# Sytem timezone
# System time zone
Timezone Asia/Shanghai
# Root password
# Administrator password, value: encrypted string
Rootpw -- iscrypted $1 $ MGv8U4W0 $ BS7JLb3MZT70Z30mutWwO1
# Reboot after installation
# Automatic restart after installation
Reboot
# Use text mode install
# Use the text installation interface
Text
# Install OS instead of upgrade
Install
# Use CDROM installation media
# Use a CD as the installation media
Cdrom
# System bootloader configuration
Bootloader -- location = mbr
# Clear the Master Boot Record
Zerombr yes
# Partition clearing information
# Clear original partition information
Clearpart -- all -- initlabel
# Disk partitioning information
# Create a-m boot zone, a-m swap zone, and allocate the remaining disk space to the root path/
Part/boot -- fstype ext3 -- size 200 -- grow -- maxsize 500
Part swap -- size 300 -- grow -- maxsize 500
Part/-- fstype ext3 -- size 1 -- grow
# System authorization information
# Set the system verification method
Auth -- useshadow -- enablemd5
# Network information
# Using dhcp to obtain ip addresses
Network -- bootproto = dhcp -- device = eth0
# Firewall configuration
# Disable the firewall
Firewall -- disabled
Selinux -- disabled
# Do not configure XWindows
# Do not set xwindows
Skipx
# Package install information
% Packages? Resolvedeps
# The following are all the rpm packages to be installed by the system. assume that all the required packages are known and put in the/CentOS path.
Kernel
# Autoconf
# E2fsprogs
# Fonts-chinese
#...
 
Make sure that the RPM package to be installed and the RPM on which it depends are stored in the/CentOS Directory. in the ks configuration file, you only need to write the name of the RPM package to be installed, anaconda parses the dependency and automatically installs the associated package. If no package is required, an error is reported and the installation is terminated.
 
3.2 prepare for custom installation
The custom installation preparation starts with "% post -- nochroot" and ends with "% post. This script uses the bash syntax. in this script, you can copy your own installation package from the installation disc to the installed system.
Pay attention to two issues when writing scripts at this stage.
1. to access the disk path, add "/mnt/sysimage" before the target path. for example, copy a file to the/var/log Directory of the hard disk, the script should be # cp somefile/mnt/sysimage/var/log.
2. if you want to copy files from a CD to the hard disk, you need to mount the optical drive to the system first. However, depending on the motherboard, the device name of the CD is not necessarily/dev/cdrom, therefore, you may need to create a link as needed to mount the link, for example:
# Mkdir/mnt/cdrom/
The optical drive is a usb external optical drive, and a link is established.
# Ln-s/dev/sp_0/dev/cdrom
The mount device is read-only.
# Mount/dev/cdrom/mnt/cdrom/-o ro
 
3.3 custom installation
The custom installation starts with "% post". after the custom installation package is copied to the hard disk in the previous part, you can use the bash script to control the installation of the software. Note that you do not need to add "/mnt/sysimage" to access the disk path, as shown in figure
# Cp somefile/var/log
 
In addition, because the user's environment path has not been set at this time, it is best to bring the complete path name when calling the system command, such:
/Usr/sbin/groupadd xxxx
/Usr/sbin/adduser xxxx-g xxxx
4. Generate the installation disk
Now we have completed all the modifications to the custom installation CD, and we can create a CD image. To generate an ISO image of the installation disk, you must first install the createrepo and mkisofs software packages on the system.
 
First, you must synchronize the RPM package query information on the CD. Otherwise, the system will prompt that the RPM package cannot be found during installation.
# Createrepo-g/disk/repodata/comps. xml/disk/
Comps. xml is the function Group and dependency information of the RPM that comes with CentOS. createrepo needs to synchronize the information based on the file. it is recommended that you do not manually modify the file.
 
After successful synchronization, you can create an iso file. assume that the CD tag is sample and the output iso file name is/sample. iso.
# Cd/disk
# Mkisofs-o/sample. iso-A 'sample'-V 'sample'-B isolinux/isolinux. bin-c isolinux/boot. cat-no-emul-boot-load-size 4-allow-leading-dots-allow-m

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.