首先感谢N(81855776)的帮助,跟他学到了很多。

一,介绍

pxe(preboot execute envionment,预启动执行环境),很多人叫它无盘安装,就是不需要我们平时安装系统用光盘或者U盘就可以安装系统,而采用网络安装,就是用远端服务器来充当之前的盘。当然了,最重要的就是客户端(我们即将要安装系统的电脑)和服务器端(已经搭建好的pxe环境的电脑)之间的网络是通的,即可以传递数据。

并非所有的电脑都支持pxe方式安装的,1,网卡上集成了pxe client,2,主板支持网卡启动。现在新一点的电脑都支持,我的电脑估计是比较早吧,13年初买的戴尔i5,暂时只支持legacy方式的network启动(即pxe),在uefi方式下没有。

因为pxe服务器的原因,我将pxe方式装机过程分为3个阶段,

第一阶段:dhcp

客户端开机选择network启动,然后将网卡上的pxe client信息拷贝到内存上运行,发送dhcp广播信息,从dhcp服务器上获取一个ip,并告知tftp服务器的ip,如果有多个dhcp服务器,客户端会接受第一个dhcp服务器的ip。所以服务器端要有个dhcp服务器。

第二阶段:tftp/mtftp

网卡上存储空间有限,所以只能集成轻量级别的tftp客户端。客户端从第一阶段获取到ip之后就会去tftp服务器端获取内核,初始化程序,引导文件等。所以服务器端还要搭建一个tftp服务器。

第三阶段:ftp/http/ntfs

这个阶段可以使用ftp/http/ntfs中的一个来获取系统的安装文件,我这里使用ftp。所以服务器端还要搭建一个ftp服务器。

这三个服务器搭建之后,pxe服务器就搭建好了,这个时候没有盘就可以安装,但是还是需要人去操作。接下来现在再写preseed文件,就可以完全自动化的安装系统了。

二,下载

iso文件:

这个是提供安装包的

需要下载系统的iso文件,官网:https://mirrors.tuna.tsinghua.edu.cn/debian-cd/9.6.0/amd64/iso-dvd/。

我下载的是这个:debian-9.6.0-amd64-DVD-1.iso

netboot文件:这个是提供Initrd文件的,因为cd或者dvd的initrd文件是在安装的过程会提示为探测到可用的光驱。

下载:https://mirrors.tuna.tsinghua.edu.cn/debian/dists/Debian9.6/main/installer-amd64/20170615/images/netboot/

有的人是直接用的netboot里的东西。

三,服务器搭建

这个阶段,可以使用

sudo dpkg -s xxxx

的命令,来看xxxx是否安装成功。

1,dhcp服务器的搭建

安装过程请参考:debian9.6搭建dhcp服务器,这里不暂仔细说了。

a,设置监听网口,这个地方必须是无线网口,因为目前无线的暂时不支持pxe,所以要去当dhcp服务器的监听网口,而有线网口给虚拟机无盘安装系统。如果两台都是物理机,则可以让其中一台的有线网卡当dhcp服务器的监听网口。

guoyanzhang@bogon:~$ sudo vim /etc/default/isc-dhcp-server
INTERFACESv4="wlp8s0"

b,增加两句,最后两句是和其他dhcp服务器不同的,因为这是为了pxe服务的dhcp服务器。

