Centos5.3_64定制

Centos5.3_64定制
2010-05
整理:Chenxin
光盘结构介绍
*isolinux 目录存放光盘启动时的安装界面信息
*images 目录包括了必要的启动映像文件
*CentOS 目录存放安装软件包及信息
.discinfo 文件是安装价质的识别信息(是光盘中的隐藏文件,需要拷贝到指定目录下)
//
lemp.tar.gz 文件存放系统初始化及其相关程序安装脚本.

环境说明:CentOS 5.3-i386_64 Vmware Workstation上完成制作工作.

准备工作:
VMware // 虚拟机
Secure // SSH连接工具
1、在VM安装linux系统
安装anaconda repodata createrepo mkisofs ,尽量采用yum安装//定制过程需要产生comps.xml文件以及生成iso

  1. yum -y install anaconda repodata createrepo mkisofs#安装制作发行版所需的基本软件包
    
  2. yum -y install anaconda-runtime createrepo yum-utils anacondaanaconda-help busybox-anaconda mkisofs
    

2、生成packages.list 所安装的RPM包文件清单(由于install.log文件在root目录,所以该操作在root目录进行)
cat install.log | grep Installing | sed 's/Installing //g' > /root/packages.list
:%s/^.*😕/g

生成后,需要仔细看该文件,一般会在某些文件开始部分如“1:”这样的字符,需要删除这些字符,否在后面执行copy动作会报错,注意引项为英文版Shell

3、建立定制Centos的源目录

  1. mkdir /disk     #定制时要复制RPM包的目录
    
  2. mkdir /mnt/cdrom   #加载光驱目录
    
  3. mount -o loop /dev/cdrom /mnt/cdrom     #将光盘内容加载到/mnt/cdrom中
    
  4. cd /mnt/cdrom/   #复制光盘内容到disk文件下,或者
    
  5. cp -aprf $(ls /mnt/cdrom |grep -v "CentOS") /disk
    
  6. mkdir /disk/CentOS/   #创建RPM包存放目录
    

4、通过脚本复制系统安装的包;

!/bin/bash

DEBUG=0
DVD_CD=/disk/CentOS
ALL_RPMS_DIR=/mnt/cdrom/CentOS/
DVD_RPMS_DIR=$DVD_CD
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* $DVD_RPMS_DIR/"
            cp $ALL_RPMS_DIR/$name$version* $DVD_RPMS_DIR/
            # in case the copy failed
            if [ $? -ne 0 ] ; then
                    echo "cp $ALL_RPMS_DIR/$name$version* "
                    cp $ALL_RPMS_DIR/$name* $DVD_RPMS_DIR/
            fi
    fi
    i=`expr $i + 1`

done

将以上内容保存为copyrpms.sh

  1. chmod 775 copyrpms.sh
    
  2. ./copyrpms.sh
    

经过一系列的复制就完成了你要定制的RPM包(在/disk/CentOS/目录下);
5、定制安装控制文件ks.cfg
一般方便可以直接由root下面的anaconda-ks.cfg修改

  1. cp anaconda-ks.cfg /disk/ks.cfg
    

样例内容如:

Kickstart file automatically generated by anaconda.

install
cdrom
lang zh_CN.UTF-8
keyboard us
network --device eth0 --bootproto static --ip 192.168.21.154 --netmask 255.255.255.0 --gateway 192.168.21.1 --nameserver 202.98.96.68,202.96.209.133 --hostname CentOSCustom

rootpw --iscrypted $1$hj66ggPY$uu29tX5xMmwn/pa7CpVm81

firewall --disabled
authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda

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 --linux --drives=sda

part /boot --fstype ext3 --size=100 --ondisk=sda

part pv.2 --size=0 --grow --ondisk=sda

volgroup VolGroup00 --pesize=32768 pv.2

logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow

logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=512 --grow --maxsize=1024

%packages
@development-libs
@editors
@core
@base
@chinese-support
@development-tools
device-mapper-multipath
imake
%post
sed -i 's/id:5:initdefault:/id:3:initdefault:/g' /etc/inittab
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
chkconfig --list |awk '{ print $1 }'|grep -v "^crond" |grep -v "^network" |grep -v "^sshd"|grep -v "^syslog" > chkconfig.txt;for i in cat ./chkconfig.txt; do { chkconfig --level 3 $i off; } done

reboot

示例新装的:anaconda-ks.cfg

Kickstart file automatically generated by anaconda.

