cobbler定制化安装Centos7.2操作系统

一、定制Centos_7_x86_64.ks文件内容

# Cobbler for Kickstart Configurator for CentOS 7.2.1511 by Wolf_Dreams

# Install OS instead of upgrade
install
# Use network installation(The starting "$" variables are all values in the call configuration file)
url --url=$tree  #引用cobbler配置文件来进行安装
# Use text mode install(graphical, text, or cmdline)
text  #采用文本方式安装
# System language
lang en_US.UTF-8  #指定系统语言
# System keyboard
keyboard us  #指定键盘使用语言
# Clear the Master Boot Record
zerombr  #清空系统主引导记录(原机器有系统)
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto net.ifnames=0 biosdevname=0 rhgb quiet"  #引导启动器
# Network information
$SNIPPET(‘network_config‘)
# System timezone
timezone --utc Asia/Shanghai --ntpservers=ntp1.aliyun.com
# System authorization information(Use shadow passwords,set up the SHA-512 hashing)
authconfig --enableshadow --passalgo=sha512  #设置认证信息
#Root password
rootpw  --iscrypted $default_password_crypted  #新装系统默认密码
# Partition clearing information
clearpart --all –initlabel  #删除分区信息
# Allow manual partitioning of the system as needed(default fstype xfs or default units MB)
part /boot --fstype xfs --size 500
part swap --size 2048
part / --fstype xfs --grow  #逻辑磁盘的所有分区都划分给根(/)分区
# Run the Setup Agent on first boot
firstboot --disable
# SELinux configuration
selinux --disabled
# Firewall configuration
firewall --disabled
#Controls the error logging of Anaconda during installation. It has no effect on the installed system.
logging --level=info
# Do not configure the X Window System
skipx  #不配置x window桌面系统
# Creates a new user group
group --name=development
# Creates a new user on the system
user --name=gandalf --groups=development --homedir=/data/gandalf --password=123456 --shell=/bin/sh
# Reboot after installation
reboot

# Pre-installation Script(The %pre script is run on the system immediately after the Kickstart file has been parsed, but before installation begins. )
%pre --log=/var/log/ks-pre.log
$SNIPPET(‘log_ks_pre‘)  #调用的文件存放在/var/lib/cobbler/snippets目录下
$SNIPPET(‘kickstart_start‘)  #调用kickstart开始安装
$SNIPPET(‘pre_install_network_config‘)
# Enable installation monitoring
$SNIPPET(‘pre_anamon‘)
%end

# Package Selection(The %packages section must end with the %end command.)
%packages  #定制安装完的系统安装有什么软件包(@代表安装软件包组-代表不安装什么软件包,没有前缀代表单个软件包)
@base
@compat-libraries
@debugging
@development
net-tools
tree
lrzsz
vim
telnet
nmap
sysstat
dos2unix
iptraf
ncurses-devel
openssl-devel
zlib-devel
OpenIPMI-tools
screen
%end

# Post-installation Script(You have the option of adding commands to run on the system once the installation is complete, but before the system is rebooted for the first time)
#Logs the script‘s output into the specified log file(/var/log/ks-post.log)
%post --log=/var/log/ks-post.log
systemctl disable postfix.service
%end

# kdump configuration(enable,The amount of memory you want to reserve for kdump, in MiB)
%addon com_redhat_kdump --enable --reserve-mb=128  #开启系统崩溃转存机制kdump
%end

# Jump to local drive boot start
%post
# Start final steps
$SNIPPET(‘kickstart_done‘)  #防止系统循环安装,即调用pxe_just_once=1
%end

二、指定Centos_7_x86_64.ks文件及调整内核net.ifnames=0 biosdevname=0参数

1、切换到存放kickstarts文件目录并查看其目录所有文件

[[email protected] ~]# cd /var/lib/cobbler/kickstarts/
[[email protected] kickstarts]# ls
default.ks    install_profiles  sample_autoyast.xml  sample_esxi4.ks  sample.ks
esxi4-ks.cfg  legacy.ks         sample_end.ks #默认ks文件        sample_esxi5.ks  sample_old.seed
esxi5-ks.cfg  pxerescue.ks      sample_esx4.ks       sample_esxi6.ks  sample.seed

