centos用kickstart自动部署ubuntu12

简介:

最近研究kickstart启动,来一篇centos装ubuntu12的文档共享给大家,供大家参考。是经过本人反复测试完善的。

centos6.2 with kickstart网络启动自动安装Ubuntu 12.04(vsftpd+DHCP+TFTP)
参考文章
1、http://www.linuxidc.com/Linux/2012-06/62441.htm
2、百度文库《Ubuntu12.04lts的pxe安装及拾遗》
3、http://bbs.linuxtone.org/thread-10957-1-1.html

#在网络启动的centos服务器上安装kickstart所需软件(如果用dnsmasq+httpd的话,会方便很多,且易于管理;因为dnsmasq=dhcp+tftp+xinetd)


yum install dhcp tftp* xinetd vsftpd

yum install -y dnsmasq


vim /etc/dnsmasq.conf把如下行注释去掉并修改

bogus-priv
filterwin2k
dhcp-range=192.168.44.100,192.168.44.120,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/lib/tftpboot
dhcp-authoritative


#以下是使用vsftpd+DHCP+TFTP的情形

#启用tftp
sed -i '/disable/s/yes/no/g' /etc/xinetd.d/tftp

将/var/lib/tftpboot链接到/tftpboot
ln -s /var/lib/tftpboot /tftpboot