install
cdrom
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto static --ip 61.160.192.254 --netmask 255.255.255.0 --gateway 61.160.192.1 --nameserver 202.96.209.133,202.98.96.68 --hostname YenetCentos
rootpw --iscrypted $1$VJTECYBV$F1ICs8glrJSwME88NdLby0
firewall --enabled --port=22:tcp
authconfig --enableshadow --enablemd5
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda

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 --linux

part /boot --fstype ext3 --size=100 --asprimary

part / --fstype ext3 --size=3000 --asprimary

part /home --fstype ext3 --size=1000

part swap --size=520

part /data --fstype ext3 --size=1 --grow

%packages
@development-libs
@editors
@core
@base
@development-tools
device-mapper-multipath
imake

备注1:分区

Disk partitioning information

bootloader --location=mbr --driveorder=sda,hda
clearpart --all --initlabel
part /boot --fstype=ext3 --size=100 --asprimary
part / --fstype=ext3 --size=20000 --asprimary
part swap --fstype=swap --recommended
part /home --fstype=ext3 --size=20000
part /data --fstype=ext3 --grow --maxsize=100000

参考:

part the disk######

bootloader --location=mbr --driveorder=sda,hda
clearpart --all --initlabel
part /boot --fstype=ext3 --size=200 --asprimary
part swap --fstype=swap --recommended
part / --fstype=ext3 --grow --size=1

能否使用”%”? 不能

备注2:示例

Package install information

%packages --resolvedeps
@ X Window System
@ GNOME Desktop Environment
@ Editors
@ Server Configuration Tools
@ Web Server
@ Mail Server
@ Windows File Server
@ DNS Name Server
@ FTP Server
@ Network Servers
%post
echo "nameserver 192.168.0.254" >> /etc/resolv.conf

备注3:kickstart语法
kickstart 語法
接下來探討 ks.cfg 的相關參數,這些參數筆者將依上述ks,cfg 出現的先後順序來討論,有些參數並不是一定要設定。完整的kickstart 參數意義可參考下列網址。
http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/sysadmin-guide/s1-kickstart2-options.html
ks.cfg 檔由三個部份皆組成:
command 區段— 此部份包含了必要安裝選項
packages 區段— 列出欲安裝套件
%pre and %post 區段
package 區段
安裝一個新的系統,你必需選擇你想安裝的套件。選擇欲安裝的套件是使用%packages 指令。套件可分為單一套件或者是套件組。你能在第一片Red Hat安裝光碟下的/base/comps.xml 尋找群組套件清單。通常,只需列出套件組不需要列出單一套件。注意!預設之下 core 和base 群組是被選取的,所以也不需要在 %packages 這個區段下去指定它們。
如同利用 ksconfig 所產生出來的ks.cfg %packages 區段中套件組是一行指定一個,以@節號開頭,後面加上一格空白接下來是完整群組名稱就如同comps.xml 檔案所指定。如果個別單一套件並列出該單一套件名,不加上額外的字元。套件組是一行指定一個,以@節號開頭,後面加上一格空白接下來是完整群組名稱就如同comps.xml 檔案所指定。如果是個別單一套件則列出該單一套件名,前面不需加上額外的字元。
%package 有三個選項可以設定:
--resolvedeps
決解自動相依性問題及安裝套件。建意選項,在安裝中由於沒使用自動決解相依性,若有相依性問題可能會造成中止安裝並且做提示回應。
--ignoredeps
你選擇安裝套某套件但乎略它的相依性,可能造成此套件無法運作,尤其是此套件需要其它相依的套件。
—ignoremissing
標示忽視安裝遺失套件及群組並且也不做提示回應。
%pre and %post 區段
%pre 區段內可填入在開始安裝作業系統需要先執行的工作。
%post 指令傳遞到系統上執行必須在Kickstart 安裝完成後。能有效的執行指令
去安裝其他的軟體或者設定系統組態。

6、修改isolinux.cfg文件 // 将/disk/isolinux/目录下的isolinux.cfg文件第一行default linux修改成default linux ks=cdrom:/ks.cfg
样例文件如:

  1. default linux ks=cdrom:/ks.cfg
    
  2. prompt 1
    
  3. timeout 60
    
  4. display boot.msg
    
  5. F1 boot.msg
    
  6. F2 options.msg
    
  7. F3 general.msg
    
  8. F4 param.msg
    
  9. F5 rescue.msg
    
  10. label linux
    
  11.   kernel vmlinuz
    
  12.   append initrd=initrd.img
    
  13. label text
    
  14.   kernel vmlinuz
    
  15.   append initrd=initrd.img text
    
  16. label ks
    
  17.   kernel vmlinuz
    
  18.   append ks initrd=initrd.img
    
  19. label local
    
  20.   localboot 1
    
  21. label memtest86
    
  22.   kernel memtest
    
  23.   append -
    

