TFTP服务

用PXE安装操作系统依赖于DHCP服务和TFTP服务

网卡一般都内置的TFTP客户端的程序

systemctl enable tftp     systemctl enable  dhcpd

 [root@centos7 dhcp]# yum install tftp-server
[root@centos7 dhcp]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd..gz
/usr/share/man/man8/tftpd..gz
/var/lib/tftpboot
#安装客户端
[root@yxh6 ~]# yum install tftp
[root@yxh6 ~]# tftp 192.168.231.7
tftp> get file
#file存在服务端的/var/lib/tftpboot目录下

TFTP配置

搭建PXE服务器

[root@centos7 html]#yum install httpd
[root@centos7 html]# systemctl start httpd
[root@centos7 html]# vi /etc/fstab
/dev/sr0 /var/www/html/centos7 iso9660 defautls
[root@centos7 html]# mount -a
mount: /dev/sr0 is write-protected, mounting read-only
[root@centos7 html]# mkdir ksdir{,}
[root@centos7 html]# ls
centos6 centos7 ksdir6 ksdir7
[root@centos7 html]# cp /root/anaconda-ks.cfg ksdir7/ks7_desktop.cfg
[root@centos7 html]# cd ksdir7
[root@centos7 ksdir7]# ls
ks7_desktop.cfg
[root@centos7 ksdir7]# ll
total
-rw------- root root May : ks7_desktop.cfg
[root@centos7 ksdir7]# chmod ks7_desktop.cfg
[root@centos7 ksdir7]# ll
total
-rw-r--r-- root root May : ks7_desktop.cfg

准备yum源和ks文件

[root@centos7 dhcp]# vi dhcpd.conf
#配置和自动安装系统相关的配置 subnet 192.168.231.0 netmask 255.255.255.224 {
range 192.168.231.10 192.168.231.20;
option routers 192.168.231.254;
next-server 192.168.231.7;
filename "pxelinux.0";
} [root@centos7 dhcp]# systemctl restart dhcpd.service
[root@centos7 dhcp]# systemctl enable dhcpd httpd

配置DHCP

 [root@centos7 dhcp]# yum install  tftp-server syslinux
[root@centos7 dhcp]# cd /var/lib/tftpboot
[root@centos7 tftpboot]# mkdir pxelinux.cfg/
#pxelinux. 文件来自于 syslinux软件包,必须先安装syslinux
[root@centos7 tftpboot]# cp /usr/share/syslinux/pxelinux. .
[root@centos7 tftpboot]# cp /var/www/html/centos7/isolinux/{vmlinuz,initrd.img,vesamenu.c32} /var/lib/tftpboot/
[root@centos7 tftpboot]#cp /var/www/html/centos7/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@centos7 pxelinux.cfg]# vi default
label linux
menu label ^Install Desktop7
kernel vmlinuz
append initrd=initrd.img ks=http://192.168.231.7/ksdir7/ks7_desktop.cfg
[root@centos7 pxelinux.cfg]#systemctl enable tftp.socket
[root@centos7 pxelinux.cfg]#systemctl start tftp

配置TFTP

 #version=DEVEL
# System authorization information
auth --enableshadow --passalgo=sha512
# Use CDROM installation media
url --url=http://192.168.231.7/centos7
# Use graphical install
#graphical
text
# Run the Setup Agent on first boot
firstboot --enable
ignoredisk --only-use=sda
# Keyboard layouts
keyboard --vckeymap=us --xlayouts='us'
# System language
lang en_US.UTF-
reboot
# Network information
network --bootproto=dhcp --device=ens33 --onboot=on --ipv6=auto --no-activate
network --hostname=centosmy7.localdomain # Root password
rootpw --iscrypted $$RzUIKaLkncGUm9SL$FtuXzR8IpSz2OEQp.LlDrDH1O62SMrZ/Gj06iTSNqlxWma/aHf21lpikhNln6UgNyuL/HqGUrM45feTBkMC1T0
# System services
services --disabled="chronyd"
# System timezone
timezone Asia/Shanghai --isUtc --nontp
# X Window System configuration information
xconfig --startxonboot
# System bootloader configuration
bootloader --append=" crashkernel=auto" --location=mbr --boot-drive=sda
zerombr
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part swap --fstype="swap" --ondisk=sda --size=
part / --fstype="xfs" --ondisk=sda --size=
part /data --fstype="xfs" --ondisk=sda --size=
part /boot --fstype="xfs" --ondisk=sda --size= %packages
@base
@core
@dial-up
@fonts
@guest-agents
@print-client
@x11
kexec-tools %end %addon com_redhat_kdump --enable --reserve-mb='auto' %end %anaconda
pwpolicy root --minlen= --minquality= --notstrict --nochanges --notempty
pwpolicy user --minlen= --minquality= --notstrict --nochanges --emptyok
pwpolicy luks --minlen= --minquality= --notstrict --nochanges --notempty
%end %post
systemctl disable initial-setup.service
systemctl disable initial-setup-graphical.service
systemctl set-default multi-user.target
mkdir -p /root/oscreate
useradd laozijiadeuser
%end

ks文件示例

新创建一个虚拟机,把网卡的网段设置成和服务器为同一个网段,启动机器出现下图

PXE安装多个版本的系统

安装不同版本的操作系统,需要分别拷贝对应的内核文件和ks文件,不能混合使用

