参考链接:

http://www.smorgasbork.com/2012/01/04/building-a-custom-centos-7-kickstart-disc-part-4/

Building a custom CentOS 7 kickstart disc, part 1

July 16, 2014Linuxpriebe

55

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

CentOS (and of course, it’s upstream distro, Red Hat Enterprise Linux) has an extremely powerful, but somewhat poorly documented, tool for rapidly deploying machines and managing their configuration: kickstart. Kickstart lets you build a custom installation that can run hands-free. So not only is the installation quick and easy for you, you can be confident that your machines are configured exactly the way you want them to be.

Kickstart可以让你做一个自动化的安装,以至于你可以释放双手。不仅仅你可以快速便捷地安装,你更可以确保你机器按你要求进行正确的配置

Imagine that you have 25 web servers (or a mix of web servers, database servers, mail servers, etc.). It would be highly desirable to install identical software packages on all of those machines. In that way, you know that any application you build will run the same way on all machines.

料想下你有25台网站服务器(或者集网站服务器、数据库服务器、邮件服务器等等混合在一块的)。这就对安装正确的包提出了更高的要求。通过这种方式,您知道您构建的任何应用程序都将在所有机器上以相同的方式运行。

If you use the standard install DVD, achieving such uniformity can be challenging. During the installation, it’s always possible that you might accidentally select a different mix of packages for one machine, especially if you are not using one of the standard installation types. Further, it’s quite likely that for your production environment you might need some additional packages that are not part of the standard CentOS distribution. For example, in our environment, we add apps like aide, httperf, zabbix, iftop, memcached, and swatch. If you have to add these packages manually after installation, you’ll spend a lot of time, and you might overlook a machine or a package, leading to inconsistent behavior down the road.

如果你使用的是标准dvd安装碟,实现这样的功能会具备挑战性。在安装某台机器期间,总是会有你选择了不一样混合起来的包,这样导致了各台服务器的差异性,尤其是你没有使用标准的安装类型(我理解应该是minimal、desktop这样的类型)。进一步说,很有可能你环境需要一些其他的包(这些包都不是标准centos发行版附带的)。例如,在我们环境下,我们要增加一个应用程序:aide,httperf, zabbix, iftop, memcached, and swatch.如果你必需在安装完centos后手动增加这些,你会浪费很多时间,并且你可能会忘了装某台机器或者某个包,这将在未来导致你环境不一致

In addition to your software packages, you will likely need to make various system and software configurations. For example, you may need to configure httpd or mysql, or maybe you need to add a group to /etc/group or a user to /etc/passwd. It is critical that these configurations be done consistently on all machines.

除了你的软件包之外,你将可能需要做大量的系统和软件配置。例如,你可能需要配置httpd或者mysql,抑或是可能需要增加一个组到/etc/group 或者增加一个user到/etc/passwd。这些比较重要的配置操作总是需要在每一台机器上完成

The solution is to predefine your package selections with kickstart and let the automated installer guarantee the installation of the same applications on all machines. Further, the postinstaller capabilities of kickstart will allow you to install non-distro applications and perform any system configuration that you can do from a shell script.

该解决方案目的是通过kickstart,预先定义好你的包选择,并且确保为所有机器上自动化安装好一样的应用程序。进一步说,kickstart的postinstaller(后安装)的能力将允许你安装非发行版的应用程序和执行系统配置,他们都是通过shell脚本来实现。

If you want to make your life really easy, you can set up your kickstart to run from a single DVD.

Prepare a build system准备好一个系统

You will need a CentOS 7 machine on which to assemble the packages and build the custom ISO file. This can be a physical or a virtual machine; my build machine runs under VMWare Fusion on a Mac. Download the DVD ISO for the install media. Be sure to validate your checksums before you get started. If you are going to build on a physical machine, burn the ISO to DVD. If you’re using a virtual build machine, you can just mount the ISO directly.

你将需要一个由组合了相关的包和建造了自定义的iso文件的centos7机器(应该是说要安装好centos7,并安装了相关的包),可以是虚拟机也可以是物理机;我的机器是跑在vmvare for mac上的。下载这个dvd iso镜像作为安装镜像。这里不赘述

Install CentOS 7 on your build machine; choose “Desktop” for the installation type (unless you plan to build custom packages from source; if you need to do that, you’ll need to install the development tools as well).

这里可以选择把iso文件传到服务器上,并做挂载动作即可。

On the build system, create a build directory: ~/kickstart_build. Create subdirectories like this:

~/kickstart_build

+-- isolinux

| +-- images

| +-- ks

| +-- LiveOS

| +-- Packages

+-- utils

Copy all the files from the isolinux directory on CentOS DVD into your ~/kickstart_build/isolinux directory.

拷贝来自标准的centos dvd下的isolinux目录下的所有文件到你~/kickstart_build/isolinux目录下

Copy .discinfo from the CentOS DVD into your ~/kickstart_build/isolinux directory

拷贝.discinfo到~/kickstart_build/isolinux

Recursively copy the contents of the images directory on the CentOS DVD into your ~/kickstart_build/isolinux/images directory.

同样地拷贝到~/kickstart_build/isolinux/images目录.

Copy the contents of the LiveOS directory on the CentOS DVD into your ~/kickstart_build/isolinux/LiveOS directory.

Get the comps.xml file from repodata. This file is named with a unique hex string for each release. In CentOS 7.0.1406, for example,called

4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz.

Copy it to ~/kickstart_build/comps.xml.gz and gunzip it so that you have ~/kickstart_build/comps.xml.

Your kickstart config file will go into ~/kickstart_build/isolinux/ks. I like to have a separate directory for this, because I build a series of different config files for different machines or classes of machines.

ks文件可以放在文件夹下,这样可以根据不同的环境执行不一样的ks文件

Start from a sample configuration file

It is always best to start with a sample configuration file. CentOS makes it easy for you to get your hands on one. Just perform a standard installation on a machine. After the install, look in look in /root/anaconda-ks.cfg to get a sample kickstart configuration file.

正常安装好你的centos7后,这个/root/anaconda-ks.cfg 文件就是个配置kickstart文件的模板。

Copy this file into ~/kickstart_build/isolinux/ks/ks.cfg.

复制内容到/kickstart_build/isolinux/ks/ks.cfg

If you want your kickstart to run completely unattended, you will need to make sure that the installer clears any existing partitions on the system before installing. Change this line:

如果需要完全无人地跑kickstart,你需要确保installer 在安装前清除了已存在的分区。主要改动下面这行:

1、clearpart --none --initlabel

to

clearpart --drives=sda --all --initlabel

Of course, if you’re not installing to sda, you may need to modify this line.

当然,如果你不是安装到sda,那么你需要定义一下

Do not use the --all option if you plan on running your kickstart to install to a multiboot system; you will blow away all your operating systems. Then again, I don’t know that kickstart makes much sense in such a scenario. You’re much safer installing manually.

如果你计划跑你的kickstart去安装一个多系统,那么久别加--all的选项;选择这个选项,意味着覆盖掉你所有的操作系统。还有就是,我不知道在这种多系统场景下的kickstart是否行得通。如果你手动安装,会更加稳妥。

Note: it seems that in CentOS 7, anaconda writes a line into this file that is not valid according to the kickstart installer.

注意:看来在centos7下,anaconda的这行在kickstart安装器是无效的

This line:

network  --hostname=localhost.localdomain

should be:做个修改

network  --device=lo --hostname=localhost.localdomain

Note that the drive configuration here reflects the configuration of your build machine. If that is different from your target machine (for example, your build machine might use IDE drives, and your target might use SCSI, or you may want to use software RAID on the target machine), you’ll have to edit some of these lines. When you’re getting started, it’s easiest if you use a build machine configured identically to your target machine.

注意到这里的驱动配置反射出你服务器的配置情况。如果不同于你的目标的机器的话(打个比方,你自建的机器可能使用的是IDE驱动,但你的目标服务器可能使用的是SCSI,或者你可能想使用软RAID),你将必需编辑这些行。当你着手开始时,通过这个配置,这也是最方便的方式

Copy the RPMs拷贝RPMs

You will need access to all the RPMs that you might possibly include in your kickstart (along with all their dependencies). These will be located on your install media in the Packages directory.

你将需要链接所有的RPMs,这些rpm你要尽可能地包含在kickstart(伴随着所有的依赖包)。这些rpm包将会放置到Packages目录

You will probably find it more convenient to copy them all to your local disk; I use this directory: ~/kickstart_build/all_rpms. This will allow you to combine RPMs from different install media or multiple repos if necessary.

创建个/kickstart_build/all_rpms,并把所有的rpms拷贝到这个目录。

Determine which packages to include声明要包含的包

Look in the file ~kickstart_build/comps.xml (which you copied from repodata/comps.xml on disc 1 of the CentOS distribution). This defines the packages and their groups.

查看~kickstart_build/comps.xml(上面的操作),这文件定义了包和包组

Your baseline kickstart configuration file will list the packages that are to be installed (under %packages). Groups are noted with a leading @. You can edit this list, but leave @core in the file, since that group has system-critical packages in it.

kickstart配置文件开始行将会列出哪些包将被安装(在%packages这一处),包组的前缀是@。你可以编辑这个列表,但要留下@core,这个里头很多重要的文件。

Add groups and packages to this list. If you want to really trim down your package list to make a tight distribution, you can use individual packages rather than groups, which may include more than you need. You can include a group and then explicitly exclude a specific package by listing the package with a - prepended to the name.

增加包组和包到这个清单。如果想削减包列表做成更小的版本,你可以使用单独的包,而不是包组。你可以纳入一个包组,然后明确地排除掉某个定义的包,这个功能可以通过-prepended来定义

Next comes the most challenging part — compiling the RPMs and resolving dependencies.接下来讲述编辑RPMs和解析依赖

Building a custom CentOS 7 kickstart disc, part 2

January 4, 2012Linux

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Once you’ve decided which packages you’re going to include in your kickstart disc, it’s time to pull them all together.

Which RPMs do you need? Assuming that you are including at least the @core and @base package groups (and you should), you’ll need the RPMs for all the packages in those groups.