7、生成comps.xml
cd /disk/
createrepo -g repodata/comps.xml /disk/
该文件comps.xml来自于系统光盘,且未发生改变;
到此以上定制任务已经完成。

切记,要把光盘中的“.discinfo” 文件拷贝过来,如果没有拷贝此文件,在用光盘安装时会提示如下错误:“The CentOS CD was not found in any of your CDROM drives. Please insert the CentOS CD and press OK to retry.”

8、制作IOS文件
cd /disk/
mkisofs -o MyCentOS.iso -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -R -J -v -T /disk/
/disk/ 目录下产生的MyCentOS.iso 生成的ISO文件。
再用winscp把ISO文件拷出来拿到虚拟机实验,如果OK那就没问题了!

为何 只有在图形界面安装模式下配置文件才生效呢?!

备注1:
在准备制作 ISO 的目录里添加一个子目录,比如 boot/isolinux/ ,然后放入 isolinux.cfg 和一个对所有光盘都一样的 isolinux 提供的引导介质 isolinux.bin,当然还要放入相应的 kernel, initrd 等等,然后,制作 iso 的时候要使用 -b 参数:
mkisofs -o output.iso -b boot/isolinux/isolinux.bin -c boot/isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table for-iso-dir/
最后的参数就是指定的光盘的目录了,-c 参数的那个文件是自动生成的,不用太担心,其余参数都是固定的。事实上,也常常有人用 isolinux/ 而不是 boot/isolinux/ ,这都是约定俗成的,你完全可以用自己的。这里的路径都是相对于光盘的根的,而和制作光盘时的工作目录没有关系。

安装完成后,系统并未关闭iptables,但selinux关掉了;
安装时,不再需要选择软件包,分区和root密码需要自定;

附录1:

CentOS(Redhat)提供了一套完整的自动化安装机制,利用该机制,我们可以自己定制无人值守的自动安装光盘,也可以进行系统裁减,甚至可以以 CentOS为基础制作自己软件系统的系统安装盘。

以下全部内容以CentOS 5.1版本为准

自定制安装盘主要有以下 几个步骤

1、选取必要服务,去除不必要的RPM包

2、定制自动安装过程

3、定制安装界面(可选)

4、 生成新安装盘

1 创建源盘

首先我们需要从CentOS 5.1的完整dvd版本创建源盘,假设我们已经有一个完整的CentOS5.1的dvd放在光驱中,源盘的位置为/disk,则执行以下操作

  1. mount dvd

mkdir /cdrom

mount –o loop /dev/cdrom /cdrom

2.复制光盘内容

mkdir /disk

cp –R /cdrom/. /disk

  1. 清除非必须的RPM

注意,此时/disk目录下实际上是一个DVD的备份景象,我们需要根据第5节的内容选取自定义安装盘所需的RPM 包,然后在/disk/CentOS目录里删除所有不必要的RPM,以减小安装盘容量。
上述步骤完成后,我们已经有了一个与原版DVD基本相同, 但是完全去除了无用RPM包的源盘,后续的定制工作将在该路径中进行。
典型的CentOS安装盘中,与光盘定制有关的主要有以下几个目录和文件:

/CentOS

/isolinux

/repodata

.discinfo

ks.cfg(此 时尚未创建)

CentOS目录存放所有在安装过程中需要使用的RPM包

isolinux目录存放光盘启动时的安装界面信 息

repodata目录是与RPM包安装相关的依赖信息

.discinfo是CentOS的识别信息,直接从 CentOS DVD版本中获取,如果该文件丢失,会导致安装过程中,系统提示找不到CentOS光盘

ks.cfg是自动安装过程的主控 配置文件
CentOS的自动安装过程如下:

1、光盘自动引导,调用isolinux中的信息生成启动界面

2、根 据用户输入,选择ks.cfg作为安装控制文件

3、进入自动安装过程,根据ks.cfg安装RPM包、配置网 络、进行硬盘分区等等

4、系统安装完成后,根据ks.cfg进行用户自定义的安装过程

