Ubuntu18.04 PXE unmanned automatic installation-2021.3.19

Deploying the ubuntu unattended installation system
guide Unattended installation (Unattended Setup) refers to the software installation without any user intervention, directly according to the default or through the answer file to set the installation, which is for users without special needs or enterprises to deploy and install the operating system in large quantities It is very convenient when it comes to software.
QQ:1450930976 Welcome to leave a message, exchange technology, and share a happy thing

General principle:

  1. DHCP Client sends the PXE Server IP address request message, whether the DHCP Client detecting
    method (detected mainly MAC address of Client), if valid Client returns the IP
    address, the location information of the file will be started in a pxelinux.0 And send it to the Client.

  2. The client sends a pxelinux.0 request message to TFTP on the PXE Server.
    After receiving the message, TFTP sends the pxelinux.0 size information to the client to test whether the client is satisfied. When
    TFTP receives the agreed size information sent back by the client, it officially sends Client sends pxelinux.0.

  3. Client executes the received pxelinux.0 file.

  4. Client transmits configuration information (recorded on a TFTP pxelinux.cfg for this machine to the TFTP
    lower), the configuration file TFTP (pxelinux.cfg / default this file is important) back to Client, then Client performs subsequent operations according to the configuration file
    for .

  5. Client sends Linux kernel request information to TFTP, and TFTP sends the kernel file
    to Client after receiving the message .

  6. Client sends root file request information to TFTP, and TFTP returns the Linux root file after receiving the message

    system.

  7. Client starts the Linux kernel (the startup parameters have been set in the configuration file in 4).

  8. Client downloads the image file through NFS (apache, Nginx, both), and reads the autoyast automated installation script (ks.cfg).
    At this point, the Client officially enters the automated installation mode and begins to install the system until completion.

Here is an explanation of the difference between the two (preseed.seed; system-config-kickstart=ks.cfg) automatic response scripts.
1. Make liveusb to realize the start-up and plug-in effect, fully automatic installation of centos6 and ubuntu12, and the installation of ubuntu12 should try to ensure that there is only one partition in fat32 format on the u disk, otherwise you will need to manually press enter to confirm to continue the installation, you need to use the seed file
2, deployment pxe kickstart be fully automated network installation centos6 and ubuntu12, which ubuntu12 not use seed, seed anyway I did not work out how to write
3, automatic deployment cobbler were pxe network installation centos6 and ubuntu12, which ubuntu12 not use seed
summary : U disk to install the ubuntu system requires a seed file, the content of which is the type with di at the beginning of each line; the pxe network to install the ubuntu system requires a ks file, which is the same kickstart configuration file as centos6. Centos6 only has ks files, so it's very simple.

From https://blog.51cto.com/zhukeqiang/1384017

Environment
Ubuntu-desktop (ip: 192.168.56.11)
server system: Ubuntu18.04 -amd64-disktop.iso
is installed system: Ubuntu 18.04-amd64-server.iso
download link: cdimage.ubuntu.com/releases/18.04/release / Download the official mirror, if you want to install it, go here to download it. Ubantu 18.04 amd64-server.iso

Install the software
apt install dnsmasq apache2 system-config-kickstart
or use (isc-dhcp, tftpd-pha, nfs, apche2), dnsmasq=(tfpt+DHCP+DNS) This tool is more convenient. It depends on you, the principle is the same

Modify the IP address of the machine to be static for easy configuration. At the same time, you can temporarily turn off the DHCP server in the network. It is best if it is installed in an offline switch.
$ sudo vim /etc/netplan/01-network-manager-all.yaml (Ubuntu18 modify the IP here, pay attention to the following file format, if it is wrong, it will not start)
network:
version: 2
renderer
:
networkd ethernets: ens33:
dhcp4 : no
dhcp6: no
addresses: [192.168.6.254/24]
gateway4: 192.168.6.1
nameservers:
addresses: [114.114.114.114, 8.8.8.8]

Sudo netplan apply # Apply the IP configuration file directly,
Systemctl restart networking #If this command fails, you need to turn off the check function of the systemctl stop NetworkManager service.

配置dnsmasq
vim /etc/dnsmasq.conf
bogus-priv
filterwin2k
interface=eth0
dhcp-range=192.168.5.150,192.168.5.250,12h
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/ftpd
dhcp-authoritative

Create the necessary directories
mkdir /var/ftpd
mkdir /var/www/ubuntu