guoyanzhang@bogon:~$ sudo cat /etc/dhcp/dhcpd.conf
[sudo] guoyanzhang 的密码:
# begin /etc/dhcp/dhcp.conf
ddns-update-style none;
option domain-name "mydebian.org";
option domain-name-servers ns1.mydebian.org,ns2.mydebian.org;
default-lease-time 3600;
max-lease-time 7200;
authoritative;subnet 192.168.1.0 netmask 255.255.255.0{option routers 192.168.1.92;option subnet-mask 255.255.255.0;option domain-search "mydebian.org";option domain-name-servers 192.168.1.1;range 192.168.1.10 192.168.1.100;range 192.168.1.110 192.168.1.200;filename "pxelinux.0";next-server 192.168.1.92;
}
host debian1-node{hardware ethernet d4:be:d9:72:79:f6;fixed-address 192.168.1.158;
}
host debian2-node{hardware ethernet 00:50:56:2C:98:57;fixed-address 192.168.1.156;
}
host wins-node{hardware ethernet BC:EE:7B:C8:1A:39;fixed-address 192.168.1.160;
}
#filename "pxelinux.0";
#next-server 192.168.1.155;# end /etc/dhcp/dhcp.conf

pxelinux.0在下面说,next-server即tftp服务器的地址,在这里就是本机无线ip,如下:

3: wlp8s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000link/ether 84:a6:c8:e7:ef:b9 brd ff:ff:ff:ff:ff:ffinet 192.168.1.92/24 brd 192.168.1.255 scope global dynamic wlp8s0valid_lft 255764sec preferred_lft 255764secinet6 fe80::ed88:4aed:e1c8:8ad6/64 scope link valid_lft forever preferred_lft forever

我这个是笔记本连接无线,分的一个ip,如果你没有联网,那你就给你的无线网卡自己配一个ip,在/etc/init.d/interface里面。

2,tftp服务器的搭建

详细请参考:debian9.6搭建tftp服务器和安装tftp客户端,我这里不在写。

这个地方需要安装pxelinux,因为我们需要前面提到的pxelinux.0文件,也可以不安装,使用之前netboot里面的,我diff过了,没什么区别,它只是个引导文件。

guoyanzhang@bogon:~$ sudo apt-get install pxelinux
guoyanzhang@bogon:~$ sudo find / -name pxelinux.0
[sudo] guoyanzhang 的密码:
/usr/lib/PXELINUX/pxelinux.0

将netboot.tar.gz解压到mytftp目录下,现在我的tftp根目录下,如下:

guoyanzhang@bogon:~/mytftp$ ls
debian-installer  ldlinux.c32  pxelinux.0  pxelinux.cfg  version.info

不过,这个不能用因为这里面解压出来的内核,会和我使用dvd,cd的iso里面的内核不一样,如果用Netboot.tar.gz解压的话,后面安装会报错,说是内核模块不兼容。所以采用如下的办法:

guoyanzhang@bogon:~$ apt-cache search debian-installer-9-netboot-amd64
debian-installer-9-netboot-amd64 - Debian-installer network boot images for amd64
guoyanzhang@bogon:~$ sudo apt-get install debian-installer-9-netboot-amd64
guoyanzhang@bogon:~$ dpkg -s debian-installer-9-netboot-amd64
Package: debian-installer-9-netboot-amd64
Status: install ok installed
Priority: optional
Section: misc
Installed-Size: 86624
Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
Architecture: all
Source: debian-installer-netboot-images
Version: 20170615+deb9u5
guoyanzhang@bogon:~$ dpkg -L debian-installer-9-netboot-amd64
这里会看到debian-installer的,将里面的debian-installer拷贝到mytftp里面去

至于prexlinux.cfg是个文件夹,里面有个default文件,内容如下:

guoyanzhang@bogon:~/mytftp/pxelinux.cfg$ cat default
# D-I config version 2.0
# search path for the c32 support libraries (libcom32, libutil etc.)
path .
#include ./menu.cfg
default ./debian-installer/amd64/boot-screens/vesamenu.c32
prompt 1
timeout 100
default vmdebianlabel vmdebiankernel debian-installer/amd64/linux
#   append vga=normal initrd=./initrd.gz
#   append vga=normal initrd=./initrd.gz repo=http://192.168.1.92/
#   append vga=normal initrd=./initrd.gz mirror_regexps=http://192.168.1.92/ append vga=normal withiscsi=0 initrd=debian-installer/amd64/initrd.gz debian-installer/allow_unauthenticated=true auto=true interface=auto netcfg=no_default_route=true priority=critical url=http://192.168.1.92/preseed.cfg  inetcfg/choose_interface=enp7s0 netcfg/dhcp_timeout=120 DEBCONF_DEBUG=5IPAPPEND 2