5、安装完成,系统 重起

2 自定义启动界面

在isolinux里面有三个文件和自定义安装界面有关

boot.msg是定义 启动界面如何显示

isolinux.cfg决定如何处理用户的输入,并执行对应的安装过程

splash.lss是启动界 面的背景图片
2.1 boot.msg

boot.msg内容大致如下:

^L

^Xsplash.lss

  • XXXX auto-instiall, press the O0f<ENTER>O07 key to begin.
    文档中的^X用 ctrl+X输入

^Xsplash.lss表示使用splash.lss作为启动界面的背景图片

后面就是启动时界面下的 提示信息O0f和O07之间的内容作为高亮显示

2.2 isolinux.cfg

isolinux.cfg 设置进入启动页面后,系统如何处理用户输入。

主要内容如下:

default auto

默认执行auto 段的安装进程

prompt 1

timeout 6000

设置用户输入的超时时间,单位:秒。超时未输入 则执行默认的安装进程

display boot.msg

将boot.msg作为显示的启动界面

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

标记auto段,使用光驱根目录下的ks.cfg 文件作为kickstart的配置文件

label manual

kernel vmlinuz

append ks=cdrom:/ks_manual.cfg initrd=initrd.img ramdisk_size=8192 acpi=off noapic skipddc

标记manual段,使用光驱根目录下的ks_manual.cfg文件作为kickstart的配置文 件。如果用户在启动界面输入manual,则执行该段

2.3 splash.lss

splash.lss是启动 界面的背景图片,该图形文件比较特殊,只能使用14色(标准16色除去黑白两色)的原始图片来生成。

首先创建一个16色(包含黑白两色) 的gif文档,名为splash.gif

将该文件转换为lss格式

giftopnm < splash.gif | ppmtolss16 > splash.lss

3 自定义安装过程

CentOS的安装主要是由 anaconda来实现的,它通过kickstart配置文件来控制整个安装进程,以到达无人值守安装的效果。

kickstart文件具 体配置可以参看:

http://www.redhat.com/docs/manua ... /ch-kickstart2.html

进行配置前,需要创建目标ks文件

cd /disk

vi ks.cfg

ks文件主要分为三个部分

1、系统安装及配置

2、自定义安装准备(%post --nochroot)

3、用户自定义安装(%post)

3.1 系统安装及配置

kickstart 文件首先进行系统的设置,比如机器语言、时区、键盘等参 数的设置,然后检查安装所需RPM是否都完整,然后根据分区信息进行格式化。

这部分配置信息写在ks文件的最前面,以 “%post --nochroot”为结束,典型的配置信息如下:

System language

系统语言 简体中文

lang zh_CN

Language modules to install

要安装的语 言模块以及默认语言

langsupport zh_CN --default=zh_CN

System keyboard

系统键盘类型

keyboard us

System mouse

mouse

Sytem timezone

系统时区

timezone Asia/Shanghai

Root password

管 理员密码,值为已加密字符串

rootpw --iscrypted $1$MGv8U4W0$BS7JLb3MZT70Z30mutWwO1

Reboot after installation

安装完成后是否自动重起

reboot

Use text mode install

使用文本安装界面

text

Install OS instead of upgrade

install

Use CDROM installation media

使用光盘作为安装媒体

cdrom

System bootloader configuration

bootloader --location=mbr

Clear the Master Boot Record

zerombr yes

Partition clearing information

清除原有分区信息

clearpart --all --initlabel

Disk partitioning information

建立一个200-500M的引导区,一个300-500M的交换区,剩余磁 盘空间划分给根路径/

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

设置系统验证方式

auth --useshadow --enablemd5

Network information

使用dhcp获取ip

network --bootproto=dhcp --device=eth0

Firewall configuration

关闭防火墙

firewall --disabled

selinux --disabled

Do not configure XWindows

不设置xwindows

skipx

Package install information

%packages –resolvedeps

以下全部是系统需要安装的rpm包,我们假设此时已经知道所有需要的包,并且全部放在/CentOS路径下

kernel

autoconf

e2fsprogs

fonts-chinese

...

请 注意必须保证要安装的RPM包以及被依赖的RPM都存放在/CentOS目录下,在ks配置文件里只需要写要安装的RPM包名即可,anaconda会解 析依赖关系并自动安装关联的包,如果没有需要的包,则会报错并终止安装。
3.2 自定义安装准备