One way to obtain the list of RPMs you need is to look in the file comps.xml for the core and base groups. You will see XML like this:

一种方式去囊括你需要的rpm包是通过comps.xml 文件去声明:

CentOS (and of course, it’s upstream distro, Red Hat Enterprise Linux) has an extremely powerful, but somewhat poorly documented, tool for rapidly deploying machines and managing their configuration: kickstart. Kickstart lets you build a custom installation that can run hands-free. So not only is the installation quick and easy for you, you can be confident that your machines are configured exactly the way you want them to be.

Kickstart可以让你做一个自动化的安装,以至于你可以释放双手。不仅仅你可以快速便捷地安装,你更可以确保你机器按你要求进行正确的配置

Imagine that you have 25 web servers (or a mix of web servers, database servers, mail servers, etc.). It would be highly desirable to install identical software packages on all of those machines. In that way, you know that any application you build will run the same way on all machines.

料想下你有25台网站服务器(或者集网站服务器、数据库服务器、邮件服务器等等混合在一块的)。这就对安装正确的包提出了更高的要求。通过这种方式,您知道您构建的任何应用程序都将在所有机器上以相同的方式运行。

If you use the standard install DVD, achieving such uniformity can be challenging. During the installation, it’s always possible that you might accidentally select a different mix of packages for one machine, especially if you are not using one of the standard installation types. Further, it’s quite likely that for your production environment you might need some additional packages that are not part of the standard CentOS distribution. For example, in our environment, we add apps like aide, httperf, zabbix, iftop, memcached, and swatch. If you have to add these packages manually after installation, you’ll spend a lot of time, and you might overlook a machine or a package, leading to inconsistent behavior down the road.

如果你使用的是标准dvd安装碟,实现这样的功能会具备挑战性。在安装某台机器期间,总是会有你选择了不一样混合起来的包,这样导致了各台服务器的差异性,尤其是你没有使用标准的安装类型(我理解应该是minimal、desktop这样的类型)。进一步说,很有可能你环境需要一些其他的包(这些包都不是标准centos发行版附带的)。例如,在我们环境下,我们要增加一个应用程序:aide,httperf, zabbix, iftop, memcached, and swatch.如果你必需在安装完centos后手动增加这些,你会浪费很多时间,并且你可能会忘了装某台机器或者某个包,这将在未来导致你环境不一致

In addition to your software packages, you will likely need to make various system and software configurations. For example, you may need to configure httpd or mysql, or maybe you need to add a group to /etc/group or a user to /etc/passwd. It is critical that these configurations be done consistently on all machines.

除了你的软件包之外,你将可能需要做大量的系统和软件配置。例如,你可能需要配置httpd或者mysql,抑或是可能需要增加一个组到/etc/group 或者增加一个user到/etc/passwd。这些比较重要的配置操作总是需要在每一台机器上完成

The solution is to predefine your package selections with kickstart and let the automated installer guarantee the installation of the same applications on all machines. Further, the postinstaller capabilities of kickstart will allow you to install non-distro applications and perform any system configuration that you can do from a shell script.

该解决方案目的是通过kickstart,预先定义好你的包选择,并且确保为所有机器上自动化安装好一样的应用程序。进一步说,kickstart的postinstaller(后安装)的能力将允许你安装非发行版的应用程序和执行系统配置,他们都是通过shell脚本来实现。

If you want to make your life really easy, you can set up your kickstart to run from a single DVD.

Prepare a build system准备好一个系统

You will need a CentOS 7 machine on which to assemble the packages and build the custom ISO file. This can be a physical or a virtual machine; my build machine runs under VMWare Fusion on a Mac. Download the DVD ISO for the install media. Be sure to validate your checksums before you get started. If you are going to build on a physical machine, burn the ISO to DVD. If you’re using a virtual build machine, you can just mount the ISO directly.

你将需要一个由组合了相关的包和建造了自定义的iso文件的centos7机器(应该是说要安装好centos7,并安装了相关的包),可以是虚拟机也可以是物理机;我的机器是跑在vmvare for mac上的。下载这个dvd iso镜像作为安装镜像。这里不赘述

Install CentOS 7 on your build machine; choose “Desktop” for the installation type (unless you plan to build custom packages from source; if you need to do that, you’ll need to install the development tools as well).

这里可以选择把iso文件传到服务器上,并做挂载动作即可。

On the build system, create a build directory: ~/kickstart_build. Create subdirectories like this:

~/kickstart_build

+-- isolinux

| +-- images

| +-- ks

| +-- LiveOS

| +-- Packages

+-- utils

Copy all the files from the isolinux directory on CentOS DVD into your ~/kickstart_build/isolinux directory.

拷贝来自标准的centos dvd下的isolinux目录下的所有文件到你~/kickstart_build/isolinux目录下

Copy .discinfo from the CentOS DVD into your ~/kickstart_build/isolinux directory

拷贝.discinfo到~/kickstart_build/isolinux

Recursively copy the contents of the images directory on the CentOS DVD into your ~/kickstart_build/isolinux/images directory.

同样地拷贝到~/kickstart_build/isolinux/images目录.

Copy the contents of the LiveOS directory on the CentOS DVD into your ~/kickstart_build/isolinux/LiveOS directory.

Get the comps.xml file from repodata. This file is named with a unique hex string for each release. In CentOS 7.0.1406, for example,called

4b9ac2454536a901fecbc1a5ad080b0efd74680c6e1f4b28fb2c7ff419872418-c7-x86_64-comps.xml.gz.

Copy it to ~/kickstart_build/comps.xml.gz and gunzip it so that you have ~/kickstart_build/comps.xml.(拷贝并重命名为comps.xml.gz)

Your kickstart config file will go into ~/kickstart_build/isolinux/ks. I like to have a separate directory for this, because I build a series of different config files for different machines or classes of machines.

ks文件可以放在/kickstart_build/isolinux/ks文件夹下,这样可以根据不同的环境执行不一样的ks文件

Start from a sample configuration file

It is always best to start with a sample configuration file. CentOS makes it easy for you to get your hands on one. Just perform a standard installation on a machine. After the install, look in look in /root/anaconda-ks.cfg to get a sample kickstart configuration file.

正常安装好你的centos7后,这个/root/anaconda-ks.cfg 文件就是个配置kickstart文件的模板。

Copy this file into ~/kickstart_build/isolinux/ks/ks.cfg.

复制内容到/kickstart_build/isolinux/ks/ks.cfg

If you want your kickstart to run completely unattended, you will need to make sure that the installer clears any existing partitions on the system before installing. Change this line:

如果需要完全无人地跑kickstart,你需要确保installer 在安装前清除了已存在的分区。主要改动下面这行:

1、clearpart --none --initlabel

to

clearpart --drives=sda --all --initlabel

Of course, if you’re not installing to sda, you may need to modify this line.

当然,如果你不是安装到sda,那么你需要定义一下

Do not use the --all option if you plan on running your kickstart to install to a multiboot system; you will blow away all your operating systems. Then again, I don’t know that kickstart makes much sense in such a scenario. You’re much safer installing manually.

如果你计划跑你的kickstart去安装一个多系统,那么久别加--all的选项;选择这个选项,意味着覆盖掉你所有的操作系统。还有就是,我不知道在这种多系统场景下的kickstart是否行得通。如果你手动安装,会更加稳妥。

Note: it seems that in CentOS 7, anaconda writes a line into this file that is not valid according to the kickstart installer.

注意:看来在centos7下,anaconda的这行在kickstart安装器是无效的

This line:

network  --hostname=localhost.localdomain

should be:做个修改

network  --device=lo --hostname=localhost.localdomain

Note that the drive configuration here reflects the configuration of your build machine. If that is different from your target machine (for example, your build machine might use IDE drives, and your target might use SCSI, or you may want to use software RAID on the target machine), you’ll have to edit some of these lines. When you’re getting started, it’s easiest if you use a build machine configured identically to your target machine.

注意到这里的驱动配置反射出你服务器的配置情况。如果不同于你的目标的机器的话(打个比方,你自建的机器可能使用的是IDE驱动,但你的目标服务器可能使用的是SCSI,或者你可能想使用软RAID),你将必需编辑这些行。当你着手开始时,通过这个配置,这也是最方便的方式

Copy the RPMs拷贝RPMs

You will need access to all the RPMs that you might possibly include in your kickstart (along with all their dependencies). These will be located on your install media in the Packages directory.

你将需要链接所有的RPMs,这些rpm你要尽可能地包含在kickstart(伴随着所有的依赖包)。这些rpm包将会放置到Packages目录

You will probably find it more convenient to copy them all to your local disk; I use this directory: ~/kickstart_build/all_rpms. This will allow you to combine RPMs from different install media or multiple repos if necessary.

创建个/kickstart_build/all_rpms,并把所有的rpms拷贝到这个目录。

Determine which packages to include声明要包含的包

Look in the file ~kickstart_build/comps.xml (which you copied from repodata/comps.xml on disc 1 of the CentOS distribution). This defines the packages and their groups.

查看~kickstart_build/comps.xml(上面的操作),这文件定义了包和包组

Your baseline kickstart configuration file will list the packages that are to be installed (under %packages). Groups are noted with a leading @. You can edit this list, but leave @core in the file, since that group has system-critical packages in it.

kickstart配置文件开始行将会列出哪些包将被安装(在%packages这一处),包组的前缀是@。你可以编辑这个列表,但要留下@core,这个里头很多重要的文件。

Add groups and packages to this list. If you want to really trim down your package list to make a tight distribution, you can use individual packages rather than groups, which may include more than you need. You can include a group and then explicitly exclude a specific package by listing the package with a - prepended to the name.

增加包组和包到这个清单。如果想削减包列表做成更小的版本,你可以使用单独的包,而不是包组。你可以纳入一个包组,然后明确地排除掉某个定义的包,这个功能可以通过-prepended来定义

Next comes the most challenging part — compiling the RPMs and resolving dependencies.接下来讲述编辑RPMs和解析依赖