mkdir /var/lib/tftpboot/pxelinux.cfg/
cp /usr/share/syslinux/pxelinux. /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
mkdir /var/lib/tftpboot/centos{,} cp /var/www/html/centos//isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos7/
cp /var/www/html/centos//isolinux/{vmlinuz,initrd.img} /var/lib/tftpboot/centos6/ cp /var/www/html/centos//isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
vim /var/lib/tftpboot/pxelinux.cfg/default cat /var/lib/tftpboot/pxelinux.cfg/default cat /var/lib/tftpboot/pxelinux.cfg/default
default menu.c32
timeout menu title www.yxh.com label centos7
menu label ^Install Desktop CentOS
kernel centos7/vmlinuz
append initrd=centos7/initrd.img ks=http://192.168.30.17/ksdir/ks7_desktop.cfg label centos6
menu label install ^Mini CentOS
menu default
kernel centos6/vmlinuz
append initrd=centos6/initrd.img ks=http://192.168.30.17/ksdir/ks6_mini.cfg
label local
menu label Boot from ^local drive
localboot 0xffff
menu end

代码示例

 tree /var/lib/tftpboot/
/var/lib/tftpboot/
├── centos6
│├── initrd.img
│└── vmlinuz
├── centos7
│├── initrd.img
│ └── vmlinuz
├── menu.c32
├── pxelinux.
└── pxelinux.cfg
└── default

文件结构目录

Linux配置服务的一般步骤

1.检查防火墙和selinux
2.安装包
3.启动服务
4.检查服务是否成功启动
5.在客户端执行命令测试
6.每个服务都有自己的工作主目录

PXE安装操作系统的更多相关文章

  1. PXE+Kickstart+DHCP+TFTP实现无人值守安装操作系统

    PXE+Kickstart+DHCP+TFTP实现无人值守安装操作系统 PXE + Kickstart PXE的工作流程及配置文件 Kickstart的配置文件 Linux安装大致可以分为2个阶段 第 ...

  2. [转]CentOS 6.4下PXE+Kickstart无人值守安装操作系统

    一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...

  3. CentOS 6.4下PXE+Kickstart无人值守安装操作系统 转

    一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...

  4. RHEL7下PXE+NFS+Kickstart无人值守安装操作系统

    RHEL7下PXE+NFS+Kickstart无人值守安装操作系统 1.配置yum源 vim /etc/yum.repos.d/development.repo [development] name= ...

  5. RHEL7下PXE+Apache+Kickstart无人值守安装操作系统

    RHEL7下PXE+Apache+Kickstart无人值守安装操作系统 1.配置yum源 vim /etc/yum.repos.d/development.repo [development] na ...

  6. CentOS 6.6下PXE+Kickstart无人值守安装操作系统

    一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...

  7. 【转载】CentOS 6.4下PXE+Kickstart无人值守安装操作系统

    [转载]CentOS 6.4下PXE+Kickstart无人值守安装操作系统 转自:CentOS 6.4下PXE+Kickstart无人值守安装操作系统 - David_Tang - 博客园 http ...

  8. Centos下PXE+Kickstart无人值守安装操作系统

    一.简介 1.1 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持 ...

  9. CentOS 7下PXE+Kickstart无人值守安装操作系统

    1.简介 1.1. 什么是PXE PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支 ...

随机推荐

  1. 【Oracle】删除所有表

    BEGIN FOR cur_rec IN (SELECT object_name, object_type FROM user_objects WHERE object_type IN ('TABLE ...

  2. 【JAVA-JDT-AST】Java抽象语法树的构建、遍历及转成dot格式(附Github源码)

    Background: 最近为了重现tree-based clone detection的论文:L. Jiang, G. Misherghi, Z. Su, and S. Glondu. Deckar ...

  3. gitlab图形化使用教程 (mtm推荐)

    原文:http://www.restran.net/2016/02/23/git-and-gitlab-guide/?utm_source=tuicool&utm_medium=referra ...

  4. vb编程学习之路之基础与概念总结

    OOP (Object Oriented Programming)面向对象程序设计/面向对象编程 对象是代码和数据的集合,对象的三要素:属性.事件.方法 对象的命令规则:必须以字母或汉字开头,不能以数 ...

  5. vs2017企业版本安装和序列号

    离线包大概下载为19G,可以选择的选择项很多,很不错,安装如下: 安装完成 启动效果 SharePoint插件自带了 离线包(19G) Visual Studio 2017(VS2017) 企业版En ...

  6. linux的centos如何查看java的安装路径

    https://blog.csdn.net/dannistang/article/details/82906867 使用echo查看文件位置的话,前提是配置安装了环境变量java_home,否则是找不 ...

  7. isinstance函数

    isinstance isinstance(object, classinfo) 判断实例是否是这个类或者object是变量 classinfo 是类型(tuple,dict,int,float,bo ...

  8. nodejs 获取自己的ip

    代码片段 // npm i --save-dev request const request = require('request'); const url = "http://ip.tao ...

  9. python-and和 or用法

    python中的逻辑运算 and和or执行逻辑运算,但是它们不会返回bool值,而是返回它们进行比较的值之一 and >>> 1 and 2 取2 >>>1 and ...

  10. 试水Spring Cloud Hystrix

    Spring Cloud Hystrix是一个容错库,它实现了断路器模式,使得当服务发生异常时,会自动切断连接,并将请求引导至预设的回调方法. 服务端 在Spring Tool Suite的文件菜单中 ...