kickstart无人值守安装Ubuntu1804系统

1.安装配置DHCP服务

apt install isc-dhcp-server -y
vim /etc/dhcp/dhcpd.conf
#配置文件最后插入
subnet 10.0.0.0 netmask 255.255.255.0 {
range 10.0.0.70 10.0.0.90;
option routers 10.0.0.2;
option domain-name-servers 10.0.0.2;
default-lease-time 600;
max-lease-time 7200;
next-server 10.0.0.200;
filename "pxelinux.0";
}
systemctl start isc-dhcp-server
systemctl enable isc-dhcp-server
netstat -lntup |grep 67

2.安装配置FTP服务

apt install tftpd-hpa -y

#我这里配置文件保持默认
root@cxy:~# vim /etc/default/tftpd-hpa 
# /etc/default/tftpd-hpa
  
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"

systemctl start tftpd-hpa.service
systemctl enable tftpd-hpa.service
netstat -lntup |grep 69

3.安装配置HTTP服务以及挂载ISO至HTTP站点目录

apt install apache2 -y
systemctl start apache2
systemctl enable apache2
#上传ISO至根目录
mkdir -p /var/www/html/ubuntu
mount /root/ubuntu-18.04.5-live-server-amd64.iso /var/www/html/ubuntu

4.下载对应系统的netboot.tar包并且解压放至网络引导启动的根路径下

Ubuntu系统Netboot Images下载

#解压之后查看
root@cxy:/var/www/html# cd /var/lib/tftpboot/
root@cxy:/var/lib/tftpboot# ls
ldlinux.c32  pxelinux.0  pxelinux.cfg  ubuntu-installer  version.info

5.配置Kickstart应答文件

cxy@cxy:~$ cat /var/www/html/ks_ubuntu1804.cfg 
#Generated by Kickstart Configurator
#platform=x86

# Fetch content from here
#url –url http://mirrors.ustc.edu.cn/ubuntu/
url –url http://10.0.0.200/ubuntu/

#System language
lang en_US.UTF-8

#Language modules to install
langsupport en_US.UTF-8

#System keyboard
keyboard us

#System mouse
mouse

#System timezone
timezone --utc Asia/Shanghai

#Root password
rootpw --disabled

#Initial user (user with sudo capabilities) 
user www --fullname "Ubuntu User" --password Admin_123.

#Reboot after installation
reboot

#Use text mode install
text

#Install OS instead of upgrade
install

#Installation media
#cdrom

#System bootloader configuration
bootloader --location=mbr 

#Clear the Master Boot Record
zerombr yes

#Partition clearing information
clearpart --all --initlabel

#Basic disk partition

# 1. standard partition 
#part / --fstype ext4 --size 1 --grow --asprimary 
#part swap --size 2048 
#part /boot --fstype ext4 --size 256 --asprimary

# 2. lvm partition


preseed partman-auto-lvm/guided_size string 90%
part /boot --fstype=ext4 --size=512 --asprimary
part pv.1 --grow --size=1 --asprimary
volgroup vg0 pv.1
logvol / --fstype=ext4 --name=root --vgname=vg0 --size=30GB --grow
logvol swap --name=swap --vgname=vg0 --size=2GB



#System authorization infomation
auth  --useshadow  --enablemd5 

#Network information
network --bootproto=dhcp --device=auto

#Firewall configuration
firewall --disabled

#Do not configure the X Window System
skipx

#Package install information
%packages
#ubuntu-minimal
openssh-server
#vim
#screen
#curl
#wget
#acpid
#unattended-upgrades
#linux-image-generic
#python-apt
#lshw
#lldpd
#dmidecode

%post

# add normal apt source list aliyun
(
cat <<'EOF'
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse

EOF
) > /etc/apt/sources.list

#apt-get update
#apt-get upgrade -y

# setup locales
locale-gen en_US.UTF-8
update-locale LANG="en_US.UTF-8"
echo 'LANG=en_US.UTF-8' >> /etc/environment
echo 'LC_ALL=en_US.UTF-8' >> /etc/environment

(
cat <<'EOF'
#!/bin/bash
who -b >> /root/boot1.txt
last >> /root/boot2.txt
EOF 
) > /etc/rc.local
chmod +x /etc/rc.local

reboot

6.配置引导启动菜单

root@cxy:~# cat /var/lib/tftpboot/pxelinux.cfg/default 
# D-I config version 2.0
# search path for the c32 support libraries (libcom32, libutil etc.)
path ubuntu-installer/amd64/boot-screens/
include ubuntu-installer/amd64/boot-screens/menu.cfg
default ubuntu-installer/amd64/boot-screens/vesamenu.c32

root@cxy:~# cat /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg 
default install
label install
	menu label ^Install Ubuntu Server 1804 by cxy
	menu default
	kernel ubuntu-installer/amd64/linux
	append ks=http://192.168.6.100/ks_ubuntu1804.cfg vga=788 initrd=ubuntu-installer/amd64/initrd.gz live-installer/net-image=http://192.168.6.100/ubuntu/casper/filesystem.squashfs clock-setup/ntp=false ip=dhcp ksdevice=bootif --- quiet 

label cli
	menu label ^Command-line install
	kernel ubuntu-installer/amd64/linux
	append tasks=standard pkgsel/language-pack-patterns= pkgsel/install-language-support=false vga=788 initrd=ubuntu-installer/amd64/initrd.gz --- quiet 

timeout 30

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值