UBUNTU16 Kickstart PXE installation system

Source: Internet
Author: User

Environment
PXE Network segment: 172.25.151.0/24
PXE Gateway: 172.25.151.1
PXE server address: 172.25.151.254
PXE Server system: Ubuntu 16.04
DHCP address pool: 172.25.151.240~172.25.151.253
PXE Install image Ios:ubuntu-16.04.4-server-amd64
Mount Directory:/mnt

首先:设置网卡1 以pxe方式启动最后:安装完成后恢复默认启动方式。

Configuration:
1. Install the DHCP server

apt-get install isc-dhcp-server

Modify the NIC

[email protected]:~# cat /etc/default/isc-dhcp-server  | grep -v "^#" | grep -v "^$"INTERFACES="enp2s0"

Configure the DHCP address pool

[email protected]:~# cat /etc/dhcp/dhcpd.conf  | grep -v "^#" | grep -v "^$"                       ddns-update-style none;log-facility local7;subnet 192.168.151.0 netmask 255.255.255.0 {  range 192.168.151.240 192.168.151.253;  option domain-name-servers 192.168.111.2;  option subnet-mask 255.255.255.0;  option routers 192.168.151.1;  option broadcast-address 192.168.151.255;  default-lease-time 600;  max-lease-time 7200;}allow booting;allow bootp;option option-128 code 128 = string;option option-129 code 129 = text;next-server 192.168.151.254;filename "pxelinux.0";

Restart the DHCP service

systemctl restart isc-dhcp-server
    1. Installing the TFTP service
apt-get install tftpd-hpa

Modify Configuration

[email protected]:~# cat /etc/default/tftpd-hpa  | grep -v "^#" | grep -v "^$"                    TFTP_USERNAME="tftp"TFTP_DIRECTORY="/var/lib/tftpboot"TFTP_ADDRESS="0.0.0.0:69"TFTP_OPTIONS="--secure"RUN_DAEMON="yes"OPTIONS="-l -s /var/lib/tftpboot"

3. Installing Apache2

apt-get install apache2

4. Copy and modify the required documents

mkdir /var/www/html/ubunturm -fr /var/www/html/index.htmlmount /dev/cdrom /mntcp -r /mnt/* /var/www/html/ubuntu/cp -r /var/www/html/ubuntu/install/netboot/* /var/lib/tftpboot/

5. Generate the Ks.cfg file (see the file contents at the end)
6. Modify some configurations
In the command-line root home directory
CP ks.cfg/var/www/html/
Vim/var/www/html/ks.cfg #添加安装的软件包
Skipx #下面添加需要安装的软件包
%packages
Openssh-server
Edit Txt.cfg

[email protected]:~# cat /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg | grep -v "^#" | grep -v "^$"                       default installlabel install        menu label ^Install        menu default        kernel ubuntu-installer/amd64/linux        append net.ifnames=0 AND biosdevname=0 ks=http://192.168.151.254/ks.cfg vga=788 initrd=ubuntu-installer/amd64/initrd.gz live-installer/net-image=http://192.168.151.254/ubuntu/install/filesystem.squashfslabel 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

Edit file Default

[email protected]:~# cat /var/lib/tftpboot/pxelinux.cfg/default | grep -v "^#" | grep -v "^$"                                                             path ubuntu-installer/amd64/boot-screens/include ubuntu-installer/amd64/boot-screens/menu.cfgdefault ubuntu-installer/amd64/boot-screens/vesamenu.c32prompt 0timeout 100

Then we can install the system.
Ks.cfg File Contents:

#Generated by Kickstart Configurator#platform=x86#system Languagelang en_us#language modules to Installlangsupport zh_ CN--default=en_us#system keyboardkeyboard us#system mousemouse#system timezonetimezone--UTC Asia/Shanghai#Root PASSWORDROOTPW--iscrypted $1$ay.kmnwt$euoqbv95hykjitybakfqw/#Initial useruser web--fullname "Web"--iscrypted-- Password $1$sqnvuinl$uytm7d0myy1qne8utestl. #Reboot after installationreboot#use text mode Installtext#install OS Instead of Upgradeinstall#use Web installationurl--url http://192.168.151.254/ubuntu#System bootloader Configurationbootloader--location=mbr #Clear The Master Boot recordzerombr yes#partition clearing Informationclearpart --all--initlabel#disk Partitioning informationpart/boot--fstype ext4--size/--asprimarypart/--fstype ext4--size 10240--asprimarypart swap--size 4096--asprimary#system authorization Infomationauth--useshadow--enablemd5#network Informationnetwork--bootproto=dhcp--device=eth0#firewall ConfigurationfirewAll--disabled#do not configure the X Window systemskipx%packagesopenssh-servervimntp%postip=$ (/sbin/ifconfig |grep 192.168|grep-op "(? <=inet addr:). * (? = bcast)") name=$ (Echo $IP |awk-f "." ' {print $3$4} ') sed-i "/$IP/d"/etc/hostsecho $IP sh$name >>/etc/hostshostname sh$nameecho sh$name >/etc/hostna menet=$ (/sbin/ifconfig |grep-o "inet addr:192.168[^]*" |awk-f. ' {print $} ')

7. Start a server in network mode for installation

过程略。。。

UBUNTU16 Kickstart PXE installation system

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.