设为首页 收藏本站
查看: 1067|回复: 0

[经验分享] centos用kickstart自动部署ubuntu12

[复制链接]

尚未签到

发表于 2018-5-3 12:39:17 | 显示全部楼层 |阅读模式
  最近研究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时候出现这个如图的错误,
DSC0000.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

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-455358-1-1.html 上篇帖子: ubuntu 软件管理命令 下篇帖子: ubuntu自动更新配置
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表