Mount the installation media
mount /dev/cdroom /mnt # sudo mount /dev/sr0 /mnt
The mirror here supports Ubuntu 16.04-i386 / Ubuntu18.04-amd64-server, it cannot be the live version and disktop version, there is no need in the mirror The file
$ ls /met/ install/ (ubuntu-installer, pxelinux.0) There is no way to install correctly without these files.

cp /mnt/* /var/www/ubuntu -arf
Copy the network boot file to the network boot directory
cp /var/www/ubuntu/install/netboot/* /var/ftpd -arf/

Modify the apache2 configuration file

vim /etc/apache2/sites-enabled/000-default.conf
DocumentRoot /var/www #Here
only the key configuration is given. The role of apache2 installation is to provide a web home directory.

Edit the response file ks.cfg and
run system-config-kickstart to generate the ks.cfg file, where you can directly copy the following content; there is no way to graphically operate this automatic response file generation tool without installing the desktop.
vim /var/www/ks.cfg
#Generated by Kickstart Configurator
#platform=AMD64 or Intel EM64T
install
text
#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone - utc Asia/Shanghai
#Root password #If you disable root users, you don’t need to set a password
rootpw --disabled
#Initial user #Configure normal system users. The first one below is an encrypted user. You may not be able to log in after the installation is complete. Test it yourself.
user wsfnk --fullname “wsfnk” --iscrypted --password 1 11 Q4SPUaqc$KCsPmeMevJS0zzrqLTeVw0 #The
following is a user who does not use password encryption but the password length must exceed 8 digits, otherwise the automatic installation will prompt whether to use a weak password.
User connor --fullname “connor” --paswwrod abc123abc
#Reboot after installation
reboot#Use
text mode install
#text
#Install OS instead of upgrade
#install #Use
Web installation
url --url http://192.168.56.11/ubuntu
# System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information #Set the file system and partition, you can go to the graphical interface to operate and see how to allocate .
part swap --size 512
part /boot --fstype ext4 --size 200
part / --fstype ext4 --size 1 --grow
#System authorization infomation
auth --useshadow --enablemd5
#Firewall configuration
firewall --disabled
#Do not configure the X Window System
skipx
%packages
openssh-server
openssh-client
gcc
g++
vim
Curl

**Edit boot file, **
Ubuntu series system can use the following boot file directly, please delete the Chinese remarks.
vim /var/ftpd/pxelinux.cfg/default
path ubuntu-installer/amd64/boot-screens/
include ubuntu-installer/amd64/boot-screens/menu.cfg
default ubuntu-installer/amd64/boot-screens/vesamenu.c32
#If the following two lines are not written, it will not be installed automatically, and the automatic answering installation will be executed after manual confirmation.
default install
label install
#kernel system kernel location, (var/ftpd2/ubuntu-installer/amd64/linux)
kernel ubuntu-installer/amd64/linux #The
following specifies the location of the automatic answer installation file, you can use a browser to access and test curl http: //192.168.6.254/ks.cfg
append ks=http://192.168.6.254/ks.cfg initrd=ubuntu-installer/amd64/initrd.gz –
prompt 0
timeout 0

Start related services
systemctl start apache2
systemctl start dnsmasq
If you start dnsmsaq and port 53 is occupied, you can solve it by Baidu, or you can close systemctl status systemd-resolved.service.
If the following error occurs in the installation,
Insert picture description here
Insert picture description here
please go to ubuntu-installer/amd64/boot -screens/txt.cfg, append the following configuration
live-installer/net-image=http://192.168.56.11/ubuntu/install/filesystem.squashfs clock-setup/ntp=false ip=dhcp ksdevice=bootif

To solve the error shown in the picture, it is safer to add this content directly before installation.
vim /var/ftpd/ubuntu-installer/amd64/boot-screens/txt.cfg
default install
label install
menu label ^Install
kernel ubuntu-installer/amd64/linux
append ks=http://192.168.6.254/ks.cfg vga =788 initrd=ubuntu-installer/amd64/initrd.gz live-installer/net-image=http://192.168.6.254/ubuntu/install/filesystem.squashfs clock-setup/ntp=false ip=dhcp ksdevice=bootif — quit

Reference link:
from <blog.csdn.net/Linuxprobe18/article/details/102454236> CSDN can be operated,
blog.csdn.net/a1231231231313/article/details/109241431
cdimage.ubuntu.com/releases/18.04/release/ official Mirror download, if you want to install it, go here to download. Ubantu 18.04 amd64-server.iso
https://blog.xizhibei.me/2019/10/21/how-to-install-more-than-10-os-in-an-hour-with-pxe/ abroad Forum, a more detailed explanation

Guess you like

Origin blog.csdn.net/Connor_xie/article/details/115016919