Building a custom CentOS 7 kickstart disc, part 2

January 4, 2012Linux

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Once you’ve decided which packages you’re going to include in your kickstart disc, it’s time to pull them all together.

Which RPMs do you need? Assuming that you are including at least the @core and @base package groups (and you should), you’ll need the RPMs for all the packages in those groups.

One way to obtain the list of RPMs you need is to look in the file comps.xml for the core and base groups. You will see XML like this:

一种方式去囊括你需要的rpm包是通过comps.xml 文件去声明:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

<group>

<id>core</id>

<name>Core</name>

...

<packagelist>

<packagereq type="mandatory">Red_Hat_Enterprise_Linux-Release_Notes-7-en-US</packagereq>

<packagereq type="mandatory">audit</packagereq>

<packagereq type="mandatory">basesystem</packagereq>

<packagereq type="mandatory">bash</packagereq>

<packagereq type="mandatory">biosdevname</packagereq>

<packagereq type="mandatory">btrfs-progs</packagereq>

<packagereq type="mandatory">coreutils</packagereq>

<packagereq type="mandatory">cronie</packagereq>

<packagereq type="mandatory">curl</packagereq>

<packagereq type="mandatory">dhclient</packagereq>

<packagereq type="mandatory">e2fsprogs</packagereq>

...

</packagelist>

</group>

At a bare minimum, you will want all the required packages from within the core group. I also like to install the base group. Look for <packagereq type="mandatory"> and <packagereq type="default"> entries within the <group> tags. This tells you which packages to get. These package names correspond to the names of the RPM files.

最低限度地,你可能想从core包组中获取所有需要的包。我也喜欢安装base包组。来看看<group>标签下的<packagereq type="mandatory"> 和 <packagereq type="default"> 。这会告诉你哪些包会被获取到。这些包名跟rpm文件名保持一致。

To make this easier, I have built a script to parse the comps.xml file and gather all the non-optional packages for the base and core package groups.

为了更加简单化,我就创建了一个脚本去分析comps.xml文件,并为base包组和core包组获取所有非可选的包

Download gather_packages.pl and save it in your ~/kickstart_build/utils directory.

下载gather_packages.pl 并保存在~/kickstart_build/utils目录

Before you can run gather_packages.pl, you’ll need to install some perl libraries. All I wanted to use was XML::Simple, but that set off a chain of dependencies. Use the rpm command below to install all the dependencies.

在你跑这个pl文件前,你需要安装perl环境。

我只想用XML::Simple(一种perl环境下读写xml文件工具),但会引发一系列的依赖包链。使用以下的rpm命令去安装所有的依赖。(我的理解就是做个更新)

这里顺便讲述一下:yum -y update

是升级所有包,改变软件设置和系统设置,系统版本内核都升级

是我猜测作者的意思应该是更新一下当前perl环境,以配合脚本文件的使用

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh perl-5*-*.el7.x86_64.rpm \

perl-Business-ISBN-*.el7.noarch.rpm \

perl-Carp-*.el7.noarch.rpm \

perl-Compress-Raw-Bzip2-*.el7.x86_64.rpm \

perl-Compress-Raw-Zlib-*.el7.x86_64.rpm \

perl-constant-*.el7.noarch.rpm \

perl-Data-Dumper-*.el7.x86_64.rpm \

perl-devel-*.el7.x86_64.rpm \

perl-Digest-*.el7.noarch.rpm \

perl-Digest-MD5-*.el7.x86_64.rpm \

perl-Digest-SHA-*.el7.x86_64.rpm \

perl-Encode-*.el7.x86_64.rpm \

perl-Encode-Locale-*.el7.noarch.rpm \

perl-Exporter-*.el7.noarch.rpm \

perl-ExtUtils-Install-*.el7.noarch.rpm \

perl-ExtUtils-MakeMaker-*.el7.noarch.rpm \

perl-ExtUtils-Manifest-*.el7.noarch.rpm \

perl-ExtUtils-ParseXS-*.el7.noarch.rpm \

perl-File-Listing-*.el7.noarch.rpm \

perl-File-Path-*.el7.noarch.rpm \

perl-File-Temp-*.el7.noarch.rpm \

perl-Filter-*.el7.x86_64.rpm \

perl-Getopt-Long-*.el7.noarch.rpm \

perl-HTML-Parser-*.el7.x86_64.rpm \

perl-HTML-Tagset-*.el7.noarch.rpm \

perl-HTTP-Cookies-*.el7.noarch.rpm \

perl-HTTP-Daemon-*.el7.noarch.rpm \

perl-HTTP-Date-*.el7.noarch.rpm \

perl-HTTP-Message-*.el7.noarch.rpm \

perl-HTTP-Negotiate-*.el7.noarch.rpm \

perl-HTTP-Tiny-*.el7.noarch.rpm \

perl-IO-Compress-*.el7.noarch.rpm \

perl-IO-HTML-*.el7.noarch.rpm \

perl-IO-Socket-IP-*.el7.noarch.rpm \

perl-IO-Socket-SSL-*.el7.noarch.rpm \

perl-libs-*.el7.x86_64.rpm \

perl-libwww-perl-*.el7.noarch.rpm \

perl-LWP-MediaTypes-*.el7.noarch.rpm \

perl-macros-*.el7.x86_64.rpm \

perl-Net-HTTP-*.el7.noarch.rpm \

perl-Net-LibIDN-*.el7.x86_64.rpm \

perl-Net-SSLeay-*.el7.x86_64.rpm \

perl-parent-*.el7.noarch.rpm \

perl-PathTools-*.el7.x86_64.rpm \

perl-Pod-Escapes-*.el7.noarch.rpm \

perl-Pod-Perldoc-*.el7.noarch.rpm \

perl-Pod-Simple-*.el7.noarch.rpm \

perl-Pod-Usage-*.el7.noarch.rpm \

perl-podlators-*.el7.noarch.rpm \

perl-Scalar-List-Utils-*.el7.x86_64.rpm \

perl-Socket-*.el7.x86_64.rpm \

perl-srpm-macros-*.el7.noarch.rpm \

perl-Storable-*.el7.x86_64.rpm \

perl-Test-Harness-*.el7.noarch.rpm \

perl-Text-ParseWords-*.el7.noarch.rpm \

perl-Thread-Queue-*.el7.noarch.rpm \

perl-threads-*.el7.x86_64.rpm \

perl-Time-Local-*.el7.noarch.rpm \

perl-TimeDate-*.el7.noarch.rpm \

perl-URI-*.el7.noarch.rpm \

perl-WWW-RobotRules-*.el7.noarch.rpm \

perl-XML-Filter-BufferText-*.el7.noarch.rpm \

perl-XML-NamespaceSupport-*.el7.noarch.rpm \

perl-XML-Parser-*.el7.x86_64.rpm \

perl-XML-SAX-*.el7.noarch.rpm \

perl-XML-Simple-*.el7.noarch.rpm \

gdbm-devel-*.x86_64.rpm \

glibc-devel-*.x86_64.rpm \

glibc-headers-*.x86_64.rpm \

kernel-headers-*.x86_64.rpm \

libdb-devel-*.x86_64.rpm \

systemtap-sdt-devel-*.x86_64.rpm \

mailcap-*.noarch.rpm

Note that I started with the minimal install; your system may start with a different set of packages installed, so you may get messages indicating that one or more of these packages is already installed (or you might get errors about additional dependencies that you don’t have installed that I did happen to have installed). These should be fairly easily resolved.

注意到我是最小化安装的centos7;你的系统可能安装了其他的包,所以你可能会看到更多已安装的包(或者你会得到关于其他未安装依赖包的报错,而这些依赖包恰恰是我碰巧安装了的)。这些应该清楚并且很容易被解决。

Once you have the prerequisites installed, run the script this way:

一旦你安装好了先决条件,运行以下脚本文件

1

2

~/kickstart_build/utils/gather_packages.pl ~/kickstart_build/comps.xml \

~/kickstart_build/all_rpms ~/kickstart_build/isolinux/Packages x86_64

By default, gather_packages.pl will gather all the packages for the base and core package groups. You can specify more on the command line. For example, for my system, I do this:

默认地,pl文件会搜集有关base包组、core包组所有的包。你可以通过命令定义更多。例如,我是这样做的:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

~/kickstart_build/utils/gather_packages.pl ~/kickstart_build/comps.xml \

~/kickstart_build/all_rpms ~/kickstart_build/isolinux/Packages x86_64 \

debugging \

directory-client \

file-server \

ftp-server \

hardware-monitoring \

java-platform \

large-systems \

load-balancer \

mariadb \

network-file-system-client \

performance \

perl-runtime \

remote-system-management \

ruby-runtime \

web-server

Add your own RPMs添加你自己的rpms

If you want to add any RPMs not included in the base and core groups (for example, httpd, php, or mysql), copy those into the ~/kickstart_build/isolinux/Packages directory at this time.

如果你想添加任意的rpms(既没有在base组、也没有在core组),那就拷贝这些rpms到Packages目录

Resolve dependencies 解析依赖包

Now we have all the base and core RPMs in our ~/kickstart_build/isolinux/Packages directory, along with any other RPMs you’ve added, but many are missing their dependencies. So the next step is to track down all the dependencies of these packages and throw those into the directory, too. You can use another script, resolve_deps.pl, to perform this step.

现在我们已经有所有有关base、core的rpms包在我们Packages目录下,当然也有其他你额外添加进去的包,但是很多都丢失了他们的依赖包。所以下一步是替这些包在该目录下追寻所有的依赖。你可以使用这个resolve_deps.pl去执行这一步骤。

1

2

3

4

~/kickstart_build/utils/resolve_deps.pl \

~/kickstart_build/all_rpms \

~/kickstart_build/isolinux/Packages \

x86_64

Testing dependencies测试依赖

Once you’ve got a set of RPMs ready, you’ll need to test the dependencies of the RPMs. Each RPM may require that other RPMs be installed in order for it to be installed. If each RPM’s dependencies are included in the set of RPMs, then all the dependencies are resolved. The objective is to have a set of RPMs that have no unresolved dependencies.

