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. Http Referer的一些总结

    以前对Http中Referer的认识不够透彻.最近理了理,记录一下. 1 Referer可以记录访问的来源,统计访问量,可以用来防盗链. 2 客户端用js不能篡改Referer,用一些插件什么的可以达 ...

  2. 相比Redis,Memcached真的过时了吗?

    下面内容来自Redis作者在stackoverflow上的一个回答,对应的问题是<Is memcached a dinosaur in comparison to Redis?>(相比Re ...

  3. VBA RemoveDuplicates方法去重复项

    RemoveDuplicates后边必须跟参数否则不起作用 ActiveSheet.Range("G21:R36").RemoveDuplicates Columns:=12, H ...

  4. Oracle数据库入门——基础知识

    1.安装完成Oracle数据库后,使用sqlplus客户端登录数据库管理系统,只输入用户名,没有输入密码时,会提示口令为空,登录被拒绝. 请输入用户名:system 输入口令: ERROR:ORA-0 ...

  5. Mac下利用Cordova打包 iOS App以及出现的问题

    安装 cordova sudo npm install cordova 创建项目 创建一个demo文件夹,里面自动加载基本的文件以及目录 cordova create demo com.test.de ...

  6. wchar_t和char转化

    char* WcharToChar(const wchar_t* wp) { char *m_char; int len = WideCharToMultiByte(CP_ACP, 0, wp, wc ...

  7. spring的一些其他功能

    今天看书,知识点多一点了,涉及到了较多的知识,如scheduling计划任务,spring对多线程的支持,以及配置开发.测试和生产环境的profile.这些都是集成在spring中的,需要用时可以参考 ...

  8. 170828、Eclipse Java注释模板设置详解以及版权声明

    编辑注释模板的方法:Window->Preference->Java->Code Style->Code Template 然后展开Comments节点就是所有需设置注释的元素 ...

  9. 基于jdk1.8的HashMap源码学习笔记

    作为一种最为常用的容器,同时也是效率比较高的容器,HashMap当之无愧.所以自己这次jdk源码学习,就从HashMap开始吧,当然水平有限,有不正确的地方,欢迎指正,促进共同学习进步,就是喜欢程序员 ...

  10. MINIUI后台获取数据

    1.jsp <%@ page language="java" contentType="text/html; charset=UTF-8" pageEnc ...