1.关闭防火墙
2.PXE环境准备
2.1服务器静态IP设置
sudo vi /etc/network/interfaces
启动eth1网络
sudo ifup eth1
2.2安装服务
2.2.1 安装dnsmasq作为dncp服务
sudo apt-get install dnsmasq
配置dhcp文件
sudo vi /etc/dnsmasq.conf
bogus-priv
filterwin2k
interface=eth1
dhcp-range=10.0.4.100,10.0.4.200,12h
dhcp-host=08:00:27:0f:9b:1E,10.0.4.10
dhcp-boot=pxelinux.0
enable-tftp
tftp-root=/var/ftpd
dhcp-authoritative
创建tftp目录
sudo mkdir –p /var/ftpd
启动dnsmasq服务
sudo service dnsmasq start
2.2.3 安装apache2服务,提供需要安装的操作系统文件
sudo apt-get install apache2
浏览器验证httpd服务正常
apache2配置可以访问安装文件目录
sudo vi sites-enabled/000-default.conf
sudo vi /etc/apache2/apache2.conf
sudo mkdir -p /var/www/ubuntu
重启apache2目录
sudo service apache2 restart
浏览器验证httpd服务正常
2.3.复制ubuntu14.04操作系统全目录,内核与启动镜像文件
挂载ubuntu –server.iso镜像 sudo mount /dev/cdrom /mnt
复制pxe启动文件和操作系统文件
sudo cp -vr /mnt/install/netboot/* /var/ftpd
cp –varf /mnt/* /var/www/ubuntu
创建ks.cfg脚本
sudo touch /var/www/ubuntu/ks.cfg
#Generated by Kickstart Configurator
#platform=x86
#System language
lang en_US
#Language modules to install
langsupport en_US
#System keyboard
keyboard us
#System mouse
mouse
#System timezone
timezone Asia/Shanghai
#Root password
rootpw --iscrypted $1$NmOzxhNQ$Y5NsgGIYUumYf7UBFthqs/
#Initial user
user --disabled
#Reboot after installation
reboot
#Use text mode install
text
#Install OS instead of upgrade
install
#Use Web installation
url --url http://10.0.4.10/ubuntu
#System bootloader configuration
bootloader --location=mbr
#Clear the Master Boot Record
zerombr yes
#Partition clearing information
clearpart --all --initlabel
#Disk partitioning information
part /boot --fstype ext4 --size 500
part swap --size 4096
part / --fstype ext4 --size 1 --grow --maxsize 1
#System authorization infomation
auth --useshadow --enablemd5
#Network information
network --bootproto=dhcp --device=eth0
#Firewall configuration
firewall --disabled --ssh
#Do not configure the X Window System
skipx
%packages
@openssh-server
sudo touch /var/www/ubuntu/ubuntu-server.seed
### Localization.
d-i auto-install/enable boolean true
d-i debian-installer/locale string en_US
#d-i localechooser/translation/warn-light boolean true
#d-i localechooser/translation/warn-severe boolean true
d-i console-setup/ask_detect boolean false
d-i keyboard-configuration/layoutcode string us
d-i keyboard-configuration/modelcode string SKIP
### Net interface setting.
d-i netcfg/choose_interface select eth0
d-i netcfg/dhcp_failed note
d-i netcfg/get_hostname string ubuntu
d-i netcfg/get_domain string ubuntu
### Mirror setting. use the local proxy.
d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/hostname string 10.0.4.10
d-i mirror/http/directory string /ubuntu/
d-i mirror/http/proxy string http://10.0.4.10
### Clock and timezone setting. use local ntp.
d-i clock-setup/utc boolean true
d-i time/zone string Asia/Chongqing
d-i clock-setup/ntp boolean true
### Partioning setting.
#d-i partman-auto/disk string /dev/sda
#d-i partman-auto-lvm/guided_size string max
#d-i partman-auto/choose_recipe select atomic
d-i partman-auto/method string regular
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm boolean true
#d-i partman-lvm/confirm_nooverwrite boolean true
d-i partman-lvm/device_remove_lvm boolean true
d-i partman-lvm/device_remove_md boolean true
d-i partman/choose_recipe select atomic
d-i partman/default_filesystem string ext4
d-i partman/confirm_write_new_label boolean true
d-i partman/choose_partition select finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
#d-i partman/confirm_write_new_label boolean true
### Account setting.
d-i passwd/root-login boolean false
d-i passwd/user-fullname string test
d-i passwd/username string test
d-i passwd/user-password password test
d-i passwd/user-password-again password test
d-i user-setup/allow-password-weak boolean true
d-i user-setup/encrypt-home boolean false
d-i live-installer/net-image string http://10.0.4.10/install/filesystem.squashfs
### Package selection.
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none
d-i pkgsel/update-policy select none
tasksel tasksel/first multiselect standard, ubuntu-server
### Boot loader installation.
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
### finishing up the installation.
d-i finish-install/reboot_in_progress note
### Running custom commands.
#d-i preseed/late_command string echo "hello" >> /root/test
2.4启动选择安装配置文件
sudo vi /var/ftpd/pxelinux.cfg/default
# D-I config version 2.0
#include ubuntu-installer/amd64/boot-screens/menu.cfg
#default ubuntu-installer/amd64/boot-screens/vesamenu.c32
#prompt 0
#timeout 0
default linux
label linux
kernel ubuntu-installer/amd64/linux
append ks=http://10.0.4.10/ubuntu/ks.cfg preseed/url=http://10.0.4.10//ubuntu/ubuntu-server.seed vga=normal initrd=ubuntu-installer/amd64/initrd.gz –-
2.5 新建虚拟机测试pxe结果
本文出自 “柠檬的技术博客” 博客,请务必保留此出处http://lemonnews.blog.51cto.com/11010917/1962529
原文地址:http://lemonnews.blog.51cto.com/11010917/1962529