一旦你准备好了rpms,你将需要测试rpms的依赖情况。每个rpm可能要求

To test the dependencies in your set of RPMs, run these commands:

1

2

3

4

cd ~/kickstart_build/isolinux/Packages

mkdir /tmp/testdb

rpm --initdb --dbpath /tmp/testdb

rpm --test --dbpath /tmp/testdb -Uvh *.rpm

If you find you have unresolved dependencies (and you will almost certainly have some), you can do one of two things:

如果你发现你没解决的依赖(几乎都会有),你可以做以下2选1

  • remove the RPM with the unresolved dependencies (a good idea if the RPM is going to set off a chain of dependencies that you don’t want, for example X Windows on a server class installation)
  • 移除这个rpm
  • track down the RPMs to fulfill the dependency
  • 彻查到底

Here, again, you need a little bit of savvy to determine which packages should be removed. In general, if the package is one that you explicitly added to the base and core groups, then you’ll probably want to find the dependencies and include them. If it’s an RPM that you don’t really want (one that got matched by the wildcard, for example), you might decide to eliminate that RPM.

到这里,你需要有点点知识去决定那个包的去留。一般地,如果这个包是你明确地要添加到base、core组的话,然后你将尽可能的想找到它的依赖并且把他们搞进来。那如果不是很想要的包,那么你要决定删除它

Resolving dependencies

The resolve_deps.pl script will get most dependencies automatically. But not always.

此pl文件将自动获得更多的依赖,但并非总是如此。

Some RPMs report their dependencies in strange ways. For example, usbutils reports a dependency on /usr/bin/pkg-config. But not a single package in the distribution reports that it provides /usr/bin/pkg-config.

一些rpms使用了一些奇怪的方式去宣告所需的依赖。例如,usbutils宣告依赖必需在/usr/bin/pkg-config。而不是来源于发行版单一的包,如下图

我就卡在这里的:/usr/bin/nm is needed by kmod-20-23.el7.x86_64,也不知道怎么处理,个人试了所有有关networkmanager的包,没什么头绪

/usr/bin/pkg-config is contained within the pkgconfig RPM. But the RPM reports that it provides the following:

/usr/bin/pkg-config包含了围绕pkgconfig 的rpm。但是这rpm宣告:

1

2

3

4

5

$ rpm -q --provides -p pkgconfig-0.27.1-4.el7.x86_64.rpm

warning: pkgconfig-0.27.1-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

pkgconfig = 1:0.27.1-4.el7

pkgconfig(pkg-config) = 0.27.1

pkgconfig(x86-64) = 1:0.27.1-4.el7

Note that rpm does not report that the package provides “/usr/bin/pkg-config“. My script isn’t smart enough to know that pkgconfig(pkg-config) means that the binary /usr/bin/pkg-config gets installed. So the dependency goes unmatched.

注意到rpm没有宣告这个包提供/usr/bin/pkg-config。我的脚本不会智能地知道pkgconfig(pkg-config) 想给/usr/bin/pkg-config安装了。所以依赖就不会被映射到

There are a few packages in the base and core groups that do this, but not too many, thankfully. After running resolve_deps.pl, I got these failed dependencies when I tested the repo:

base跟core这里会有一些包存在这情况,但不会很多。在运行了pl文件后,我获得了一个报错:

1

2

3

4

5

6

7

8

error: Failed dependencies:

/usr/bin/pkg-config is needed by bash-completion-1:2.1-6.el7.noarch

/usr/sbin/cgrulesengd is needed by cgdcbxd-1.0.2-5.el7.x86_64

/usr/bin/fipscheck is needed by fipscheck-lib-1.4.1-5.el7.x86_64

/usr/bin/db_stat is needed by rpm-4.11.1-16.el7.x86_64

/usr/bin/pkg-config is needed by shared-mime-info-1.1-7.el7.x86_64

/usr/bin/pkg-config is needed by usbutils-007-4.el7.x86_64

/usr/bin/pkg-config is needed by xorg-x11-font-utils-1:7.5-18.1.el7.x86_64

So through some sleuthing, I determined that I needed these files:

通过一些查阅,我确定我需要以下的文件:

1

2

3

4

5

6

cd ~/kickstart_build/all_rpms

cp fipscheck-*.el7.x86_64.rpm \

libdb-utils-*.el7.x86_64.rpm \

libcgroup-tools-*.el7.x86_64.rpm \

pkgconfig-*.el7.x86_64.rpm \

~/kickstart_build/isolinux/Packages

Depending on which package groups you specified to gather_packages.pl, you may have additional situations like this that require more investigation. If you’ve brought in RPMs from other repos, or you’ve included your own compiled RPMs, the situation could be even more complicated, but if you are doing this, hopefully you know how to deal with it.

基于你定义到 gather_packages.pl的包组,你可能有其他的情况,这就需要更多的研究:如果你从其他repos带来的rpms,这情况就更为复杂了,但如果你正在做这个,很有希望地你会知道如何去解决。

When resolve_deps.pl runs, it creates a file /tmp/providers.txt that lists every RPM and the capabilities provided by each. It might help you match up some of these non-obvious dependencies.

当 resolve_deps.pl跑起来的时候,它创建了一个文件 /tmp/providers.txt ,这文件列出每一个rpm和它提供的能力。他将帮助你匹配出一些不明显的依赖。

If you have installed CentOS 7 to another system with a lot of RPMs installed, you can use the rpm -q --whatprovides query on that system to try to track it down.

如果你已经安装了centos7 并且有很多rpm安装了,你可以使用rpm -q --whatprovides 在系统上查询,以尝试追寻依赖。

When all else fails, try googling for “rpm /path/to/file/in/question”; sometimes you can figure it out that way.

当其他报错时,尝试谷歌rpm /path/to/file/in/question,或许有帮助。

This is an iterative process. Every time you add a new RPM to the directory, you need to test the dependencies. Be prepared to spend a while chasing down these dependencies to build a fine-tuned collection of RPMs with no unresolved dependencies.

这是一个重复的进程。每一次你添加新的rpm到目录,你就需要测试它的依赖。准备好去花费努力寻找依赖,以创建一个调整好的、并没有待解决依赖的rpms集合

“Hidden” dependencies隐藏的依赖

One would hope that the resulting collection of RPMs would be complete, providing all dependencies. However, it seems that anaconda can’t complete the installation without some additional packages:

一种希望rpms集合完美完成,提供所有的依赖。但是,如果缺少其他的包,这看起来anaconda并不能完成安装

  • authconfig (@base)
  • chrony (@base)
  • firewalld (@base)
  • grub2 (@anaconda-tools)

(the containing package group for each package is listed in parens)

If you’re using gather_packages.pl, these should not be a problem;

如果你正使用gather_packages.pl ,这不会出现问题;

gather_packages.pl always includes the @base package group. It also includes grub2 specifically because of this problem.

gather_packages.pl 总是包括base包组。由于这个问题,它也会包括grub2

Next steps

The next step is to build your disk image. I will cover that in the next installment.

下一步是创建你的镜像。

Building a custom CentOS 7 kickstart disc, part 3

January 4, 2012Linux

28

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Now that you’ve compiled your RPMs, you need to build a disk image from which to perform the kickstart.

既然你已经编辑好你的rpms,你需要建一个disk镜像

Create the repository创建仓库

Install createrepo so that you can create a repository. If you’ve copied all the RPMs to ~kickstart_build/all_rpms as suggested earlier, just do this:

安装createrepo,以至于你可以创建一个仓库。如果你已经拷贝了所有rpm包到 ~kickstart_build/all_rpms

1

2

3

4

5

6

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh \

createrepo-*.el7.noarch.rpm \

deltarpm-*.el7.x86_64.rpm \

python-deltarpm-*.el7.x86_64.rpm \

libxml2-python-*.el7.x86_64.rpm

You need to build the repodata for your install disc. These files provide the installer information about the available packages. On your build machine, you should have already copied the repodata/comps.xml file from the CentOS disc to ~/kickstart_build. Use createrepo to build the repository info.

你需要为安装disc创建这个repodata。这些repodata文件提供了有关可提供安装包安装器的信息。在你自建的机器上,你应该准备好了拷贝 repodata/comps.xml这一动作。那么现在使用createrepo去创建仓库吧

1

2

cd ~/kickstart_build/isolinux

createrepo -g ~/kickstart_build/comps.xml .

This will create a repodata directory under ~/kickstart_build/isolinux with the repository data files in it.

Note: in CentOS 6, you had to use the contents of .discinfo to set the baseurl (declare -x discinfo=head -1 .discinfo; createrepo -u "media://$discinfo" ...); you don’t do this any more. In fact, if you do, your kickstart will bail out at some point, saying something like “RepoError after 10 retries: Insufficient space in download directory /run/install/repo/Packages”. It seems that having this media:// baseurl in the repo causes yum to try to update the repo on your DVD, which it can’t do, since the filesystem is read-only and is technically full (thus the “insufficient space” error message). I was stuck on this for a few hours before I stumbled across the fix.

Build the ISO

Install the genisoimage package so that you can create an ISO.

1

2

3

4

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh \

genisoimage-*.el7.x86_64.rpm \

libusal-*.el7.x86_64.rpm

We’re finally ready to build the ISO image that we can burn to CD.

1

2

3

4

5

cd ~/kickstart_build

chmod 664 isolinux/isolinux.bin

mkisofs -o custom.iso -b isolinux.bin -c boot.cat -no-emul-boot \

-V 'CentOS 7 x86_64' \

-boot-load-size 4 -boot-info-table -R -J -v -T isolinux/

You should now have an ISO image in custom.iso.

Testing the ISO测试iso文件

Rather than spending the time to burn a DVD and perform a physical installation, you can test the ISO using a virtual machine, which you can run under a program like VirtualBox.

When the system (virtual or physical) boots up, you’ll see your standard CentOS installation prompt. Before the countdown expires, hit ESC and type

1

linux inst.ks=cdrom:/dev/cdrom:/ks/ks.cfg