指定了内核,初始化程序等的位置。

3,ftp服务器的搭建

详细请参考:debian9.6搭建ftp服务器和安装ftp客户端 ,这里我不再详细写,里面内容和这里完全一样。

guoyanzhang@bogon:~$ sudo apt-get install vsftpd

将下载的系统的iso文件下的内容全部拷贝到ftp的根目录下。

这个方法比较麻烦,搞了好久,也没成功,所以我这里换了http服务器apache2。

guoyanzhang@bogon:~$ dpkg -s apache2
Package: apache2
Status: install ok installed
Priority: optional
Section: httpd
Installed-Size: 578
Maintainer: Debian Apache Maintainers <debian-apache@lists.debian.org>
Architecture: amd64
Version: 2.4.25-3+deb9u6
Replaces: apache2.2-bin, apache2.2-common
Provides: httpd, httpd-cgi

配置如下:这里是跟原来的配置不一样的地方,其他地方都没有变动。

guoyanzhang@bogon:~$ cat /etc/apache2/apache2.conf
#<Directory />
#   Options FollowSymLinks
#   AllowOverride None
#   Require all denied
#</Directory><Directory /usr/share>AllowOverride NoneRequire all granted
</Directory>
DocumentRoot "/home/guoyanzhang/dvd/"
<Directory /home/guoyanzhang/dvd/>Options Indexes FollowSymLinksAllowOverride ALL
#   Require all grantedOrder allow,denyAllow from all
</Directory>

另外一个,同样,也是只看我改的地方,其他地方都没有动。

guoyanzhang@bogon:~$ cat /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80># The ServerName directive sets the request scheme, hostname and port that# the server uses to identify itself. This is used when creating# redirection URLs. In the context of virtual hosts, the ServerName# specifies what hostname must appear in the request's Host: header to# match this virtual host. For the default virtual host (this file) this# value is not decisive as it is used as a last resort host regardless.# However, you must set it for any further virtual host explicitly.#ServerName www.example.comServerAdmin webmaster@localhost##DocumentRoot /var/www/htmlDocumentRoot /home/guoyanzhang/dvd/

可以看到,我将http的根目录设置为/home/guoyanzhang/dvd了。

现在将iso文件挂载到这个目录下:

guoyanzhang@bogon:~/os$ sudo mount debian-9.6.0-amd64-DVD-1.iso /home/guoyanzhang/dvd/debianiso/
mount: /home/guoyanzhang/os/debian-9.6.0-amd64-DVD-1.iso is already mounted

因为我挂载过了,所以提示这个。

4,写preseed.cfg文件,放到/home/guoyanzhang/dvd下。

guoyanzhang@bogon:~/dvd$ cat preseed.cfg
#d-i live-installer/net-image string http://192.168.1.92/extrafiles
# locale sets language and country
d-i debian-installer/locale string zh_CN
# keyboard selection
d-i keyboard-configuration/xkb-keymap select us
# network configuration
# mirror settings
d-i mirror/country string manual
d-i mirror/protocol string http
d-i mirror/http/hostname string 192.168.1.92
d-i mirror/http/directory string /debianiso
d-i mirror/http/proxy string http://192.168.1.92
d-i mirror/udeb/suite string stretch
# clock and time zone setup
d-i clock-setup/utc boolean false
d-i time/zone string Asia/Shanghai
# partitioning
d-i partman-auto/disk string /dev/sda
d-i partman-auto/method string regular
d-i partman-auto/choose-recipe string atomic
d-i partman-partitioning/confirm_write_new_label boolean true
d-i partman/choose_partition string finish
d-i partman/confirm boolean true
d-i partman/confirm_nooverwrite boolean true
# account setup
d-i passwd/root-login boolean true
d-i passwd/root-password password 123456
d-i passwd/root-password-again password 123456
d-i passwd/make-user boolean false
d-i user-setup/encrypt-home boolean false
d-i user-setup/allow-password-weak boolean true
# package selection
tasksel tasksel/first multiselect standard,debian-servr
d-i pkgsel/include string openssh-server
d-i pkgsel/upgrade select none
d-i pkgsel/language-packs multiselect en,zh
d-i pkgsel/update-policy select none
# boot loader installation
d-i grub-installer/only_debian boolean true
# finishing up the installation
d-i finish-install/reboot_in_progress note

