pxe-ubuntu(kickseed)

大概的流程:网卡启动->dhcp获取ip,以及tftp服务器的地址->启动安装程序(txt.cfg.其中append中包含ks文件地址)->启动安装内核->根据ks文件(安装路径),执行安装

 

遇到的一些问题

如果是内网安装,不能访问外网的情况会出现请求默认路由
用中文安装时有出现报错,改用英语
不设置swap会需要二次确认
 
实验环境
vmware
都网卡设置为NAT模式
取消自带的dhcp服务
 
# cat /etc/redhat-release
CentOS Linux release 7.4 (Core)
 
关闭selinux,关闭firewall
 
安装
# yum install xinetd dhcp tftp-server httpd syslinux -y
 
创建安装源
# mkdir -p /data/{iso,ks,os,tftpboot}
# mkdir -p /data/os/ubuntu16
# cd /data/iso
# wget http://mirrors.aliyun.com/ubuntu-releases/16.04/ubuntu-16.04.5-server-amd64.iso
# mount -o loop ubuntu-16.04.5-server-amd64.iso /media
# cp -r /media/* /data/os/ubuntu16
# cp -a /data/os/ubuntu16/install/netboot/* /data/tftpboot/
 
配置http
# vim /etc/httpd/conf/httpd.conf
DocumentRoot "/data"
<Directory "/data">
   Options Indexes FollowSymLinks
   AllowOverride None
   Require all granted
</Directory>
# systemctl start httpd
# systemctl enable httpd
 
配置dhcp
# vim /etc/dhcp/dhcpd.conf
allow booting;
allow bootp;
 
subnet 10.10.1.0 netmask 255.255.255.0 {   #设定网段广播地址
       range 10.10.1.10 10.10.1.100;            #dhcp池
       option routers 10.10.1.1;                        #路由
       option domain-name-servers 114.114.114.114,8.8.8.8;
       default-lease-time 36000;
        max-lease-time 86400;                #默认的租约时间,单位是秒
       filename "pxelinux.0";
        next-server 10.10.1.50;                    #tftp服务器
}
 
# systemctl start dhcpd
# systemctl enable dhcpd
 
配置tftp
# vi /etc/xinetd.d/tftp
disable                    = no                                                        #打开服务
server_args             = -s /data/tftpboot                                #修改目录路径
 
# vim /usr/lib/systemd/system/tftp.service
ExecStart=/usr/sbin/in.tftpd -s /data/tftpboot                      #修改目录路径
 
重新加载服务
# systemctl daemon-reload
# systemctl enable tftp
# systemctl start xinetd
 
# vi /data/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg
default install
label install
       menu label ^Install
       menu default
       kernel ubuntu-installer/amd64/linux
       append ks=http:/10.10.1.50/ks/ks.cfg vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- quiet  preseed/url=http://10.10.1.50/os/ubuntu16/preseed/ubuntu-server.seed
 
# vi /data/os/ubuntu16/preseed/ubuntu-server.seed
添加以下配置
d-i pkgsel/include string openssh-server
d-i netcfg/get_gateway string none                                    #跳过默认路由二次确认
d-i partman-basicfilesystems/no_swap boolean false        #跳过不分配swap时的二次确认         
 
ks没有的参数,可以加到ps上
 
# vim ks.cfg
#
#Generic Kickstart template for Ubuntu
#Platform: x86 and x86-64
#
 
#System language
lang en_US
 
#Language modules to install
langsupport zh_CN    --default=en_US
 
#System keyboard
keyboard us
 
#System mouse
mouse
 
#System timezone
timezone Asia/Shanghai
 
#Root password
rootpw --disabled
 
#Initial user (user with sudo capabilities)
user ubuntu --fullname "Ubuntu User" --password 12345678
 
#Reboot after installation
reboot
 
#Use text mode install
text
 
#Install OS instead of upgrade
install
 
#Installation media
#cdrom
#nfs --server=server.com --dir=/path/to/ubuntu/
 
#System bootloader configuration
bootloader --location=mbr
 
#Clear the Master Boot Record
zerombr yes
 
#Partition clearing information
clearpart --all --initlabel
 
#Basic disk partition
part / --fstype ext4 --size 1 --grow --asprimary
part swap --size 1024
#part /boot --fstype ext4 --size 256 --asprimary
 
#Advanced partition
#part /boot --fstype=ext4 --size=500 --asprimary
#part pv.aQcByA-UM0N-siuB-Y96L-rmd3-n6vz-NMo8Vr --grow --size=1
#volgroup vg_mygroup --pesize=4096 pv.aQcByA-UM0N-siuB-Y96L-rmd3-n6vz-NMo8Vr
#logvol / --fstype=ext4 --name=lv_root --vgname=vg_mygroup --grow --size=10240 --maxsize=20480
#logvol swap --name=lv_swap --vgname=vg_mygroup --grow --size=1024 --maxsize=8192
 
#System authorization infomation
auth  --useshadow  --enablemd5
 
#Network information
network --bootproto=dhcp --device=eth0
 
#Firewall configuration
firewall --disabled --trust=eth0 --ssh
 
#Do not configure the X Window System
skipx
 

https://blogs.gnome.org/muelli/2016/08/remastering-a-custom-ubuntu-auto-install-iso/

posted on 2018-11-23 10:18  森度  阅读(346)  评论(0编辑  收藏  举报

导航