Note that there have been substantial changes to the format of the value used with the ks option in CentOS 7.

  • The new option is inst.ks instead of just ks, but ks will still work; use inst.ks for future-proofing
  • The new value has three parts; the first specifies that we want to install from a cdrom; the second specifies the device, and is technically optional (if you only have a single cdrom/dvd drive, the installer should use that). However, I have found that if you don’t specify /dev/cdrom, your kickstart installation will fail horribly, dropping to a dracut emergency shell with errors like /dev/root does not exist. And while you may find examples online that specify it as something like /dev/sr0, rest assured that this will not work — you must use /dev/cdrom. This cost me countless hours of experimentation and reading hundreds of forum posts and bug reports. This time is my gift to you.

If you specify the options correctly, your installation should proceed automatically.

Note that if you really want to make your kickstart easy, you can add an entry to the isolinux/isolinux.cfg file like this:

1

2

3

4

5

label ks

menu label ^Kickstart

menu default

kernel vmlinuz

append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 inst.ks=cdrom:/dev/cdrom:/ks/ks.cfg

This will put an entry into the boot menu so you can just select it to run your kickstart without having to manually type the boot options.

Next steps

Now you have a working custom kickstart disc. To really take advantage of the power of kickstart, you’ll most likely need a custom postinstallation script to configure the system according to your specs. We’ll cover that in the next installment in this series.

现在你有了可以使用的自定义 kickstart disc。为了真正利用kickstart的强大能力,你将尽可能地需要一个完善好的脚本文件去配置这个系统。下一部分,我们重点讲解

Building a custom CentOS 7 kickstart disc, part 4

January 4, 2012Linux

25

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Let’s make things really interesting with a postinstall script to do some custom configuration.

The %post section %post部分讲解

In your kickstart configuration file, you can have sections of commands that are designated to run after the anaconda installer has done its work. These sections are denoted with the %post directive.

在你的kickstart配置文件中,你可以在anaconda安装器完成他的工作后指定一些命令去执行。这些部分是放在%post指令

Typically, you follow this directive with the bash shebang line and the contents of a custom shell script. One thing to note is the filesystem organization at this point during the installation. Your new system’s disk is mounted at /mnt/sysimage, not at / the way it will be once the system is up and running after installation.

典型地,你基于这个指令后面,伴随一些bash工作行以及自定义的shell脚本。一点要注意是文件系统组织。一旦安装好了后,你的新系统硬盘是挂载到/mnt/sysimage,不是在/。

By default, the commands in the %post section are run in a chroot environment, where /mnt/sysimage appears as the / directory. This lets you use “normal” paths to configuration files like /etc instead of /mnt/sysimage/etc (if you didn’t chroot like this, you wouldn’t be able to do things like install RPMs). The primary disadvantage is that your install media is not visible in a chrooted environment.

默认地,%post部分的命令是运行在chroot 环境,/mnt/sysimage作为一个类似/ 的根目录。这会让你使用一般的配置文件路径就像/etc被代替成/mnt/sysimage/etc(如果你没做改变程序执行时所参考的根目录位置,你将没办法执行类似安装rpms的动作),这主要的缺点是在chrooted下的环境你的安装媒体是不可见的。

We solve this problem by building our postinstall in two stages. In the first stage, we tell anaconda not to chroot us; we then copy files from the CD to the hard drive.

解决这个问题分2步。在第一步,我们告诉anaconda别去做改变程序执行时所参考的根目录位置;然后从CD文件拷贝到硬盘。

1

2

3

4

5

6

7

8

9

10

11

%post --nochroot

#!/bin/sh

set -x -v

exec 1>/mnt/sysimage/root/kickstart-stage1.log 2>&1

echo "==> copying files from media to install drive..."

cp -r /run/install/repo/postinstall /mnt/sysimage/root

%end

In our case, we’ve put all our postinstallation files into the postinstall directory under the ~/kickstart_build/isolinux directory. Note that the isolinux directory in our build environment becomes the root of the install disc that we create, and the install disc is mounted at /run/install/repo.

在我们的情况,,我们已经把所有的预安装文件放到了~/kickstart_build/isolinux /postinstall 目录。注意到在我们自建的环境下的isolinux目录变成了the root of the install disc that we create, install disc被挂载到了/run/install/repo

So ~/kickstart_build/isolinux/postinstall is available at /run/install/repo/postinstall. We copy postinstall directory on the install disc to /root/postinstall on the new system’s hard drive.

所以 ~/kickstart_build/isolinux/postinstall在/run/install/repo/postinstall能够被找到。我们拷贝在install disc的postinstall 目录到新系统上的/root/postinstall

We’re now ready to run stage 2 of the postinstall, where we actually use the postinstallation files.

我们现在准备执行第二步,这里事实上使用的是这个postinstallation 文件

1

2

3

4

5

6

7

8

9

10

%post

#!/bin/sh

set -x -v

exec 1>/root/kickstart-stage2.log 2>&1

ls -l /root/postinstall

%end

Note that in both the stage1 and stage2 postinstall scripts, I redirect stdout to a log file in root’s home directory. This is very helpful for diagnosing problems during the kickstart postinstall. This comes in handy when you have many hundreds of lines of postinstall that need to be tested and debugged.

注意到这两步的postinstall 脚本,我重定向stdout到一个坐落在root的home目录下的日志文件。在kickstart postinstall安装期间,这对诊断问题非常有用。

The sky is the limit for what you can do in the postinstallation:

在postinstallation里头,你做任何事都没限制

  • add users or groups
  • install non-CentOS applications from RPMs (see below for some good repos)
  • install non-CentOS applications from tarballs (I prefer RPMs where available, but sometimes you don’t have them handy)
  • set the runlevels for various system services
  • configure servers like apache, samba, sshd, and MySQL
  • configure the default behavior of the bash shell

and anything else you could imagine. In my ideal world, my machines are ready to perform their designated tasks from the very first second I boot them up. I don’t want to have a series of manual steps to complete the configuration.

并且可以做任何你想做的。在我的想法里,一旦我启动了,我的机器已经准备及时执行指定好的任务。我不想又有一系列的手动步骤去完成这个配置。

Organizing the postinstall files 组织postinstall 文件

If I can offer any suggestions in terms of how you organize your postinstall files, I would suggest breaking the files up into directories like this:

就你要组织你的postinstall 文件而言,我会建议你做个分解到目录:

1

2

3

4

5

~/kickstart_build/isolinux/postinstall

+-- apps

+-- appconfig

+-- sysconfig

+-- libs

Put your non-CentOS application RPMs and tarballs into apps (with a subdirectory for each application), put application configuration files and scripts into appconfig (again with a subdirectory for each application), put OS configuration files (like network config files) into sysconfig, and put general-purpose libraries (those not specifically required by any applications you’re installing) into libs.

把你的non-CentOS 应用程序rpms和tarballs (压缩包)到apps目录,把应用程序的配置文件和脚本放到appconfig ,把OS 配置文件(像网络配置文件)放到sysconfig,把通用的librares放到libs

Of these strategies, the organization of apps is by far the most important. When you install applications that are not part of the CentOS distro, you’ll likely have to install additional libraries or utilities to satisfy dependencies in those packages. When you need to refresh your kickstart image, it is helpful to have each app and its dependencies contained in a single directory. If you throw them all into a big directory, you’ll never remember, for example, that mhash is in there because aide requires it.

基于这种策略,apps的组织就变得非常重要。当你安装的应用程序不是所属于CentOS distro,你将必需安装其他的libraries 或者utilities 去满足这些包的依赖。当你需要恢复你的kickstart 镜像,把每一个app和它的依赖放到一个目录下是很有帮助的。如果你把他们都丢在了一个大目录下,你将很容易忘记

External repositories外部仓库

I have found the following repositories to be reliable sources of packages that aren’t included in the CentOS distro:

我找到了以下的的仓库,他们可以提供可靠的包源,但他们不属于CentOS distro

  • EPEL – Extra Packages for Enterprise Linux
  • repoforge – formerly RPMforge; DAG repository now redirects to this
  • ATrpms – good place to get ffmpeg rpms
  • ELrepo – source for hardware drivers

Good luck building your custom installation disc. I welcome any comments or suggestions you might have for this guide!

 

At a bare minimum, you will want all the required packages from within the core group. I also like to install the base group. Look for <packagereq type="mandatory"> and <packagereq type="default"> entries within the <group> tags. This tells you which packages to get. These package names correspond to the names of the RPM files.

最低限度地,你可能想从core包组中获取所有需要的包。我也喜欢安装base包组。来看看<group>标签下的<packagereq type="mandatory"> 和 <packagereq type="default"> 。这会告诉你哪些包会被获取到。这些包名跟rpm文件名保持一致。

To make this easier, I have built a script to parse the comps.xml file and gather all the non-optional packages for the base and core package groups.

为了更加简单化,我就创建了一个脚本去分析comps.xml文件,并为base包组和core包组获取所有非可选的包

Download gather_packages.pl and save it in your ~/kickstart_build/utils directory.

下载gather_packages.pl 并保存在~/kickstart_build/utils目录

Before you can run gather_packages.pl, you’ll need to install some perl libraries. All I wanted to use was XML::Simple, but that set off a chain of dependencies. Use the rpm command below to install all the dependencies.

在你跑这个pl文件前,你需要安装perl环境。

我只想用XML::Simple(一种perl环境下读写xml文件工具),但会引发一系列的依赖包链。使用以下的rpm命令去安装所有的依赖。(我的理解就是做个更新)

这里顺便讲述一下:yum -y update

是升级所有包,改变软件设置和系统设置,系统版本内核都升级

是我猜测作者的意思应该是更新一下,免得有其他的依赖

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh perl-5*-*.el7.x86_64.rpm \

perl-Business-ISBN-*.el7.noarch.rpm \

perl-Carp-*.el7.noarch.rpm \

perl-Compress-Raw-Bzip2-*.el7.x86_64.rpm \

perl-Compress-Raw-Zlib-*.el7.x86_64.rpm \

perl-constant-*.el7.noarch.rpm \

