天天看點

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

準備工作

1.安裝KICKSTART

[email protected]:~$ sudo apt-get install system-config-kickstart -y

1.1在 “應用程式\系統工具”中打開kickstart

基本的配置:

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

安裝模式:這裡選擇http

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

引導啟動選項:預設即可

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

分區情況:您可以根據實際情況進行分區

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

網絡配置:增加一網卡設定為dhcp擷取ip

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

認證模式可以按預設即可

使用者設定:

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

防火牆和顯示器的配置都可以根據需要設定,或按預設即可

軟體包的選擇:這裡應該是ubuntu中kickstart的bug吧,沒有顯示可選的軟體包,一會生成ks.cfg檔案我們根據需要添加

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

安裝前後預處理腳本,可以根據需要定制,這裡簡單舉個例子:系統安裝完之後把主機名改為 pxeclient

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

儲存ks.cfg檔案:

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

修改ks.cfg檔案

在skipx後加入

%packages  #這是server version的沒有桌面

#@ubuntu-desktop  #這是ubuntu桌面版的,如果要安裝的話把#去掉

注意:alternate 既有桌面版也支援server版,是以叫做二選一

最後把ks.cfg檔案移到/var/www/html目錄下

#mv ks.cfg /var/www/html/

#我的配置檔案内容

#Generated by Kickstart Configurator

#platform=AMD64 or Intel EM64T

#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$gieKLFiM$jv5agaxq4QpX3lxpHR3UE1

#Initial user

user linux --fullname "linux" --iscrypted --password $1$y6kFWox0$S1OjQi4EbddMLnTbKoNiP0

#Reboot after installation

reboot

#Use text mode install

text

#Install OS instead of upgrade

install

#Use Web installation

url --url http://192.168.1.156/ubuntu12

#System bootloader configuration

bootloader --location=mbr 

#Clear the Master Boot Record

zerombr yes

#Partition clearing information

clearpart --all --initlabel 

#Disk partitioning information

#Disk partitioning information

part /boot --fstype ext4 --size 256

part swap --size 1024

part / --fstype ext4 --size 1 --grow

#part / --fstype ext4 --size 1 --grow 

#System authorization infomation

auth  --useshadow  --enablemd5

#Network information

#network --bootproto=dhcp --device=eth0 

network --bootproto=dhcp --device=eth0 \

                        --gateway=192.168.1.1 --nameserver=8.8.8.8

#Firewall configuration

firewall --disabled 

#X Window System configuration information

xconfig --depth=8 --resolution=800x600 --defaultdesktop=GNOME --startxonboot

@ubuntu-desktop

設定好以後,儲存配置檔案為ks.cfg

2 安裝DHCP sudo apt-get install dhcp3-server 

2.1配置DHCP,配置檔案如下 vi  /etc/dhcp/dhcpd.conf

subnet 192.168.1.156 netmask 255.255.255.0 { range 192.168.1.30 192.168.1.254; option routers 192.168.1.1; option domain-name-servers 8.8.8.8; default-lease-time 600; max-lease-time 7200; next-server 192.168.1.156; filename "pxelinux.0"; }

3.安裝TFTP伺服器

注意:必須使用TFTP-HPA這個軟體包,使用TFTPD會出現問題導緻不能導引導系統

[email protected]:/$ sudo apt-get install tftpd-hpa tftp-hpa

配置tftp

# vim /etc/default/tftpd-hpa

增加以下兩行:

RUN_DAEMON="yes" 

OPTIONS="-l -s /var/lib/tftpboot"

netboot 下載下傳網址:http://cdimage.ubuntu.com/netboot/14.04/

下載下傳那個netboot.tar.gz 即可

cd /var/lib/tftpboot

wget -r    http://archive.ubuntu.com/ubuntu/dists/trusty-updates/main/installer-amd64/current/images/netboot/ netboot.tar.gz 

或者  從server版本中拷貝 install下的netboot檔案到tftpboot下

vim /var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg

default install 

label install 

        menu label ^Install 

        menu default 

        kernel ubuntu-installer/amd64/linux 

        append ks=  http://192.168.1.156/ks.cfg\ 

        vga=788 initrd=ubuntu-installer/amd64/initrd.gz -- 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 

DHCP 拿不到IP dhcp未啟動 或者實體網絡設定的不對 service isc-dhcp-server start 

tftp 逾時 tftp服務未啟動

sudo   service tftpd-hpa restart 

安裝過程中卡住 http服務不好使了 無法通路www下的檔案了

apache2 重新開機

/etc/init.d/apache2 restart 

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0

 vim /etc/apache2/apache2.conf

最後加入一句 ServerName localhost:80      

apache2 預設服務目錄 /var/www/html 目錄 ks.cfg 和ubuntu鏡像 要放在這個目錄 /var/www/html 裡 将鏡像複制到 /var/www/html 這裡用的是ubuntu-12.04.5-alternate-amd64 mkdir /var/www/html/ubuntu12 cp /media/linux/鏡像名字/*   /var/www/ubuntu12/ -rf

添加網絡啟動的菜單選項:

/var/lib/tftpboot/ubuntu-installer/amd64/boot-screens/txt.cfg

添加菜單選項 label net 

        menu label ^Net ks 

        menu default 

        kernel ubuntu-installer/amd64/linux 

        append ks=  http://192.168.1.156/ks.cfg vga=788 initrd=ubuntu-installer/amd64/initrd.gz -- quiet  

#在vm中建立一個虛拟機,這裡需要注意虛拟機的網絡設定,一定要和伺服器在同一個網絡中,否則下載下傳不了ks.cfg檔案和系統 卡在安裝界面不自動安裝 是因為預設等待時間 0  防止區域網路内其他機器自動被重裝系統

kickstart +dhcp +tftpd+apache2 自動安裝ubuntu環境搭建

解決方法:

#vim /var/lib/tftpboot/pxelinux.cfg/default

timeout 1 #即設定1秒後自動選擇install選項

繼續閱讀