您的位置:首页 > 编程语言 > PHP开发

Ubuntu Server 12.04下cobbler + dnsmasq +tftpd-hpa的安装配置(四)

2013-11-08 16:09 417 查看
四、自定义 kickstart 文件
Kickstart最早是RedHat公司用来自动部署RedHat操作系统的,通过Kickstart配置文件,通常安装过程中需要交互输入的信息就都可以自动应答。
通过Kickstart安装操作系统一般是这样几个步骤:
Create a kickstart file.
创建单一的kickstart文件
Create a boot media with the kickstart file or make the kickstart file available on the network.
创建包含kickstart文件的启动介质,或者使kickstart文件可以通过网络访问
Make the installation tree available.
准备所安装操作系统,要包括完整的目录树
Start the kickstart installation.
开始kickstart安装过程
Cobbler中默认的kickstart文件目录为,/var/lib/cobbler/kickstarts/,默认的Ks文件为 /var/lib/cobbler/kickstarts/sample.ks。
1. 更改配置文件
修改配置文件
语法:
# cobbler profile edit --name <cobbler profile list 中显示的名称> --kickstart="/var/lib/cobbler/kickstarts/<新编辑好的ks文件名称>"
查看已修改的配置文件
语法:
# cobbler profile getks --name <cobbler profile list 中显示的名称>
2. 自定义范例一
这里以CentOS操作系统的kickstart文件为例。
2.1 配置CentOS6.4的kickstart自动安装脚本
通常安装程序根据在安装过程中的选择创建一个简单的kickstart文件,这个文件会被写入到 /root/anaconda-ks.cfg,所以我们可以在它的基础上做修改即可。
2.1.1 CentOS6.4kickstart范例
文件路径和文件名:/var/lib/cobbler/kickstarts/CentOS6.4_example.ks
#platform=x86, AMD64, or Intel EM64T
#version=DEVEL
# Firewall configuration
firewall --disabled
# Install OS instead of upgrade
install
# Use network installation
url --url="http://192.168.88.253/cobbler/ks_mirror/CentOS-6.4-x86_64/"
# Root password
rootpw --iscrypted $1$6.5.pvtY$78zocSFzXqL6o2RiKy7Ow0
# System authorization information
auth  --useshadow  --passalgo=sha512
# Use text mode install
text
#graphical
# Debug
#interactive
firstboot --disable
# System keyboard
keyboard us
# System language
lang en_US
# SELinux configuration
selinux --disabled
# Installation logging level
logging --level=info
# Reboot after installation
reboot
# System timezone
timezone --isUtc Asia/Hong_Kong
# Network information
network  --bootproto=dhcp --device=eth0 --onboot=on
network  --bootproto=dhcp --device=eth1 --onboot=on
network  --bootproto=dhcp --device=eth2 --onboot=on
network  --bootproto=dhcp --device=eth3 --onboot=on
# System bootloader configuration
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --linux --drives=sda
# Partition
part /boot --fstype=ext4 --size=500
part pv.008002 --grow --size=1
volgroup VolGroup --pesize=4096 pv.008002
logvol / --fstype=ext4 --name=lv_root --vgname=VolGroup --grow --size=1024 --maxsize=51200
logvol swap --name=lv_swap --vgname=VolGroup --grow --size=4000 --maxsize=4000
%packages
@additional-devel
@base
@chinese-support
@compat-libraries
@console-internet
@desktop-platform-devel
@development
@eclipse
@fedora-packager
@internet-browser
@network-file-system-client
@network-tools
@perl-runtime
@ruby-runtime
@server-platform-devel
@storage-client-iscsi
bzr
cjkuni-fonts-ghostscript
ftp
git
iptraf
lftp
mercurial
mock
mutt
nmap
screen
rpmdevtools
wireshark
-ibus-table-cangjie
-ibus-table-erbi
-ibus-table-wubi
%end
2.1.2  配置cobbler CentOS6.4安装时使用的kickstart文件
请按照步骤 1 更改配置文件 来操作。
2.1.3  关于用户密码的设置
我们可以通过在kickstart中引用如下语句来设置你的用户密码:
rootpw --iscrypted $1$6.5.pvtY$78zocSFzXqL6o2RiKy7Ow0
用户密码的加密可以通过如下命令来生成:
# echo "Your password" | openssl passwd -1 -stdin
$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1
也可以在kickstart文件中直接引用cobbler变量 $default_password_crypted,如下:
# Root password
rootpw --iscrypted $default_password_crypted
配置default_password_crypted默认值:
可以通过 配置 /etc/cobbler/settings 中 default_password_crypted为新值。如下:
default_password_crypted: "$1$YybbL2kO$Z35pIGEghtr7AQwUaH7GN1"
2.1.4  安装操作系统后修改下载源配置文件
2.1.4.1 添加cobbler安装过程中使用的安装源
默认安装程序不会修改CentOS的下载源配置文件。我们可以通过配置 /etc/cobbler/setting 中的 yum_post_install_mirror参数为1。
然后在kickstart文件中%post部分添加如下的行:
# Start yum configuration
$yum_config_stanza
# End yum configuration
2.1.4.2 添加其它第三方安装源
以添加mirror.163.com的源为例,在kickstart文件中%post部分添加如下的行:
wget http://mirrors.163.com/.help/CentOS6-Base-163.repo -O /etc/yum.repos.d/CentOS6-Base-163.repo
增加其它第三方的方法也类似
这样cobbler源就会自动添加到新安装好的操作系统中,文件路径和文件名为 /etc/yum.repos.d/cobbler-config.repo。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息