(partition这应该有点问题)

四,客户端搭建

方法1:virtualbox(最后不能获取ip不知道为什么,但是我连另外的物理机是可以的)

这里我另外写了文章,请参阅:debian9.6安装virtualbox,我这边戴尔电脑,在虚拟机上启动空的虚拟机,要我按F12选启动方式,我选择network。

安装好的virtualbox,我已经设置了网桥,网卡mac是我的有线网卡的。

1,新建一个debian

这里不详细说,网上很多virtualbox安装系统的教程。

启动服务:

guoyanzhang@bogon:~$ ./all.sh
[ ok ] Restarting isc-dhcp-server (via systemctl): isc-dhcp-server.service.
[ ok ] Restarting tftpd-hpa (via systemctl): tftpd-hpa.service.
[ ok ] Restarting xinetd (via systemctl): xinetd.service.
[ ok ] Restarting vsftpd (via systemctl): vsftpd.service.

2,启动,按f12,选择lan,即l键

3,获取ip,结果失败了

有人说vbox的ipxe是有点问题,但是我另外的物理机是获取了ip的,所以我换vmware试试。 如果有人知道是怎么回事的,希望留言告知。

方法2:

搭建vmware:debian9.6安装vmware15教程,里面的内容完全一样,这里不再细说。我这边启动空的虚拟机,自己就选择network方式安装了,即pxe。

同样的方法又在vm14上出现,我以为是vm的问题,换了之后还是不行。

出现问题:

参考1:https://baike.baidu.com/item/PXE/6107945?fr=aladdin

参考2:https://blog.csdn.net/u013451404/article/details/77103759

参考3:https://blog.csdn.net/soulwish/article/details/53192247

参考4:http://blog.chinaunix.net/uid-24648266-id-5609167.html

参考5:https://www.syslinux.org/wiki/index.php?title=PXELINUX#Description