perl-Data-Dumper-*.el7.x86_64.rpm \

perl-devel-*.el7.x86_64.rpm \

perl-Digest-*.el7.noarch.rpm \

perl-Digest-MD5-*.el7.x86_64.rpm \

perl-Digest-SHA-*.el7.x86_64.rpm \

perl-Encode-*.el7.x86_64.rpm \

perl-Encode-Locale-*.el7.noarch.rpm \

perl-Exporter-*.el7.noarch.rpm \

perl-ExtUtils-Install-*.el7.noarch.rpm \

perl-ExtUtils-MakeMaker-*.el7.noarch.rpm \

perl-ExtUtils-Manifest-*.el7.noarch.rpm \

perl-ExtUtils-ParseXS-*.el7.noarch.rpm \

perl-File-Listing-*.el7.noarch.rpm \

perl-File-Path-*.el7.noarch.rpm \

perl-File-Temp-*.el7.noarch.rpm \

perl-Filter-*.el7.x86_64.rpm \

perl-Getopt-Long-*.el7.noarch.rpm \

perl-HTML-Parser-*.el7.x86_64.rpm \

perl-HTML-Tagset-*.el7.noarch.rpm \

perl-HTTP-Cookies-*.el7.noarch.rpm \

perl-HTTP-Daemon-*.el7.noarch.rpm \

perl-HTTP-Date-*.el7.noarch.rpm \

perl-HTTP-Message-*.el7.noarch.rpm \

perl-HTTP-Negotiate-*.el7.noarch.rpm \

perl-HTTP-Tiny-*.el7.noarch.rpm \

perl-IO-Compress-*.el7.noarch.rpm \

perl-IO-HTML-*.el7.noarch.rpm \

perl-IO-Socket-IP-*.el7.noarch.rpm \

perl-IO-Socket-SSL-*.el7.noarch.rpm \

perl-libs-*.el7.x86_64.rpm \

perl-libwww-perl-*.el7.noarch.rpm \

perl-LWP-MediaTypes-*.el7.noarch.rpm \

perl-macros-*.el7.x86_64.rpm \

perl-Net-HTTP-*.el7.noarch.rpm \

perl-Net-LibIDN-*.el7.x86_64.rpm \

perl-Net-SSLeay-*.el7.x86_64.rpm \

perl-parent-*.el7.noarch.rpm \

perl-PathTools-*.el7.x86_64.rpm \

perl-Pod-Escapes-*.el7.noarch.rpm \

perl-Pod-Perldoc-*.el7.noarch.rpm \

perl-Pod-Simple-*.el7.noarch.rpm \

perl-Pod-Usage-*.el7.noarch.rpm \

perl-podlators-*.el7.noarch.rpm \

perl-Scalar-List-Utils-*.el7.x86_64.rpm \

perl-Socket-*.el7.x86_64.rpm \

perl-srpm-macros-*.el7.noarch.rpm \

perl-Storable-*.el7.x86_64.rpm \

perl-Test-Harness-*.el7.noarch.rpm \

perl-Text-ParseWords-*.el7.noarch.rpm \

perl-Thread-Queue-*.el7.noarch.rpm \

perl-threads-*.el7.x86_64.rpm \

perl-Time-Local-*.el7.noarch.rpm \

perl-TimeDate-*.el7.noarch.rpm \

perl-URI-*.el7.noarch.rpm \

perl-WWW-RobotRules-*.el7.noarch.rpm \

perl-XML-Filter-BufferText-*.el7.noarch.rpm \

perl-XML-NamespaceSupport-*.el7.noarch.rpm \

perl-XML-Parser-*.el7.x86_64.rpm \

perl-XML-SAX-*.el7.noarch.rpm \

perl-XML-Simple-*.el7.noarch.rpm \

gdbm-devel-*.x86_64.rpm \

glibc-devel-*.x86_64.rpm \

glibc-headers-*.x86_64.rpm \

kernel-headers-*.x86_64.rpm \

libdb-devel-*.x86_64.rpm \

systemtap-sdt-devel-*.x86_64.rpm \

mailcap-*.noarch.rpm

Note that I started with the minimal install; your system may start with a different set of packages installed, so you may get messages indicating that one or more of these packages is already installed (or you might get errors about additional dependencies that you don’t have installed that I did happen to have installed). These should be fairly easily resolved.

注意到我是最小化安装的centos7;你的系统可能安装了其他的包,所以你可能会看到更多已安装的包(或者你会得到关于其他未安装依赖包的报错,而这些依赖包恰恰是我碰巧安装了的)。这些应该清楚并且很容易被解决。

Once you have the prerequisites installed, run the script this way:

一旦你安装好了先决条件,运行以下脚本文件

1

2

~/kickstart_build/utils/gather_packages.pl ~/kickstart_build/comps.xml \

~/kickstart_build/all_rpms ~/kickstart_build/isolinux/Packages x86_64

By default, gather_packages.pl will gather all the packages for the base and core package groups. You can specify more on the command line. For example, for my system, I do this:

默认地,pl文件会搜集有关base包组、core包组所有的包。你可以通过命令定义更多。例如,我是这样做的:

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

~/kickstart_build/utils/gather_packages.pl ~/kickstart_build/comps.xml \

~/kickstart_build/all_rpms ~/kickstart_build/isolinux/Packages x86_64 \

debugging \

directory-client \

file-server \

ftp-server \

hardware-monitoring \

java-platform \

large-systems \

load-balancer \

mariadb \

network-file-system-client \

performance \

perl-runtime \

remote-system-management \

ruby-runtime \

web-server

Add your own RPMs添加你自己的rpms

If you want to add any RPMs not included in the base and core groups (for example, httpd, php, or mysql), copy those into the ~/kickstart_build/isolinux/Packages directory at this time.

如果你想添加任意的rpms(既没有在base组、也没有在core组),那就拷贝这些rpms到Packages目录

Resolve dependencies 解析依赖包

Now we have all the base and core RPMs in our ~/kickstart_build/isolinux/Packages directory, along with any other RPMs you’ve added, but many are missing their dependencies. So the next step is to track down all the dependencies of these packages and throw those into the directory, too. You can use another script, resolve_deps.pl, to perform this step.

现在我们已经有所有有关base、core的rpms包在我们Packages目录下,当然也有其他你额外添加进去的包,但是很多都丢失了他们的依赖包。所以下一步是替这些包在该目录下追寻所有的依赖。你可以使用这个resolve_deps.pl去执行这一步骤。

1

2

3

4

~/kickstart_build/utils/resolve_deps.pl \

~/kickstart_build/all_rpms \

~/kickstart_build/isolinux/Packages \

x86_64

Testing dependencies测试依赖

Once you’ve got a set of RPMs ready, you’ll need to test the dependencies of the RPMs. Each RPM may require that other RPMs be installed in order for it to be installed. If each RPM’s dependencies are included in the set of RPMs, then all the dependencies are resolved. The objective is to have a set of RPMs that have no unresolved dependencies.

一旦你准备好了rpms,你将需要测试rpms的依赖情况。每个rpm可能要求

To test the dependencies in your set of RPMs, run these commands:

1

2

3

4

cd ~/kickstart_build/isolinux/Packages

mkdir /tmp/testdb

rpm --initdb --dbpath /tmp/testdb

rpm --test --dbpath /tmp/testdb -Uvh *.rpm

If you find you have unresolved dependencies (and you will almost certainly have some), you can do one of two things:

如果你发现你没解决的依赖(几乎都会有),你可以做以下2选1

  • remove the RPM with the unresolved dependencies (a good idea if the RPM is going to set off a chain of dependencies that you don’t want, for example X Windows on a server class installation)
  • 移除这个rpm
  • track down the RPMs to fulfill the dependency
  • 彻查到底

Here, again, you need a little bit of savvy to determine which packages should be removed. In general, if the package is one that you explicitly added to the base and core groups, then you’ll probably want to find the dependencies and include them. If it’s an RPM that you don’t really want (one that got matched by the wildcard, for example), you might decide to eliminate that RPM.

到这里,你需要有点点知识去决定那个包的去留。一般地,如果这个包是你明确地要添加到base、core组的话,然后你将尽可能的想找到它的依赖并且把他们搞进来。那如果不是很想要的包,那么你要决定删除它

Resolving dependencies

The resolve_deps.pl script will get most dependencies automatically. But not always.

此pl文件将自动获得更多的依赖,但并非总是如此。

Some RPMs report their dependencies in strange ways. For example, usbutils reports a dependency on /usr/bin/pkg-config. But not a single package in the distribution reports that it provides /usr/bin/pkg-config.

一些rpms使用了一些奇怪的方式去宣告所需的依赖。例如,usbutils宣告依赖必需在/usr/bin/pkg-config。但不是来源于发行版单一的包

/usr/bin/pkg-config is contained within the pkgconfig RPM. But the RPM reports that it provides the following:

/usr/bin/pkg-config包含了围绕pkgconfig 的rpm。但是这rpm宣告:

1

2

3

4

5

$ rpm -q --provides -p pkgconfig-0.27.1-4.el7.x86_64.rpm

warning: pkgconfig-0.27.1-4.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID fd431d51: NOKEY

pkgconfig = 1:0.27.1-4.el7

pkgconfig(pkg-config) = 0.27.1

pkgconfig(x86-64) = 1:0.27.1-4.el7

Note that rpm does not report that the package provides “/usr/bin/pkg-config“. My script isn’t smart enough to know that pkgconfig(pkg-config) means that the binary /usr/bin/pkg-config gets installed. So the dependency goes unmatched.

注意到rpm没有宣告这个包提供/usr/bin/pkg-config。我的脚本不会智能地知道pkgconfig(pkg-config) ,这个代表/usr/bin/pkg-config已经安装了。所以依赖就不会被映射到

There are a few packages in the base and core groups that do this, but not too many, thankfully. After running resolve_deps.pl, I got these failed dependencies when I tested the repo:

base跟core这里会有一些包存在这情况,但不会很多。在运行了pl文件后,我获得了一个报错:

1

2

3

4

5

6

7

8