自定义安装准备部分以 “%post --nochroot”作为开始,以“%post”作为结束。该部分脚本使用bash语法,通常在这一段脚本中将用户自己的安装包从安装光盘复制到已经安 装好的系统上。

这一阶段的脚本编写需要注意两个问题

1、此时要访 问磁盘路径,则要在目标路径前增加“/mnt/sysimage”,例如要将某个文件复制硬盘的/var/log,则脚本应为#cp somefile /mnt/sysimage/var/log。

2、如果要从光盘复制文件到硬盘,需要先将光驱mount到系统,但是 根据主板不同,此时的光盘设备名不一定是/dev/cdrom,所以可能需要根据自己的情况创建一个link,以便进行mount,如:

mkdir /mnt/cdrom/

光驱为usb外接光驱,建立链接

ln -s /dev/scd0 /dev/cdrom

mount 设备为只读

mount /dev/cdrom /mnt/cdrom/ -o ro

3.3 自定义安装

自 定义安装部分以“%post”作为开始,在前一部分将自定义安装包复制到硬盘之后,就可以在这里使用bash脚本进行软件的安装控制了。唯一需要注意的 是,此时访问磁盘路径已经不需要添加“/mnt/sysimage”,直接访问即可,如

cp somefile /var/log

此 外,因为此时还没有设置用户的环境路径,所以调用系统命 令时最好尽量带上完整地路径名,如:

/usr/sbin/groupadd xxxx

/usr/sbin/adduser xxxx -g xxxx
4 生成安装盘

现在我们已经完成了自定义安装光盘的全部调整,就可以制作光盘镜像了。生成安装盘 ISO镜像,需要先在系统安装好createrepo和mkisofs两个软 件包。

首先,必须同步光盘中RPM包的查询信息,否则安装过程中会提示找不到RPM包

createrepo -g /disk/repodata/comps.xml /disk/

comps.xml是CentOS自带的 RPM所属功能组以及依赖关系的信息,createrepo需要根据该文件来同步信息,最好不要手动修改该文件。

同步成功之后,就可以进 行iso的创建了,我们假定光盘标签为sample,输出iso文件名为/sample.iso

cd /disk

mkisofs -o /sample.iso -A ‘sample’ -V ‘sample’ -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -allow-leading-dots -allow-multidot -udf -R -r -T -boot-info-table -J /disk/

该命令执行成功之 后就会在生成sample.iso的镜像,刻录到光盘上就可以作为自制CentOS安装盘使用了。
5 裁减RPM包

CentOS 5.1完整版本容量接近4G,其中大部分功能包都不是必要的,完整安装不仅耗费磁盘空间,增加安装时间,还会因为运 行无用服务影响系统性能,所以必须要对RPM包裁减。

RPM裁减,即是选出需要的包,去掉其他无用包。但是Linux下 安装RPM时,常常还需要依赖其他包,否则安装会失败,而被依赖的RPM包也常常需要依赖其他包,经常导致多层依赖,手动检查起来非常麻烦。还好 CentOS提供了RPM包安装工具yum,我们可以通过这个工具自动获取所有的关联包。

5.1准备工作:

1、 安装 yum

2、 准备CentOS 5.1完整版的DVD
yum查找RPM依赖包,首先需要提供全部可用RPM,yum会自动检查 RPM包并检查关联信息,以确定所依赖的RPM包,所以首先我们要准备好全部RPM。
5.2加载光盘的RPM

cd /mnt

mkdir cdrom

mount –o loop /dev/cdrom cdrom

加载完成后,/mnt/cdrom /CentOS就是RPM包的存放位置

5.3设置yum的RPM搜索信息

cd /etc/yum.repos.d/

ls

CentOS-Base.repo CentOS-Media.repo

该 目录有两个文件,第一个文件是从网络读取RPM信息的配置文件,第二个是从本地媒体读取RPM信息的配置文件,因为yum优先从网络读取信息,所以我们必 须修改第一个文件的名字,强制yum从本地媒体搜索文件。

mv CentOS-Base.repo CentOS-Base.repo.bak

然后修改CentOS-Media.repo,把搜索位置指向/mnt/cdrom/,那么 yum会自动在/mnt/cdrom/repodata的repomd.xml去寻找信息

vi CentOS-Media.repo

修 改内容如下:

baseurl=file:///mnt/cdrom/

file:///media/cdrom/

file:///media/cdrecorder/

gpgcheck=1

enabled=1

