Custom centos 6.5 automatic installation CD
I. Prepare the production environment
Lab environment:
VMware Workstation
CentOS-6.5-x86_64-minimal minimal installation
After installation, we will use the install. log and anaconda-ks.cfg files under the system/root directory (which is easier to modify)
1. CD directory structure
* The isolinux directory stores the installation interface information when the CD is started.
* The images directory contains the necessary startup image files.
* The Packages directory stores the installation package and information.
* The discinfo file is the identifier of the installation price.
MediaCentOS directory stores the media center installation package
Store rpm package dependency information in the Repodata directory
5. x Series, boot. iso exists in the images/directory
6. x Series, stored in the/isolinux directory
6. Download The netinstall. iso image file from the official website.
2. Procedure
(1) install the minimal operating system, including the basic system and required tools (I will first achieve the minimum automatic installation)
For example, for http, mysql, and other software, it is recommended to install it by compiling and then package it in to reduce the trouble of many dependent packages.
(2) after installing the system, collect the software packages installed in the system and use scripts to uniformly store them in a directory.
(3) copy the images image on the installation disc and start centos from the disc to install the required files.
(4) define your own kickstart installation script.
(5) regenerate the repodata information of the CD based on the previously stored software (rpm) package.
(6) package and generate an ISO file and an MD5 verification code.
Ii. Operation Process record:
1. Install the required Toolkit
1
#yum-yinstallanacondarepodatacreaterepomkisofsrsync
2. Mount and copy files
Directory planning:
Mount Directory:/mnt
Custom CD file directory:/root/iso
[Root @ linuxidc ~] # Pwd
/Root
[Root @ linuxidc ~] # Mkdir iso # create an iso file directory
[Root @ linuxidc ~] # Mkdir-p./iso/{Packages, repodata} # create the package directory and repodata directory
[Root @ linuxidc ~] # Mount/dev/cdrom/mnt # mount a DVD
Mount: block device/dev/sr0 is write-protected, mounting read-only
# Copy all files in the Packages and repodata directories of the source DVD image to the iso directory.
[Root @ linuxidc ~] #/Usr/bin/rsync-a -- exclude = Packages -- exclude = repodata/mnt/./iso/
[Root @ linuxidc ~] # Ls iso
CentOS_BuildTag GPL Packages RPM-GPG-KEY-CentOS-6 RPM-GPG-KEY-CentOS-Testing-6
EFI images RELEASE-NOTES-en-US.html RPM-GPG-KEY-CentOS-Debug-6 TRANS. TBL
EULA isolinux repodata RPM-GPG-KEY-CentOS-Security-6
# Copy the installation package of the current system
[Root @ linuxidc ~] # Awk '/Installing/{print $2}' install. log | xargs-I cp/mnt/Packages /{}. rpm. /iso/Packages/# If the installation language is set to Chinese when Installing the system, the installation will be garbled.
[Root @ linuxidc ~] # Ls iso/Packages/| wc-l
205
# Execute the createrepo program to generate the comps. xml file under repodata (important)
# The comps. xml file contains all rpm-related content that the user sees during installation. It checks
# RPM package dependency. If the dependency package is missing during installation, it will prompt you which RPM package requires which dependent libraries.
[Root @ linuxidc ~] # Pwd
/Root
# Edit the shell script and execute
#! /Bin/bash
ISO_DIR =/root/iso
Cd $ {ISO_DIR}
Declare-x discinfo = $(head-1. discinfo)
Cp/mnt/repodata/*-minimal-x86_64.xml $ {ISO_DIR}/repodata/minimal-x86_64.xml
Createrepo-g $ {ISO_DIR}/repodata/minimal-x86_64.xml $ {ISO_DIR}
Createrepo-u "media: // $ discinfo"-g $ {ISO_DIR}/repodata/*-minimal-x86_64.xml $ {ISO_DIR}
The comps. xml file and other associated files have been regenerated to the repodata directory.
Tips: If you have added or deleted the RPM package in the Packages directory, generate a new comps. xml file.
3. Create the ks. cfg script.
The ks file is modified by the anaconda-ks.cfg created by the system installation, of course, it can also be made with the system-config-kickstart tool. You can modify the settings as needed:
Compile the. cfg file
Change ~ /Copy anaconda-ks.cfg ~ /Ios/isolinux/ks. cfg
The modified Ks. cfg content is as follows:
# Kickstartfileautomaticallygeneratedbyanaconda.
# Version = DEVEL
Install
# Text
Cdrom
# Set the installation Language
# Langen_US.UTF-8
Langzh_CN.UTF-8
Keyboardus
# SkiptheXconfiguration
Skipx
Network -- onbootno -- deviceeth0 -- bootprotodhcp -- noipv6
# Set the root password, which is centos
Rootpw -- iscrypted $6 $ q4pbJVjqD7ZmOEEq $ Encrypt
Firewall -- service = ssh
Authconfig -- enableshadow -- passalgo = sha512
Selinux -- enforcing
Timezone -- utcAsia/Chongqing
Bootloader -- location = mbr -- driveorder = sda -- append = "crashkernel = autorhgbquiet"
# Thefollowingisthepartitioninformationyourequested
# Notethatanypartitionsyoudeletedarenotexpressed
# Heresounlessyouclearallpartitionsfirst, thisis
# Notguaranteedtowork
# Clearpart -- linux -- drives = sda
# VolgroupVolGroup -- pesize = 4096pvs. 008002
# Logvol/-- fstype = ext4 -- name = lv_root -- vgname = VolGroup -- grow -- size = 1024 -- maxsize = 51200
# Logvolswap -- name = lv_swap -- vgname = VolGroup -- grow -- size = 1984 -- maxsize = 1984
# Part/boot -- fstype = ext4 -- size = 500
# Partpv.008002 -- grow -- size = 1
# Clearpart -- linux -- drives = sda
# Clearpart -- all -- initlabel
Clearpart -- all -- initlabel # This command must be added; otherwise, the system will ask the user to manually select whether to clear all data
# All hard drive partition tables are cleared! Clearpart -- all # partition clear the Partition Table of the vda hard disk. Do not clear the Partition Table of other hard disks! Clearpart -- drives = vda -- all
# Set partitions here
Part/boot -- fstype = ext4 -- size = 300 -- ondisk = sda
Part/home -- fstype = ext4 -- grow -- size = 1 -- ondisk = sda # use all the remaining space
Part/opt -- fstype = ext4 -- size = 3000 -- ondisk = sda
Part/var -- fstype = ext4 -- size = 2000 -- ondisk = sda
Part/-- fstype = ext4 -- size = 8000 -- ondisk = sda
Partswap -- recommended -- ondisk = sda
# Repo -- name = "CentOS" -- baseurl = cdrom: sr0 -- cost = 100 # comment out this sentence, or you will be prompted to find a valid repo named CentOS.
# The package to be installed @ starts with group. You can also specify a single package name, such as vim.
% Packages
@ Core
@ Server-policy
@ Workstation-policy
% End
# % Post -- nochroot
# Mountcdrom
#/Bin/mkdir-p/mnt/cdrom
#/Bin/mount-r-tiso9660/tmp/cdrom/mnt/cdrom
# Umountcdrom
#/Bin/umount/mnt/cdrom
% Post # This step is performed after the system is installed and can be customized.
/Bin/echo "mount-n-oremount, ro/">/etc/rc. local
/Bin/echo "tmpfs/tmptmpfsdefaults00">/etc/fstab
% End
# -- Rebootthehostafterinstallationisdone
Reboot
4. Modify the isolinux. cfg configuration file and specify the ks path.
Note: To edit this file, you must save it forcibly. : Wq!
# Vi./iso/isolinux. cfg
Defaultauto
# Defaultvesamenu. c32
# Prompt1
Timeout600
Displayboot. msg
Menubackgroundsplash.jpg
MenutitleWelcometoCentOS6.5!
Menucolorborder0 # ffffffff #00000000
Menucolorsel7 # ffffffff # ff000000
Menucolortitle0 # ffffffff #00000000.
Menucolortabmsg0 # ffffffff #00000000
Menucolorunsel0 # ffffffff #00000000.
Menucolorhotsel0 # ff000000 # ffffff
Menucolorhotkey7 # ffffffff # ff000000
Menucolorscrollbar0 # ffffffff #00000000
Labelauto
Kernelvmlinuz
Appendks = cdrom:/isolinux/ks. cfginitrd = initrd. img
Labellinux
Menulabel ^ Installorupgradeanexistingsystem
Menudefault
Kernelvmlinuz
Appendinitrd = initrd. img
Labelvesa
MenulabelInstallsystemwith ^ basicvideodriver
Kernelvmlinuz
Appendinitrd = initrd. imgxdriver = vesanomodeset
Labelrescue
Menulabel ^ Rescueinstalledsystem
Kernelvmlinuz
Appendinitrd = initrd. imgrescue
Labellocal
MenulabelBootfrom ^ localdrive
Localboot0xffff
Labelmemtest86
Menulabel ^ Memorytest
Kernelmemtest
Append-
5. generate an iso image and generate an MD5 verification code.
# Cd ~ /Iso
# Mkisofs-R-J-T-r-l-d-joliet-long-allow-multidot-allow-leading-dots-no-bak-o ../myos-0.1-x86.iso \
-Bisolinux/isolinux. bin-cisolinux/boot. cat-no-emul-boot-boot-load-size4-boot-info-table ./
9. Modify the background and text information of the CD. 9.1 modify the background image displayed during the automatic installation of the system. Modify the background and text information of the CD.
# Enter the cd/data/ISO/images/# install. the img image contains the background image used during the CD installation, mounting the imgfile mount-oloop-tsquashfsinstall.img/mnt/installmkdirtmp # mount the install. img cannot be edited. You need to copy it and replace it with the original install. imgfile rsync-av/mnt/install/tmp/# Enter the directory where the background image is located, select the image to be modified, and replace it (host image size, format must be the same as the original ), the image location is tmp/install/usr/share/anaconda/pixmaps # create a new install. imgmksquashfstmp/install_v1.img-all-root # Replace install. imgcptmp/install_v1.imginstall.img
9.2 modify the welcome speech during installation
Mkdir/data/ISO/isolinux/tmp # decompress initrd. img image xz-dc .. /initrd. img | cpio-id # modify the welcome speech. in the buildstamp file, replace CentOS with PowerSoftvim. buildstamp # create a new initrd. img and replace find. | cpio-c-o | xz-9 -- format = lzma> .. /initrd. img
Attachment download:
Ks. cfg: http://xiexiaojun.blog.51cto.com/2305291/1632139