error: Failed dependencies:

/usr/bin/pkg-config is needed by bash-completion-1:2.1-6.el7.noarch

/usr/sbin/cgrulesengd is needed by cgdcbxd-1.0.2-5.el7.x86_64

/usr/bin/fipscheck is needed by fipscheck-lib-1.4.1-5.el7.x86_64

/usr/bin/db_stat is needed by rpm-4.11.1-16.el7.x86_64

/usr/bin/pkg-config is needed by shared-mime-info-1.1-7.el7.x86_64

/usr/bin/pkg-config is needed by usbutils-007-4.el7.x86_64

/usr/bin/pkg-config is needed by xorg-x11-font-utils-1:7.5-18.1.el7.x86_64

So through some sleuthing, I determined that I needed these files:

通过一些查阅,我确定我需要以下的文件:

1

2

3

4

5

6

cd ~/kickstart_build/all_rpms

cp fipscheck-*.el7.x86_64.rpm \

libdb-utils-*.el7.x86_64.rpm \

libcgroup-tools-*.el7.x86_64.rpm \

pkgconfig-*.el7.x86_64.rpm \

~/kickstart_build/isolinux/Packages

Depending on which package groups you specified to gather_packages.pl, you may have additional situations like this that require more investigation. If you’ve brought in RPMs from other repos, or you’ve included your own compiled RPMs, the situation could be even more complicated, but if you are doing this, hopefully you know how to deal with it.

基于你定义到 gather_packages.pl的包组,你可能有其他的情况,这就需要更多的研究:如果你从其他repos带来的rpms,这情况就更为复杂了,但如果你正在做这个,很有希望地你会知道如何去解决。

When resolve_deps.pl runs, it creates a file /tmp/providers.txt that lists every RPM and the capabilities provided by each. It might help you match up some of these non-obvious dependencies.

当 resolve_deps.pl跑起来的时候,它创建了一个文件 /tmp/providers.txt ,这文件列出每一个rpm和它提供的能力。他将帮助你匹配出一些不明显的依赖。

If you have installed CentOS 7 to another system with a lot of RPMs installed, you can use the rpm -q --whatprovides query on that system to try to track it down.

如果你已经安装了centos7 并且有很多rpm安装了,你可以使用rpm -q --whatprovides 在系统上查询,以尝试追寻依赖。

When all else fails, try googling for “rpm /path/to/file/in/question”; sometimes you can figure it out that way.

当其他报错时,尝试谷歌rpm /path/to/file/in/question,或许有帮助。

This is an iterative process. Every time you add a new RPM to the directory, you need to test the dependencies. Be prepared to spend a while chasing down these dependencies to build a fine-tuned collection of RPMs with no unresolved dependencies.

这是一个重复的进程。每一次你添加新的rpm到目录,你就需要测试它的依赖。准备好去花费努力寻找依赖,以创建一个调整好的、并没有待解决依赖的rpms集合

“Hidden” dependencies隐藏的依赖

One would hope that the resulting collection of RPMs would be complete, providing all dependencies. However, it seems that anaconda can’t complete the installation without some additional packages:

一种希望rpms集合完美完成,提供所有的依赖。但是,如果缺少其他的包,这看起来anaconda并不能完成安装

  • authconfig (@base)
  • chrony (@base)
  • firewalld (@base)
  • grub2 (@anaconda-tools)

(the containing package group for each package is listed in parens)

If you’re using gather_packages.pl, these should not be a problem;

如果你正使用gather_packages.pl ,这不会出现问题;

gather_packages.pl always includes the @base package group. It also includes grub2 specifically because of this problem.

gather_packages.pl 总是包括base包组。由于这个问题,它也会包括grub2

Next steps

The next step is to build your disk image. I will cover that in the next installment.

下一步是创建你的镜像。

Building a custom CentOS 7 kickstart disc, part 3

January 4, 2012Linux

28

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Now that you’ve compiled your RPMs, you need to build a disk image from which to perform the kickstart.

既然你已经编辑好你的rpms,你需要建一个disk镜像

Create the repository创建仓库

Install createrepo so that you can create a repository. If you’ve copied all the RPMs to ~kickstart_build/all_rpms as suggested earlier, just do this:

安装createrepo,以至于你可以创建一个仓库。如果你已经拷贝了所有rpm包到 ~kickstart_build/all_rpms

1

2

3

4

5

6

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh \

createrepo-*.el7.noarch.rpm \

deltarpm-*.el7.x86_64.rpm \

python-deltarpm-*.el7.x86_64.rpm \

libxml2-python-*.el7.x86_64.rpm

You need to build the repodata for your install disc. These files provide the installer information about the available packages. On your build machine, you should have already copied the repodata/comps.xml file from the CentOS disc to ~/kickstart_build. Use createrepo to build the repository info.

你需要为安装disc创建这个repodata。这些repodata文件提供了有关可提供安装包安装器的信息。在你自建的机器上,你应该准备好了拷贝 repodata/comps.xml这一动作。那么现在使用createrepo去创建仓库吧

1

2

cd ~/kickstart_build/isolinux

createrepo -g ~/kickstart_build/comps.xml .

This will create a repodata directory under ~/kickstart_build/isolinux with the repository data files in it.

Note: in CentOS 6, you had to use the contents of .discinfo to set the baseurl (declare -x discinfo=head -1 .discinfo; createrepo -u "media://$discinfo" ...); you don’t do this any more. In fact, if you do, your kickstart will bail out at some point, saying something like “RepoError after 10 retries: Insufficient space in download directory /run/install/repo/Packages”. It seems that having this media:// baseurl in the repo causes yum to try to update the repo on your DVD, which it can’t do, since the filesystem is read-only and is technically full (thus the “insufficient space” error message). I was stuck on this for a few hours before I stumbled across the fix.

Build the ISO

Install the genisoimage package so that you can create an ISO.

1

2

3

4

cd ~/kickstart_build/all_rpms

sudo rpm -Uvh \

genisoimage-*.el7.x86_64.rpm \

libusal-*.el7.x86_64.rpm

We’re finally ready to build the ISO image that we can burn to CD.

1

2

3

4

5

cd ~/kickstart_build

chmod 664 isolinux/isolinux.bin

mkisofs -o custom.iso -b isolinux.bin -c boot.cat -no-emul-boot \

-V 'CentOS 7 x86_64' \

-boot-load-size 4 -boot-info-table -R -J -v -T isolinux/

You should now have an ISO image in custom.iso.

Testing the ISO测试iso文件

Rather than spending the time to burn a DVD and perform a physical installation, you can test the ISO using a virtual machine, which you can run under a program like VirtualBox.

When the system (virtual or physical) boots up, you’ll see your standard CentOS installation prompt. Before the countdown expires, hit ESC and type

1

linux inst.ks=cdrom:/dev/cdrom:/ks/ks.cfg

Note that there have been substantial changes to the format of the value used with the ks option in CentOS 7.

  • The new option is inst.ks instead of just ks, but ks will still work; use inst.ks for future-proofing
  • The new value has three parts; the first specifies that we want to install from a cdrom; the second specifies the device, and is technically optional (if you only have a single cdrom/dvd drive, the installer should use that). However, I have found that if you don’t specify /dev/cdrom, your kickstart installation will fail horribly, dropping to a dracut emergency shell with errors like /dev/root does not exist. And while you may find examples online that specify it as something like /dev/sr0, rest assured that this will not work — you must use /dev/cdrom. This cost me countless hours of experimentation and reading hundreds of forum posts and bug reports. This time is my gift to you.

If you specify the options correctly, your installation should proceed automatically.

Note that if you really want to make your kickstart easy, you can add an entry to the isolinux/isolinux.cfg file like this:

1

2

3

4

5

label ks

menu label ^Kickstart

menu default

kernel vmlinuz

append initrd=initrd.img inst.stage2=hd:LABEL=CentOS\x207\x20x86_64 inst.ks=cdrom:/dev/cdrom:/ks/ks.cfg

This will put an entry into the boot menu so you can just select it to run your kickstart without having to manually type the boot options.

Next steps

Now you have a working custom kickstart disc. To really take advantage of the power of kickstart, you’ll most likely need a custom postinstallation script to configure the system according to your specs. We’ll cover that in the next installment in this series.

现在你有了可以使用的自定义 kickstart disc。为了真正利用kickstart的强大能力,你将尽可能地需要一个完善好的脚本文件去配置这个系统。下一部分,我们重点讲解

Building a custom CentOS 7 kickstart disc, part 4

January 4, 2012Linux

25

Note: this series of articles applies to CentOS 7; for CentOS 6, see this series.

Let’s make things really interesting with a postinstall script to do some custom configuration.

The %post section %post部分讲解

In your kickstart configuration file, you can have sections of commands that are designated to run after the anaconda installer has done its work. These sections are denoted with the %post directive.

在你的kickstart配置文件中,你可以在anaconda安装器完成他的工作后指定一些命令去执行。这些部分是放在%post指令

Typically, you follow this directive with the bash shebang line and the contents of a custom shell script. One thing to note is the filesystem organization at this point during the installation. Your new system’s disk is mounted at /mnt/sysimage, not at / the way it will be once the system is up and running after installation.

典型地,你基于这个指令后面,伴随一些bash工作行以及自定义的shell脚本。一点要注意是文件系统组织。一旦安装好了后,你的新系统硬盘是挂载到/mnt/sysimage,不是在/。

By default, the commands in the %post section are run in a chroot environment, where /mnt/sysimage appears as the / directory. This lets you use “normal” paths to configuration files like /etc instead of /mnt/sysimage/etc (if you didn’t chroot like this, you wouldn’t be able to do things like install RPMs). The primary disadvantage is that your install media is not visible in a chrooted environment.

默认地,%post部分的命令是运行在chroot 环境,/mnt/sysimage作为一个类似/ 的根目录。这会让你使用一般的配置文件路径就像/etc被代替成/mnt/sysimage/etc(如果你没做改变程序执行时所参考的根目录位置,你将没办法执行类似安装rpms的动作),这主要的缺点是在chrooted下的环境你的安装媒体是不可见的。

