PXE无人值守安装ubuntu1804系统(kickstart无人值守安装Ubuntu1804系统)

 

 

 

从以下截图可以看出,自动化安装ubuntu系统已经成功,进入安装软件包界面

一开始错误原因: domain-name-servers配置错了,网络没通,后来改为114.114.114.114进行域名解析就对了,然后重启dhcpd服务

 正在安装系统软件:

 

 参考文档:

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

 

 

 

 

 

 

 

posted @ 2022-10-18 15:06  往事已成昨天  阅读(1564)  评论(0编辑  收藏  举报