技术标签: debian学习之路 debian pxe
首先感谢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文件是在安装的过程会提示为探测到可用的光驱。
有的人是直接用的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 1000
link/ether 84:a6:c8:e7:ef:b9 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.92/24 brd 192.168.1.255 scope global dynamic wlp8s0
valid_lft 255764sec preferred_lft 255764sec
inet6 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 <[email protected]>
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 vmdebian
label vmdebian
kernel 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=5
IPAPPEND 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 <[email protected]>
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 None
Require all granted
</Directory>
DocumentRoot "/home/guoyanzhang/dvd/"
<Directory /home/guoyanzhang/dvd/>
Options Indexes FollowSymLinks
AllowOverride ALL
# Require all granted
Order allow,deny
Allow 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.com
ServerAdmin webmaster@localhost
##DocumentRoot /var/www/html
DocumentRoot /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
2019独角兽企业重金招聘Python工程师标准>>> ...
1、什么是媒体查询 媒体查询可以让我们根据设备显示器的特性(如视口宽度、屏幕比例、设备方向:横向或纵向)为其设定CSS样式,媒体查询由媒体类型和一个或多个检测媒体特性的条件表达式组成。媒体查询中可用于..._什么是css3新增的一种新语法,用来根据窗口宽度,屏幕比例和设备方向等差异
我的要求是:当我运行NSIS安装程序时,首先它应该检查用户是否具有管理用户权限,如果用户具有权限,那么在安装时,应用程序应该在Windows注册表中写入路径和值 .要检查管理权限,我在下面写了下面的代码片段.onInitRequestExecutionLevel adminFunction .onInitUserInfo::GetAccountTypepop $0${If} $0 != "admi...
“汇新杯”互联网产业模式专项赛参赛项目范围(1)基于互联网和移动互联网的约车、食宿、支付、社交等共享经济和分享经济的新业务;(2)互联网和移动互联网与公共服务深度融合:基于互联网的交通、旅游、教育、医疗、就业、社保、养老、公安、司法等便民服务的新型商业模式;(3)互联网新技术新应用:为贫困地区农产品销售、乡村旅游、生产指导、就业服务、技能培训等提供更加优质便捷的服务;(4)围绕国家发展战略...
1. 软件清单 jdk-7u76-i586.rar apache-maven-3.3.9.rar eclipse-jee-helios-SR1-win32 taobao-tomcat.rar mysql-5.6.12-win32 navicat_trial_11.1.20.......artifactId>DmJdbcDriver 1.8.0 5 加载 DM 驱动程序 5.1 拷贝 DM ..._mysql5.7 maven
手头的一个项目中使用了dl dt dd模拟表格布局,在Chrome中一切看起来很完美,结果到IE和firefox中就完全面目全非。现总结如下:HTML结构如下:<div id="banner"> <img src="images/banner2.png" /> <dl> <dd>$445<br..._dl dd宽度一致
KaLi Linux是基于debian打造的linux操作系统,这款操作系统内置了丰富实用的安全测试工具,采用的系统核心为Linux Kernel 3.18,新版本升级了virtualbox-tool、openvm-tools、vmware-tools组件,并修复了诸多bug,可以说是比较安全的一款操作系统,有需要的快快下载吧。硬件要求至少 10GB 的磁盘空间;强烈建议分配更多的存储空间。至少 ..._kali linux更新源下载
https://pintia.cn/problem-sets/994805260223102976/problems/994805292322111488#include <iostream>using namespace std;int main(){ string s1, s2; cin >> s1 >> s2; int sub = 0, v[3...
HTML CSS锚点的作用什么?如何创建锚点?锚点是文档中某行的一个记号。类似于书签,用于链接到文档中的某个位置,当定义锚点后,我们可以创建直接跳至该锚点(比如页面中某个小节)的链接,这样使用者就无须不停地滚动页面来寻找他们需要的信息了。在使用元素创建锚点时,需要使用name属性为其命名,代码如下锚点1<a href='#anchorname1'>回到锚点</a>超级链接有哪些常见的变现形式?元素用于创建超链接,常见的表现形式有:普通超链接,语法<a hre_vue object数组打印有值长度0
93. 递归实现组合型枚举用一个动态数组记录被选中的数,若这些数的个数>m、这些数的总数+所有剩余数的个数<m表示当前的选择不满足条件(相当于剪枝函数),所以要回溯。#include <iostream>#include <bits/stdc++.h>using namespace std;int n,m;vector<int> x; //标记当前是否被选择过void dfs(int current){ if(x.size()>_递归实现组合型枚举 ii
测试 Android app 的时候,Android 模拟器是经常会用到的工具。模拟器可以轻松的模拟不同的品牌、分辨率和 Android 系统版本。可以让兼容测试做起来更容易。下面就来看看目前常用的 Android 模拟器都有哪些。_app开发模拟器
实验2:手动部署OceanBase集群。_oceanbase集群