We solve this problem by building our postinstall in two stages. In the first stage, we tell anaconda not to chroot us; we then copy files from the CD to the hard drive.

解决这个问题分2步。在第一步,我们告诉anaconda别去做改变程序执行时所参考的根目录位置;然后从CD文件拷贝到硬盘。

1

2

3

4

5

6

7

8

9

10

11

%post --nochroot

#!/bin/sh

set -x -v

exec 1>/mnt/sysimage/root/kickstart-stage1.log 2>&1

echo "==> copying files from media to install drive..."

cp -r /run/install/repo/postinstall /mnt/sysimage/root

%end

In our case, we’ve put all our postinstallation files into the postinstall directory under the ~/kickstart_build/isolinux directory. Note that the isolinux directory in our build environment becomes the root of the install disc that we create, and the install disc is mounted at /run/install/repo.

在我们的情况,,我们已经把所有的预安装文件放到了~/kickstart_build/isolinux /postinstall 目录。注意到在我们自建的环境下的isolinux目录变成了the root of the install disc that we create, install disc被挂载到了/run/install/repo

So ~/kickstart_build/isolinux/postinstall is available at /run/install/repo/postinstall. We copy postinstall directory on the install disc to /root/postinstall on the new system’s hard drive.

所以 ~/kickstart_build/isolinux/postinstall在/run/install/repo/postinstall能够被找到。我们拷贝在install disc的postinstall 目录到新系统上的/root/postinstall

We’re now ready to run stage 2 of the postinstall, where we actually use the postinstallation files.

我们现在准备执行第二步,这里事实上使用的是这个postinstallation 文件

1

2

3

4

5

6

7

8

9

10

%post

#!/bin/sh

set -x -v

exec 1>/root/kickstart-stage2.log 2>&1

ls -l /root/postinstall

%end

Note that in both the stage1 and stage2 postinstall scripts, I redirect stdout to a log file in root’s home directory. This is very helpful for diagnosing problems during the kickstart postinstall. This comes in handy when you have many hundreds of lines of postinstall that need to be tested and debugged.

注意到这两步的postinstall 脚本,我重定向stdout到一个坐落在root的home目录下的日志文件。在kickstart postinstall安装期间,这对诊断问题非常有用。

The sky is the limit for what you can do in the postinstallation:

在postinstallation里头,你做任何事都没限制

  • add users or groups
  • install non-CentOS applications from RPMs (see below for some good repos)
  • install non-CentOS applications from tarballs (I prefer RPMs where available, but sometimes you don’t have them handy)
  • set the runlevels for various system services
  • configure servers like apache, samba, sshd, and MySQL
  • configure the default behavior of the bash shell

and anything else you could imagine. In my ideal world, my machines are ready to perform their designated tasks from the very first second I boot them up. I don’t want to have a series of manual steps to complete the configuration.

并且可以做任何你想做的。在我的想法里,一旦我启动了,我的机器已经准备及时执行指定好的任务。我不想又有一系列的手动步骤去完成这个配置。

Organizing the postinstall files 组织postinstall 文件

If I can offer any suggestions in terms of how you organize your postinstall files, I would suggest breaking the files up into directories like this:

就你要组织你的postinstall 文件而言,我会建议你做个分解到目录:

1

2

3

4

5

~/kickstart_build/isolinux/postinstall

+-- apps

+-- appconfig

+-- sysconfig

+-- libs

Put your non-CentOS application RPMs and tarballs into apps (with a subdirectory for each application), put application configuration files and scripts into appconfig (again with a subdirectory for each application), put OS configuration files (like network config files) into sysconfig, and put general-purpose libraries (those not specifically required by any applications you’re installing) into libs.

把你的non-CentOS 应用程序rpms和tarballs (压缩包)到apps目录,把应用程序的配置文件和脚本放到appconfig ,把OS 配置文件(像网络配置文件)放到sysconfig,把通用的librares放到libs

Of these strategies, the organization of apps is by far the most important. When you install applications that are not part of the CentOS distro, you’ll likely have to install additional libraries or utilities to satisfy dependencies in those packages. When you need to refresh your kickstart image, it is helpful to have each app and its dependencies contained in a single directory. If you throw them all into a big directory, you’ll never remember, for example, that mhash is in there because aide requires it.

基于这种策略,apps的组织就变得非常重要。当你安装的应用程序不是所属于CentOS distro,你将必需安装其他的libraries 或者utilities 去满足这些包的依赖。当你需要恢复你的kickstart 镜像,把每一个app和它的依赖放到一个目录下是很有帮助的。如果你把他们都丢在了一个大目录下,你将很容易忘记

External repositories外部仓库

I have found the following repositories to be reliable sources of packages that aren’t included in the CentOS distro:

我找到了以下的的仓库,他们可以提供可靠的包源,但他们不属于CentOS distro

  • EPEL – Extra Packages for Enterprise Linux
  • repoforge – formerly RPMforge; DAG repository now redirects to this
  • ATrpms – good place to get ffmpeg rpms
  • ELrepo – source for hardware drivers

Good luck building your custom installation disc. I welcome any comments or suggestions you might have for this guide!

定制化centos7相关推荐

  1. CentOS7光盘定制化

    CentOS7-1511光盘定制化制作: 部分专业词汇释义: 包组:一个功能块往往由多个rpm安装包才能完成安装,此时所有此功能必备的安装包称之为一个包组. isolinux.bin:是光盘引导程序, ...

  2. fpm定制化RPM包之nginx rpm包的制作

    fpm定制化RPM包之nginx rpm包的制作 1.安装ruby模块 # yum -y install ruby rubygems ruby-devel 2.添加阿里云的Rubygems仓库,国外资 ...

  3. 自动化部署必备技能—定制化RPM包[转载]

    回顾下安装软件的三种方式: 1.编译安装软件,优点是可以定制化安装目录.按需开启功能等,缺点是需要查找并实验出适合的编译参数,诸如MySQL之类的软件编译耗时过长.  2.yum安装软件,优点是全自动 ...

  4. 使用lorax 构建定制化操作系统

    构建定制化操作系统 文章目录 构建定制化操作系统 前言 一.构建定制化操作系统步骤 1. 安装所需的linux操作系统. 2. 下载所需工具 3. 构建本地软件库 4. 构建本地所需的操作环境 5. ...

  5. 面向隐私AI的TensorFlow深度定制化实践

    作者 | Rosetta团队 出品 | AI科技大本营(ID:rgznai100) 之前我们整体上介绍了基于深度学习框架开发隐私 AI 框架中的工程挑战和可行解决方案.在这一篇文章中,我们进一步结合 ...

  6. AI进军服装零售产业:微软小冰与特步推出定制化服装设计生产及零售平台

    (6月22日,北京) 今日,体育用品企业特步集团与微软小冰宣布达成合作,依托微软小冰人工智能创造技术共同推出的定制化服装设计生产及零售平台即将上线.双方携手为消费者提供定制化图案设计,满足每个消费者的 ...

  7. 独家 | 高季尧:定制化优化算法的应用与威力(附PPT)

    随着大数据与人工智能领域技术的发展和应用的普及,算法越发繁多复杂,需要处理的数据量也越发庞大,高性能计算能力就显得尤为重要. 本篇选自高季尧先生近期于清华大数据"技术·前沿"系列讲 ...

  8. SKChoosePopView 一个HUD风格的可定制化选项弹窗的快速解决方案

    原文地址----> MyBlog HUD风格的选项弹窗是我们在日常开发中经常会碰到的一类需求,通常因为项目周期等因素,很少会专门抽出时间来对此类弹窗进行专门的定制开发和维护.常见的情况就是goo ...

  9. Oceanus:美团HTTP流量定制化路由的实践

    背景简述 Oceanus是美团基础架构部研发的统一HTTP服务治理框架,基于Nginx和ngx_lua扩展,主要提供服务注册与发现.动态负载均衡.可视化管理.定制化路由.安全反扒.session ID ...

最新文章

  1. 前端抱怨 API 响应慢,怎么办?
  2. [一文一命令]head命令详解
  3. 【数字信号处理】相关函数应用 ( 相关函数应用场景 | 噪声中检测信号原理 )
  4. Django之路——6 Django的模型层(二)
  5. C语言实验——大小写转换_JAVA
  6. 零基础学习Java开发,这些学习笔记送给你!
  7. 2019.01.26【NOIP普及组】模拟赛C组总结
  8. 汇编语言:实验10 根据材料编程—3.数值显示,编程,将data段中的数据以十进制形式显示出来
  9. 清除SQL SERVER日志
  10. 张高兴的 Xamarin.Android 学习笔记:(二)“Hello World”
  11. forward/redirect跳转页面的区别
  12. 孔浩Maven视频教程
  13. LeetCode 常用方法
  14. ELK 收集 Tomcat 日志
  15. 学习《华为基本法》(6):公司的成长
  16. 适合ABB和halcon互转——四元数与欧拉角互转方法C#
  17. 总结:伺服电机控制及结合强弱电的控制系统
  18. Error: Packagesfrx7 and VCLDB all Contains DBGrids
  19. JS实现 b站直播弹幕自动补中括号、一键常用语脚本
  20. echarts制作两个纵轴的折线图

热门文章

  1. IBM WebShere Portal主题与皮肤开发
  2. Android应用接入微信开放平台
  3. ASEMI代理MC34PF3001A7EP原装现货NXP车规级MC34PF3001A7EP
  4. Packets larger than max_allowed_packet are not allowed
  5. 中科院一博士论文致谢走红,同年的我也有一封未发表的致谢......
  6. 解析几何:第一章坐标系与坐标变换:平面直角坐标系、空间直角坐标系及其变换、极坐标系,圆柱面坐标系,球面坐标系
  7. 基于ARM的嵌入式Linux开发平台
  8. [NLP] 文本分类之TextCNN模型原理和实现(超详细)
  9. P1-2017级第一次算法上机 F SkyLee的艾露猫
  10. 基于激光雷达实现三边定位算法开发记录(五)——三角函数法拟定圆心