debian9.6搭建pxe服务器+preseed,并在虚拟机上测试(完善中)相关推荐

  1. 搭建Pxe服务器无人听应答全自动网络安装VMWare esxi 6.0系统

    前面我们已经使用CentOS6.7平台搭建了pxe服务器,现在我们利用此服务器继续安装vmware esxi6.0系统的客户机.参阅 http://1130739.blog.51cto.com/112 ...

  2. UEFI调试网络启动-WINDOWS搭建PXE服务器

    这里使用tftpd64搭建此服务器,PXE设置两个服务器: 1.DHCP服务器:用来动态分配IP地址(同时分配子网掩码.网关.TFTP服务器地址.启动文件名.DNS服务器.时间服务器等等). 2.TF ...

  3. 使用tftpd32搭建PXE服务器——从FTP服务器下载内核及INITRD文件

    2019独角兽企业重金招聘Python工程师标准>>> 必备工具 tftpd32-4.5.0 syslinux-6.0.3 vmware workstation 以上工具都可以从网上 ...

  4. 服务器安装系统sles系统,搭建Pxe服务器无人听应答全自动安装SLES11 SP3系统(示例代码)...

    前面我已经介绍了基于CentOS6.7的平台搭建的pxe服务器,今天我们利用此pxe服务器继续安装部署SLES11 SP3系统的客户机.参考http://1130739.blog.51cto.com/ ...

  5. aws搭建包含服务器和网络的虚拟基础设施(2)

    1.EC2使用 1.1启动虚拟服务器:即启动一个EC2实例 1.2使用SSH连接到虚拟服务器 1.3手动安装和运行软件 1.4监控和调试虚拟服务器 1.5关闭虚拟服务器 1.6更改虚拟服务器的容量 1 ...

  6. 虚拟机nginx 服务器无法访问,VMware虚拟机上配置nginx后,本机无法访问问题(转载)...

    转自:http://www.server110.com/nginx/201407/10794.html 把nginx装在CentOS上,用本机访问虚拟机的时候却出现了不能访问的问题,查了资料以后,原来 ...

  7. 服务器推送系统安装,搭建PXE服务器,推送安装linux系统

    搭建环境: 推送服务器: Ip:192.168.189.138 系统:CentOS 5.8 推送系统:RHEL 5.4 1:配置dhcpd服务. 如果没有安装dhcpd服务,请安装: 1 2 3 4 ...

  8. 如何在虚拟机上安装wsus服务器,如何在Hyper-V虚拟机上安装WSUS服务器技巧

    由于许多企业继续减少使用物理服务器,一个经常提及的问题随之而来:对Windows Server更新服务(WSUS)服务器进行虚拟化处理是个好想法吗?简单的回答:是的.本文介绍了如何在Hyper-V虚拟 ...

  9. 如何在虚拟机上安装wsus服务器,如何在Hyper-V虚拟机上安装WSUS服务器技巧_Hyper-V...

    由于许多企业继续减少使用物理服务器,一个经常提及的问题随之而来:对Windows Server更新服务(WSUS)服务器进行虚拟化处理是个好想法吗?简单的回答:是的.本文介绍了如何在Hyper-V虚拟 ...

最新文章

  1. Python,OpenCV提取图片中的多个茄子种子轮廓,并按从左到右排序后显示
  2. 程序员成熟的几个标志
  3. SpringSecurity认证
  4. 暴力技术(一)——BFS广(宽)度优先搜索
  5. js的tree数组对象扁平化思否_js 中的tree型数组如何去重与合并?
  6. 设计模式(十八):责任链模式
  7. 华为交换机基本配置命令详解
  8. c语言power函数作用,pow函数(c语言pow函数用法)
  9. 查看mysql 当前锁级别_mysql innodb下的锁及隔离级别
  10. A 45nm 1.3GHz 16.7 double-precision GFLOPS/W RISC-V processor with vector accelerators
  11. uniapp 微信小程序 保存图片到本地
  12. 国内有免费“免费虚拟主机““免费云服务器”吗?
  13. 微信公众号对接网课查题系统
  14. 20190401每周精品之读书
  15. 【中科院】分子生物学-朱玉贤第四版-笔记-病毒的分子生物学
  16. 搞信息化可走开源之路
  17. 开发多了犯傻系列之---数据库imp命令导入“忽略了剩余的行”
  18. 美团-深度学习在点评推荐平台排序中的运用
  19. 2019国际计算机音乐联会韩国,温州大学音乐学院与韩国全南大学2019年联合培养博士招生及培养商谈会...
  20. vue零基础——vue2基础知识

热门文章

  1. 第一篇 初步认识PRINCE2 管理体系
  2. 【413】C 语言 Command line
  3. 数据库建一张学生表,要求有姓名,性别,年龄,班级,成绩字段
  4. Vue引入Echart初始化错误
  5. python 凯利公式_凯利公式的启示
  6. android nfc刷卡广播,Android关于NFC的简单使用
  7. php宠物喂食,基于Arduino的宠物喂食系统QQFeerder--代码
  8. 第三方视频播放--jiecao
  9. 清理windows的弹窗的办法
  10. java 中如何打包成 jar 包