2、执行rz命令上传定制的Centos_7_x86_64.ks文件

[[email protected] kickstarts]# rz
rz waiting to receive.
Starting zmodem transfer.  Press Ctrl+C to cancel.
Transferring Centos_7_x86_64.ks...
  100%       2 KB       2 KB/sec    00:00:01       0 Errors  

3、查看定制的Centos_7_x86_64.ks文件属性

[[email protected] kickstarts]# ls -ldh Centos_7_x86_64.ks
-rw-r--r-- 1 root root 2.7K May 26 13:30 Centos_7_x86_64.ks

4、查看cobbler镜像文件及profile配置文件

[[email protected] kickstarts]# cobbler distro list
   CentOS-6.8-x86_64
   CentOS-7-x86_64
[[email protected] kickstarts]# cobbler profile list
   CentOS-6.8-x86_64
   CentOS-7-x86_64

5、查看首次导入系统镜像后,安装镜像的文件信息

[[email protected] kickstarts]# cobbler distro report --name=CentOS-7-x86_64
Name                           : CentOS-7-x86_64
Architecture                   : x86_64
TFTP Boot Files                : {}
Breed                          : redhat
Comment                        :
Fetchable Files                : {}
Initrd                         : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/initrd.img
Kernel                         : /var/www/cobbler/ks_mirror/CentOS-7-x86_64/images/pxeboot/vmlinuz
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart Metadata             : {‘tree‘: ‘http://@@[email protected]@/cblr/links/CentOS-7-x86_64‘}
Management Classes             : []
OS Version                     : rhel7
Owners                         : [‘admin‘]
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Template Files                 : {}

6、查看指定的profile设置,cobbler默认使用/var/lib/cobbler/kickstarts/sample_end.ks文件

[[email protected] kickstarts]# cobbler profile report --name=CentOS-7-x86_64
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/sample_end.ks #系统默认使用的kickstart文件
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : [‘admin‘]
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm

7、检查kickstart文件的完整性

[[email protected] kickstarts]# ksvalidator Centos_7_x86_64.ks
The following problem occurred on line 18 of the kickstart file:

Unknown command: $SNIPPET(network_config)  #忽略该项

8、编辑profile配置文件,修改关联的kickstart文件

[[email protected] kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kickstart=/var/lib/cobbler/kickstarts/Centos_7_x86_64.ks

9、指定更改Centos7网卡名称为ethx,指定参数--kopts=‘net.ifnames=0 biosdevname=0‘

[[email protected] kickstarts]# cobbler profile edit --name=CentOS-7-x86_64 --kopts=‘net.ifnames=0 biosdevname=0‘

10、再次查看指定的profile设置,kickstart文件/var/lib/cobbler/kickstarts/Centos_7_x86_64.ks

[[email protected] kickstarts]# cobbler profile report --name=CentOS-7-x86_64
Name                           : CentOS-7-x86_64
TFTP Boot Files                : {}
Comment                        :
DHCP Tag                       : default
Distribution                   : CentOS-7-x86_64
Enable gPXE?                   : 0
Enable PXE Menu?               : 1
Fetchable Files                : {}
Kernel Options                 : {‘biosdevname‘: ‘0‘, ‘net.ifnames‘: ‘0‘}  #centos7需要设置,centos6不需要设置
Kernel Options (Post Install)  : {}
Kickstart                      : /var/lib/cobbler/kickstarts/Centos_7_x86_64.ks #更改成指定的kickstart文件
Kickstart Metadata             : {}
Management Classes             : []
Management Parameters          : <<inherit>>
Name Servers                   : []
Name Servers Search Path       : []
Owners                         : [‘admin‘]
Parent Profile                 :
Internal proxy                 :
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos                          : []
Server Override                : <<inherit>>
Template Files                 : {}
Virt Auto Boot                 : 1
Virt Bridge                    : xenbr0
Virt CPUs                      : 1
Virt Disk Driver Type          : raw
Virt File Size(GB)             : 5
Virt Path                      :
Virt RAM (MB)                  : 512
Virt Type                      : kvm
[[email protected] kickstarts]# cobbler sync

三、定制化安装指定操作系统方法

1、查看指定服务器的MAC地址(区分不同物理服务器采用MAC地址区分)

2、指定服务器使用指定的kickstart文件

[[email protected] kickstarts]# cobbler system add --name=cobbler-client --mac-address=00:0C:29:97:85:40 --profile=CentOS-7-x86_64 --ip-address=172.16.0.100 --netmask=255.255.255.0 --gateway=172.16.0.1 --interface=eth0 --static=1 --hostname=cobbler-client --name-servers="114.114.114.114 8.8.8.8"
[[email protected] kickstarts]# cobbler system list
   cobbler-client
[[email protected] kickstarts]# cobbler sysnc

3、修改指定系统的IP地址

[[email protected] kickstarts]# cobbler system edit --name=cobbler-client --ip-address=172.16.0.190
[[email protected] kickstarts]# cobbler system report --name=cobbler-client
Name                           : cobbler-client
TFTP Boot Files                : {}
Comment                        :
Enable gPXE?                   : <<inherit>>
Fetchable Files                : {}
Gateway                        : 172.16.0.1
Hostname                       : cobbler-client
Image                          :
IPv6 Autoconfiguration         : False
IPv6 Default Device            :
Kernel Options                 : {}
Kernel Options (Post Install)  : {}
Kickstart                      : <<inherit>>
Kickstart Metadata             : {}
LDAP Enabled                   : False
LDAP Management Type           : authconfig
Management Classes             : <<inherit>>
Management Parameters          : <<inherit>>
Monit Enabled                  : False
Name Servers                   : [‘114.114.114.114‘, ‘8.8.8.8‘]
Name Servers Search Path       : []
Netboot Enabled                : True
Owners                         : <<inherit>>
Power Management Address       :
Power Management ID            :
Power Management Password      :
Power Management Type          : ipmitool
Power Management Username      :
Profile                        : CentOS-7-x86_64
Internal proxy                 : <<inherit>>
Red Hat Management Key         : <<inherit>>
Red Hat Management Server      : <<inherit>>
Repos Enabled                  : False
Server Override                : <<inherit>>
Status                         : production
Template Files                 : {}
Virt Auto Boot                 : <<inherit>>
Virt CPUs                      : <<inherit>>
Virt Disk Driver Type          : <<inherit>>
Virt File Size(GB)             : <<inherit>>
Virt Path                      : <<inherit>>
Virt PXE Boot                  : 0
Virt RAM (MB)                  : <<inherit>>
Virt Type                      : <<inherit>>
Interface =====                : eth0
Bonding Opts                   :
Bridge Opts                    :
CNAMES                         : []
InfiniBand Connected Mode      : False
DHCP Tag                       :
DNS Name                       :
Per-Interface Gateway          :
Master Interface               :
Interface Type                 :
IP Address                     : 172.16.0.190
IPv6 Address                   :
IPv6 Default Gateway           :
IPv6 MTU                       :
IPv6 Prefix                    :
IPv6 Secondaries               : []
IPv6 Static Routes             : []
MAC Address                    : 00:0C:29:97:85:40
Management Interface           : False
MTU                            :
Subnet Mask                    : 255.255.255.0
Static                         : True
Static Routes                  : []
Virt Bridge                    : 

[[email protected] kickstarts]# cobbler sync

4、开启服务器自动安装指定的操作系统

5、操作系统安装完成后进行基本验证

定制kickstart文件的语法参考网址

CentOS7:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax#sect-kickstart-commandsCentos6:https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/6/html/installation_guide/s1-kickstart2-options

原文地址:https://www.cnblogs.com/Wolf-Dreams/p/9093879.html

时间: 2024-09-30 07:35:51

cobbler定制化安装Centos7.2操作系统的相关文章

最小化安装centos7实现ifconfig命令

最小化安装centos7无法使用ifconfig命令,可使用命令ip addr进行查看 如需使用ifconfig,安装net-tools套件即可 # yum install net-tools

virtualbox下最小化安装centos7后上网设置

在虚拟机中以最小化方式安装centos7,后无法上网,可以设置 文件 /etc/sysconfig/network-scripts/ifcfg-enp0s3 将 ONBOOT=no 改为 ONBOOT=yes 保存后重启网卡: service network restart 此时就可以上网了. 因为是最小化安装,此时ifconfig命令不能用,可用 命令:ip addr  查看分配网卡情况. 联网后可运行命令: yum install net-tools 来安装ifconfig功能 此时virt

最小化安装CentOS7 + xfce4 +PHP + nginx +mariadb 开发环境

虚拟机自定义最小化安装,新增用户做为管理员,打开自动获取网络,桥接模式.所有的操作只有命令,不做解释,看不明白的可以自行搜索相关的资料. # 开头的行是注释行,# 开头的空行,我自己装机时做了快照.未完待续 1 安装CentOS7 过程: 2 3 # 最小化安装完成快照 4 5 sudo yum install -y wget 6 7 # http://mirrors.163.com/.help/centos.html 8 9 sudo mv /etc/yum.repos.d/CentOS-Ba

virtualbox 最小化安装centos7 配置双网卡(nat和桥接)记录----已经过期

该文章已经过期 请参考另一篇文章:virtualbox 安装centos7 配置桥接网卡,实现主机和虚拟机互通,虚拟机可以访问外网,解决无法上网问题 先说明一下为什么要配置双网卡? 配置nat网络, 虚拟机可以通过主机访问外网, 通过桥接网络, 虚拟机绑定静态ip,可以和其他虚拟机通信 改正:虚拟机可以通过配置一个桥接网卡,访问外网, 不需要配置两个网卡 最小化安装后,nat网卡没有启用,需要修改ifcfg-enp0s3 [[email protected] network-scripts]#

记录最小化安装centos7后所做的一些工作

操作环境 1.1. 虚拟机:    产品:VMware Workstation 版本:7.1.5 build-491717 1.2.  主机操作系统:Windows XP Professional 5.1.2600, Service Pack 3 1.3.虚拟机操作系统: [[email protected] NetworkManager]# uname -a Linux RHEL7 3.10.0-327.el7.i686 #1 SMP Fri Dec 4 17:52:05 UTC 2015 i

最小化安装centos7不能执行ifconfig命令的解决方法

操作环境 虚拟机:VirtualBox 5.0.4 for Windows 操作系统:CentOS-7-x86_64-Minimal-1503-01.iso 问题描述 登录系统之后,输入ifconfig查看IP地址,却提示命名没有找到. 解决方法 1.将虚拟机的网络连接方式设置成桥接网卡 2.启动默认网卡 cd /etc/sysconfig/network-scripts vi ifcfg-enp0s3 将ONBOOT=no 改成yes 说明:ifcfg-enp0s3的名称可能会有所不同. 3.

最小化安装centos7后的简单配置

1.修改网络配置 # cat /etc/sysconfig/network-scripts/ifcfg-eno16777736  BOOTPROTO=static ONBOOT=yes IPADDR= NETMASK= GATEWAY= DNS1= 2.关闭防火墙 # systemctl stop firewalld # systemctl disable firewalld 3.关闭selinux # sed -i 's/SELINUX=enforcing/SELINUX=disabled/g

安装centos7.0操作系统

新建一个虚拟机 不要选择立即分配磁盘大小 在安装前选择自定义硬件 Boot分区,是引导分区,作用,系统启动,在boot分区存放着grub 内核文件等,一般200M就够用. Swap交换分区:内存扩展分区 交换分区一般最多8G 16G 如果系统使用到了swap分区,就直接物理内存或排查一下服务器有没有被黑. / 根:所有文件的根 绝对路径的开始标志 原文地址:https://www.cnblogs.com/xuexue10086/p/9600605.html

u盘启动盘安装centos7.5操作系统

1.下载CentOS 7.5的安装镜像:CentOS-7-x86_64-DVD-1804.iso 2.下载UltraISO:https://cn.ultraiso.net/xiazai.html 3.打开UltraISO,它的操作界面如下图所示,点击左上角的文件,然后再点打开.选择我们刚才展示的CentOS 7.5 安装镜像.然后点击打开. 4.点击菜单栏启动-->写入硬盘映像... 5.点击便捷启动-->写入新的驱动器引导扇区-->Syslinux,这一步需要注意的是U盘的文件格式是F