挂载光盘镜像并复制网启文件到tftp
mkdir /mnt/cd
mount -o loop -t auto ~/iso/ubuntu-12.04.4-server-amd64.iso /mnt/cd
cp -rv /mnt/cd/install/netboot/* /tftpboot

修改启动菜单
vim /tftpboot/pxelinux.cfg/default
将timeout后的0改成30表示3秒自动选择
vim /tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg
修改label cli上面的那行,改成下面这样


append initrd=ubuntu-installer/amd64/initrd.gz ks=ftp://192.168.44.250/pub/ks/ubuntuserver12/ks.cfg live-installer/net-image=ftp://192.168.44.250/pub/ks/ubuntuserver12/install/filesystem.squashfs 


在ftp目录中放上安装源
mkdir -p /var/ftp/pub/ks/ubuntuserver12
cp -rv /mnt/cd/* /var/ftp/pub/ks/ubuntuserver12

配置dhcp
vim /etc/dhcp/dhcpd.conf
ddns-update-style interim;
ignore client-updates;
next-server 192.168.44.250;
filename "pxelinux.0";
allow booting;
allow bootp;
subnet 192.168.44.0 netmask 255.255.255.0 {
# — default gateway
option routers 192.168.44.1;
option subnet-mask 255.255.255.0;
# option nis-domain “domain.org”;
option domain-name "chaoxing.com";
option domain-name-servers 202.106.195.68;
option time-offset -18000; # Eastern Standard Time
range 192.168.44.100 192.168.44.120;
}

编写ks.cfg文件
vim /var/ftp/pub/ks/ubuntuserver12/ks.cfg
# ubuntuser kickstart file
install
url --url ftp://192.168.44.250/pub/ks/ubuntuserver12

preseed passwd/root-login boolean true
lang en_US
langsupport --default en_US.UTF-8 en_US.UTF-8

keyboard us
mouse
timezone Asia/Shanghai

rootpw --disabled
user john --fullname "john chu" --password chaoxing54321
reboot
text

#不管是传统分区方式还是自动lvm分区方式,当遇到硬盘本身带有lvm分区的时候依然会需要人为干预,这个问题我至今还没有解决,官方好像没有打算修复这个“bug”。目前我是使用再次创建一个全新的lvm覆盖老lvm的方式强制跳过那交互的。如下
bootloader --location=mbr
zerombr yes
clearpart --drives=sda --initlabel --all
# 不设置swap时安装过程中会提示要不要重新添加swap分区

part swap --size 4096

part /boot --fstype ext4 --size=256

part pv.01 --size=1 --grow

volgroup vg pv.01

logvol / --vgname=vg --size=1 --grow --name=lv



#用以下ubuntu kickstart seed文件的内容,可让live-installer使用默认lvm的分区方式

#d-i partman-auto/disk string /dev/sda

#d-i partman-auto/method string lvm

#d-i partman-auto/purge_lvm_from_device boolean true

#d-i partman-lvm/device_remove_lvm boolean true

#d-i partman-md/device_remove_md boolean true

#d-i partman-md/confirm_nooverwrite boolean true

#d-i partman-lvm/confirm boolean true

#d-i partman-lvm/confirm_nooverwrite boolean true

#d-i partman-auto-lvm/guided_size string max

#d-i partman-auto/choose_recipe select atomic

#d-i partman/default_filesystem string ext4  

#d-i partman-md/confirm boolean true

#d-i partman-partitioning/confirm_write_new_label boolean true

#d-i partman/choose_partition select Finish partitioning and write changes to disk

#d-i partman/confirm boolean true

#d-i partman/confirm_nooverwrite boolean true


#我测试的时候,发现如下这行,不写就会提示无法安装!

d-i live-installer/net-image string ftp://192.168.44.250/pub/ks/ubuntuserver12/install/filesystem.squashfs


auth  --useshadow  --enablemd5
network --bootproto=dhcp --device=eth0
firewall --disabled
skipx

%packages
@ Base
openssh-server
openssh-client
vim
gcc
make


启动各项服务
/etc/init.d/dhcpd restart && /etc/init.d/xinetd restart && /etc/init.d/vsftpd restart

注意
如果使用kickstart方式必须用“ks=”指出ks文件位置,不能用“file=;如果要使用seed文件(就是内容是d-i开头那种),需要使用“preseed/url=”指出seed文件位置,且必须与ks格式文件配合使用不能没有“ks=”只有“preseed/url=”
以下seed文件可供参考也可以没有,是配合ks文件扩展使用的,如果需要追加seed文件,把txt.cfg中append后改成
append initrd=ubuntu-installer/amd64/initrd.gz ks=ftp://192.168.44.250/pub/ks/ubuntuserver12/ks.cfg live-installer/net-image=ftp://192.168.44.250/pub/ks/ubuntuserver12/install/filesystem.squashfs  preseed/url=ftp://192.168.44.250/pub/ks/ubuntuserver12/ks.seed
创建ks.seed文件
vim /var/ftp/pub/ks/ubuntuserver12/ks.seed
# ubuntu preseed file
d-i debian-installer/locale string en_US  
d-i debian-installer/language string en  
d-i debian-installer/country string china
d-i localechooser/supported-locales multiselect en_US.UTF-8, zh_CN.UTF-8  
#keyboard  
d-i console-setup/ask_detect boolean false  
d-i console-configuration/layoutcode string us  
d-i keyboard-configuration/modelcode string SKIP   
#clock  
d-i clock-setup/utc boolean false  
d-i time/zone string Asia/Shanghai  
#network  
d-i netcfg/choose_interface select auto  
d-i netcfg/dhcp_failed note  
d-i netcfg/dhcp_options select Do not configure the network at this time  
d-i netcfg/get_hostname string test  
d-i netcfg/get_domain string test-domain  
d-i netcfg/wireless_wep string  
# Mirror  
d-i mirror/protocol string ftp  
#d-i mirror/country string china  
d-i mirror/http/hostname string  192.168.44.250  
d-i mirror/http/directory string /pub/ks/ubuntuserver12  
d-i mirror/http/proxy string  
#d-i mirror/http/mirror select 192.168.44.250
# clock  
d-i clock-setup/ntp boolean true  
# partition  
d-i partman-auto/disk string /dev/sda  
d-i partman-auto/method string regular  
d-i partman-lvm/device_remove_lvm boolean true  
d-i partman-md/device_remove_md boolean true  
d-i partman-auto/choose_recipe select atomic  
d-i partman/default_filesystem string ext4  
d-i partman/confirm_write_new_label boolean true  
d-i partman/choose_partition  select Finish partitioning and write changes to disk  
d-i partman/confirm boolean true  
#user  
#d-i passwd/root-login boolean true  
#d-i passwd/root-password-crypted password $1$3nGno0$c4rp7NcQRAcJV3AdzKV890  
#d-i passwd/make-user boolean true  
d-i passwd/user-fullname string ubuntu  
d-i passwd/username string ubuntu  
#d-i passwd/user-password-crypted password $1$3nGno0$c4rp7NcQRAcJV3AdzKV890  
d-i passwd/user-password password chaoxing54321
d-i passwd/user-password-again password chaoxing54321
d-i user-setup/allow-password-weak boolean true  
d-i user-setup/encrypt-home boolean false  
#package  
tasksel tasksel/first multiselect none  
d-i pkgsel/include string openssh-server vim gcc make 
d-i pkgsel/upgrade select full-upgrade  
d-i pkgsel/install-language-support boolean true  
d-i pkgsel/language-packs multiselect en, zh  
d-i pkgsel/update-policy select none  
# popularity-contest popularity-contest/participate boolean false  
d-i pkgsel/updatedb boolean true  

#grub  
d-i grub-installer/skip boolean false  
d-i lilo-installer/skip boolean true  
d-i grub-installer/grub2_instead_of_grup_legacy boolean true  
d-i grub-installer/only_debian boolean true  
d-i grub-installer/with_other_os boolean true  

# Finish  
d-i finish-install/keep-consoles boolean true  
d-i finish-install/reboot_in_progress note  
d-i cdrom-detect/eject boolean true  
d-i debian-installer/exit/halt boolean false  
d-i debian-installer/exit/poweroff boolean false


注意很多人在kickstart安装ubuntu时候出现这个如图的错误,

wKioL1aMetbhRU-bAACcch-BYrg166.jpg


原因是在pxe启动的menu文件里append这行没有加上live-installer/net-image=ftp://192.168.44.250/pub/ks/ubuntuserver12/install/filesystem.squashfs,且

ks文件里没有写这样一行d-i live-installer/net-image string ftp://192.168.44.250/pub/ks/ubuntuserver12/install/filesystem.squashfs



本文转自 朱科强 51CTO博客,原文链接:http://blog.51cto.com/zhukeqiang/1375268,如需转载请自行联系原作者

相关文章
|
8月前
|
Ubuntu 安全 Linux
CentOS与Ubuntu的深度对比与分析
Ubuntu更新频繁、文档丰富,适用于云服务与容器部署。 与CentOS的比较,Ubuntu基于Debian,而CentOS则源自RHEL。在软件包格式上,Ubuntu采用.deb和.snap,而CentOS则使用.rpm和flatpak。更新方面,Ubuntu使用apt,而CentOS则依赖yum。尽管CentOS以稳定性见长,不常对包进行更新,但这并不意味着Ubuntu在安全性上逊色。事实上,Ubuntu提供了更为丰富的文档和免费的技术支持。此外,Ubuntu的服务器版本在云服务和容器部署方面拥有更多的优势。
|
8月前
|
Ubuntu Linux 索引
Centos 7、Debian及Ubuntu系统中安装和验证tree命令的指南。
通过上述步骤,我们可以在CentOS 7、Debian和Ubuntu系统中安装并验证 `tree`命令。在命令行界面中执行安装命令,然后通过版本检查确认安装成功。这保证了在多个平台上 `tree`命令的一致性和可用性,使得用户无论在哪种Linux发行版上都能使用此工具浏览目录结构。
734 78
|
8月前
|
Ubuntu 安全 Unix
CentOS 与 Ubuntu 谁与争锋
不论你的选择如何,是 Ubuntu 还是 CentOS,两者都是非常优秀稳定的发行版。如果你想要一个发布周期更短的版本,那么就选 Ubuntu;如果你想要一个不经常变更包的版本,那么就选 CentOS。在下方留下的评论,说出你更钟爱哪一个吧!
|
8月前
|
Ubuntu 安全 小程序
服务器版本的CentOS和Ubuntu哪个更适合你?
但是以上的比较并不说明Ubuntu是不稳定的或者是不安全的,只是以上比较过程中,在稳定性方面Ubuntu稍微逊色了一点。由于Ubuntu在个人桌面电脑的使用率远远高于CentOS,用Ubuntu搭建服务器,如果遇到什么问题,寻找解决方案相对比较容易,这让Ubuntu在选择方面更优于CentOS。如果你是一个初学者,那么毫无疑问Ubuntu是更适合的选择。如果你正在经营自己的公司,在这两者之间,CentOS会更好一些。
|
8月前
|
Ubuntu 安全 Linux
centos和ubuntu有什么区别
总的来说,CentOS 更适合用于服务器和企业级应用,因为它稳定、可靠、安全,并且提供长期支持。而 Ubuntu 则更适合用于桌面应用程序和开发环境,因为它更加注重用户体验和新技术支持。
|
8月前
|
Ubuntu Linux 图形学
centos和ubuntu有什么区别
总之,CentOS和Ubuntu都是常见的Linux操作系统发行版,它们都是免费的、开源的操作系统。它们在更新周期、软件包管理器、默认桌面环境、用户接口和社区支持等方面存在一些不同。因此,选择哪种操作系统取决于用户的需求和偏好,以及特定的使用场景。 如果有任何疑问可以随时评论留言或私信我,欢迎关注我[点击关注],共同探讨。
|
8月前
|
Ubuntu 安全 Linux
CentOS和Ubuntu区别
好的选择。 Ubuntu有一个很大的社区平台,可以提供丰富的文档和经验。 Ubuntu服务器的图形界面适合大多数人的习惯。 因此,如果是初学者且没有特别的要求,就使用Ubuntu服务器吧。 CentOS适用于公司的生产环境,Centos的更新频率不高,仅发布稳定的版本。 网上项目教程大多基于Centos。 Ubuntu面向初学者,CentOS面向公司服务器。
|
8月前
|
Ubuntu 安全 数据挖掘
揭开Linux系统神秘面纱,选择Centos、Debian、Ubuntu?
CentOS、Debian 和 Ubuntu 三种 Linux 操作系统各具优势和适用场景。CentOS 更适合用于服务器应用,Debian 更适合稳定需求的系统环境,而 Ubuntu 更适合用于桌面操作系统和开发环境等。CentOS 和 Debian 相对保守,重视稳定性和安全性;Ubuntu 侧重更新和更好的可用性,重视用户体验。此外, Ubuntu 在市场上的占有率最高。因此,选择适合自己需求的操作系统非常重要,可以帮助用户提高效率和使用体验。
|
8月前
|
存储 Ubuntu 安全
Linux中Centos和Ubuntu的区别
CentOS主要面向服务器环境,而Ubuntu适用于服务器和桌面环境。   CentOS提供更精简的安装,而Ubuntu提供更广泛的开箱即用功能。   CentOS遵循RHEL的所有安全实践,而Ubuntu在安全方面采取更积极的方法。
|
8月前
|
Ubuntu Linux 云计算
CentOS与Ubuntu:Linux系统的双璧
选择Ubuntu还是CentOS,取决于用户的具体需求,如是否需要图形化界面、对稳定性的要求、软件包管理的偏好以及对商业支持的需求等。两者都是优秀的Linux发行版,只是在设计理念和目标用户群体上有所不同。#深度好文计划#