基于PXE+Pressed方式的Ubuntu14.04网络安装

基于PXE+Pressed方式的Ubuntu14.04网络安装

1. PXE简介

       PXE是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端服务器下载映像,并由此支持来自网络的操作系统的启动过程,其启动过程中,终端要求服务器分配IP地址,再用TFTP(trivial file transferprotocol)或MTFTP(multicast trivialfile transfer protocol)协议下载一个启动软件包到本机内存中并执行,由这个启动软件包完成终端基本软件设置,从而引导预先安装在服务器中的终端操作系统。PXE可以引导多种操作系统,如:Windows 95/98/2000/xp/2003/vista/2008,linux等。

2. 环境

PXE Server:Ubuntu-14.04 Server 64位操作系统,IP:192.168.74.128

PXE Client:BIOS设置从网络启动(若为第一次安装可不用设置)

注:PXE Server和PXE Client在一个局域网内。


3. PXE Server 安装相关服务

1. apt-get installdhcp3-server

2. apt-get installapache2

3. apt-get installtftpd-hpa tftp-hpa

 

4. 配置dhcp服务

修改配置文件/etc/dhcp/dhcpd.conf,配置如下图:

subnet 192.168.74.0 netmask 255.255.255.0 {
range 192.168.74.150 192.168.74.151;
option domain-name "192.168.74.128"; 
option domain-name-servers 192.168.74.128; 
option routers 192.168.74.1;                        
default-lease-time 600; 
max-lease-time 7200; 
next-server 192.168.74.128;                            
filename "pxelinux.0"; 
host ns1 {
hardware ethernet 00:0c:29:01:7e:f0;
fixed-address 192.168.74.243;
}
}


说明:
subnet为dhcp服务器分配ip的子网192.168.74网段,必须和PXE server的一个网卡同一个网段;
range为dhcp服务器为客户端分配IP的范围;
domain-name为客户端指明DNS名字;
domain-name-servers为客户端指明DNS服务器的IP地址;
routers为客户端指定网关;
default-lease-time为默认租约时间(单位:秒);
max-lease-time为最大租约时间(单位:秒);
next-server为客户端指定tftp服务器地址
filename为开始启动文件的名称;
host ns1中是位特定的MAC地址指定IP地址;


配置好后运行DHCP服务:
#service isc-dhcp-server restart 来重启服务
运行netstat -anp | grep :67
udp  0     0 0.0.0.0:67         0.0.0.0:*            1777/dhcpd
这个表示服务已经在运行中。


5. 配置Apache服务

首先创建ubuntu14.04的镜像目录:
#mkdir /var/www/html/ubuntu14.04
挂载Ubuntu14.04的光盘镜像:
#mount /dev/cdrom /mnt
#cp –r /mnt/* /var/www/html/ubuntu14.04
启动apache:
#/etc/init.d/apache2 start 
并保证通过浏览器访问http://ip/ubuntu14.04/ 可以看到目录的内容。


6.配置TFTP

配置文件/etc/default/tftpd-hpa默认不用修改。

1.创建pxe加载文件:
#cd /var/lib/tftpboot/
#cp -r /var/www//html/ubuntu14.04/install/netboot/* .
修改/var/lib/tftpboot/ubuntu-installer/amd64/boot-screens目录下的syslinux.cfg文件:
timeout改为1


3.修改initrd.gz文件
首先解包initrd,然后在initrd根目录下面放置一个文件preseed.cfg,然后在将initrd打包
解包initrd
#cd /home
#cp /var/lib/tftpboot/ubuntu-installer/amd64/initrd.gz .
#gunzip initrd.gz
#mv initrd initrd.img
#mkdir initrd
#cd initrd
#cpio -id <../initrd.img
#添加全自动安装的内容
#vi preseed.cfg  (该文件应在initrd目录下,后面我们要把initrd目录里的内容重新再打包)
然后再打包:
#find . | cpio -o -H newc |gzip -9 >../initrd.gz
替换网络启动的initrd
#cd ..
#cp initrd.gz /var/lib/tftpboot/ubuntu-installer/amd64/


7.preseed.cfg例子

#locate
d-i debian-installer/locale string en_US
#keyboard
d-i console-setup/ask_detect boolean false
d-i console-configuration/layoutcode string us
d-i keyboard-configuration/modelcode string SKIP
#clock
d-i clock-setup/utc boolean false
d-i time/zone string Asia/Shanghai
#network
d-i netcfg/choose_interface select eth0
d-i netcfg/dhcp_failed note
d-i netcfg/dhcp_options select Configure network manually
d-i netcfg/get_hostname string controller
#mirror
d-i mirror/country string manual
d-i mirror/http/hostname string 192.168.74.128
d-i mirror/http/directory string /ubuntu14.04
d-i mirror/http/proxy string
#clock
d-i clock-setup/ntp boolean true
#Partitioning
#d-i partman-auto/disk string /dev/sda  
d-i partman-auto/method string regular  
d-i partman-lvm/device_remove_lvm boolean true  
d-i partman-md/device_remove_md boolean true  
d-i partman-auto/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
# Base system installation
d-i base-installer/kernel/image string linux-generic
#user
d-i passwd/root-login boolean root
d-i passwd/root-password password 123456
d-i passwd/root-password-again password 123456
d-i user-setup/allow-password-weak boolean true
d-i passwd/make-user boolean false
d-i user-setup/encrypt-home boolean false
#file system
d-i live-installer/net-image string http://192.168.74.128/ubuntu14.04/install/filesystem.squashfs
#apt setup
d-i apt-setup/use_mirror boolean false
d-i apt-setup/services-select multiselect security
d-i apt-setup/security_host string 192.168.74.128
d-i apt-setup/security_path string /ubuntu14.04
d-i debian-installer/allow_unauthenticated string true
#package
tasksel tasksel/first multiselect standard
d-i pkgsel/include string openssh-server vim
d-i pkgsel/install-language-support boolean false
d-i pkgsel/language-packs multiselect en, zh
d-i pkgsel/update-policy select none
#grub
d-i grub-installer/skip boolean false
d-i lilo-installer/skip boolean true
d-i grub-installer/grub2_instead_of_grup_legacy boolean true
d-i grub-installer/only_debian boolean true
d-i grub-installer/with_other_os boolean true
d-i preseed/late_command string sed -i 's/PermitRootLogin without-password/PermitRootLogin yes/g' /target/etc/ssh/sshd_config
d-i finish-install/reboot_in_progress note

注:
d-i live-installer/net-image string http://192.168.74.128/ubuntu/install/filesystem.squashfs
这项为必须的配置项(ubuntu12.10版本以后,安装一些包会依赖于预配置的文件系统,这就是导致使用kickstart方式无法成功安装的原因),否则在安装过程中会失败。

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值