rpm --import /mnt/cdrom/RPM-GPG-KEY-beta

5.4 获取依赖包信息

按照上面步骤配置完成之 后,就可以自动获取依赖包了。以下以获取selinux-policy相关依赖包为例
进入RPM存放目录

cd /mnt/cdrom/CentOS

使用指令尝试安装目标RPM包

yum install selinux-policy

则yum输出类似如下信息:

Dependencies Resolved

Package Arch Version Repository Size

=============================================================================

Installing:

selinux-policy noarch 2.4.6-104.el5 c5-media 365 k

Installing for dependencies:

libsemanage i386 1.9.1-3.el5 c5-media 135 k

Transaction Summary

=============================================================================

Install 2 Package(s)

Update 0 Package(s)

Remove 0 Package(s)

Total download size: 500 k

Is this ok [y/N]:

显 然,根据检索结果libsemanage是安装selinux-policy所依赖的RPM包。此时可以选择N则返回命令行,选择y则会自动安装 selinux-policy及其所有依赖包。

我们可以通过这种方式获取,我们所需RPM包的全部依赖包,然后将其他无关包全部裁减掉。

附录2:

28.5. Package Selection
Use the %packages command to begin a kickstart file section that lists the packages you would like to install (this is for installations only, as package selection during upgrades is not supported).
Packages can be specified by group or by individual package name, including with globs using the asterisk. The installation program defines several groups that contain related packages. Refer to the variant/repodata/comps-*.xml file on the first Red Hat Enterprise Linux CD-ROM for a list of groups. Each group has an id, user visibility value, name, description, and package list. In the package list, the packages marked as mandatory are always installed if the group is selected, the packages marked default are selected by default if the group is selected, and the packages marked optional must be specifically selected even if the group is selected to be installed.
In most cases, it is only necessary to list the desired groups and not individual packages. Note that the Core and Base groups are always selected by default, so it is not necessary to specify them in the %packages section.
Here is an example %packages selection:
%packages
@ X Window System
@ GNOME Desktop Environment
@ Graphical Internet
@ Sound and Video dhcp
As you can see, groups are specified, one to a line, starting with an @ symbol, a space, and then the full group name as given in the comps.xml file. Groups can also be specified using the id for the group, such as gnome-desktop. Specify individual packages with no additional characters (the dhcp line in the example above is an individual package).
You can also specify which packages not to install from the default package list:
-autofs
The following options are available for the %packages option:
--nobase
Do not install the @Base group. Use this option if you are trying to create a very small system.
--resolvedeps
The --resolvedeps option has been deprecated. Dependencies are resolved automatically every time now.
--ignoredeps
The --ignoredeps option has been deprecated. Dependencies are resolved automatically every time now.
--ignoremissing
Ignore the missing packages and groups instead of halting the installation to ask if the installation should be aborted or continued. For example:
%packages --ignoremissing

附录3:最终确定的ks.cfg文件内容:
[root@CentOSCustom disk]# cat ks.cfg

Kickstart file automatically generated by anaconda.

text

install
cdrom
lang en_US.UTF-8
keyboard us
network --device eth0 --bootproto static --ip 61.160.192.254 --netmask 255.255.255.0 --gateway 61.160.192.1 --nameserver 202.96.209.133,202.98.96.68 --hostname YenetCentos
rootpw --iscrypted $1$VJTECYBV$F1ICs8glrJSwME88NdLby0
firewall --disabled

firewall --enabled --port=22:tcp

authconfig --enableshadow --enablemd5
selinux --disabled
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda

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 --linux
part /boot --fstype ext3 --size=100 --asprimary
part / --fstype ext3 --size=3000 --asprimary
part /home --fstype ext3 --size=1000
part swap --size=520
part /data --fstype ext3 --size=1 --grow

%packages
@editors
@core
@base
@development-tools
device-mapper-multipath
imake
lrzsz
ntp

%post
/bin/sed -i 's/id:5:initdefault:/id:3:initdefault:/g' /etc/inittab
/bin/sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
/sbin/chkconfig --list |/bin/awk '{ print $1 }'|/bin/grep -v "^crond" |/bin/grep -v "^network" |/bin/grep -v "^sshd"|/bin/grep -v "^syslog" > chkconfig.txt;for i in /bin/cat ./chkconfig.txt; do { chkconfig --level 3 $i off; } done

posted @ 2020-04-21 13:15  ChanixChen  阅读(139)  评论(0)    收藏  举报