Centos7 Pxe

1.关闭防火墙
systemctl disable --now firewalld
setenforce 0
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
sudo wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
sudo yum clean all
sudo yum makecache
2.安装http tftp dhcp服务
yum -y install httpd
yum -y install tftp-server
yum -y install dhcp
yum -y install xinetd
systemctl enable httpd tftp dhcp xinetd
3.创建tftp配置文件(此文件不存在 需手动创建)
vi /etc/xinetd.d/tftp
service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot
        disable                 = no
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}
4.配置dhcp服务
vi /etc/dhcp/dhcpd.conf

ddns-update-style none;


filename "bootx64.efi";
next-server 10.0.17.100;

subnet 10.0.17.0 netmask 255.255.255.0 {
  range 10.0.17.200 10.0.17.230;
  option routers 10.0.17.2;
  option domain-name-servers 114.114.114.114;
}
5.配置http服务
vi /etc/httpd/conf.d/welcome.conf

只留
<Directory /usr/share/httpd/noindex>
    AllowOverride None
    Require all granted
</Directory>


cp centos.iso/var/www/html/ubuntu.iso
mkdir /var/www/html/ubuntu
mount centos.iso /var/www/html/ubuntu
6.拷贝所需要的启动文件到/var/lib/tftpboot/
cp /var/www/html/centos/EFI/boot/grubx64.efi /var/lib/tftpboot/grubx64.efi
cp /var/www/html/centos/casper/initrd /var/lib/tftpboot/initrd 
cp /var/www/html/centos/casper/vmlinuz /var/lib/tftpboot/vmlinuz 

yum install grub2-efi-x64
yum install shim-x64
yum install grub2-efi-x64-modules

grub2-mkstandalone -d /usr/lib/grub/x86_64-efi/ -O x86_64-efi --modules="tftp net efinet linux part_gpt efifwsetup" -o /var/lib/tftpboot/bootx64.efi
chmod 777 /var/lib/tftpboot
7.编辑引导配置文件
vi /var/lib/tftpboot/grub.cfg 

function load_video {
  insmod efi_gop
  insmod efi_uga
  insmod video_bochs
  insmod video_cirrus
  insmod all_video
}

load_video
set gfxpayload=keep
insmod gzio
insmod part_gpt
insmod ext2

set timeout=5
menuentry 'Install Centos 7' --class fedora --class gnu-linux --class gnu --class os {
        set gfxpayload=keep
        linuxefi (tftp)/vmlinuz ip=dhcp url=http://10.0.17.100/ubuntu-23.10-live-server-amd64.iso ks=http://10.0.17.100/ks.cfg
        initrdefi (tftp)/initrd
}
8.Kickstart
yum install system-config-kickstart
vim /etc/yum.repo.d/development.repo

[development]

name=development

baseurl=file:///var/www/html/centos

gpgcheck=0

ks.cfg

#platform=86, AMD64, or Intel EM64T

#version=DEVEL
# System authorization information
auth --useshadow  --passalgo=sha512
# Install OS instead of upgrade
install
# Use graphical install
graphical
# Firewall configuration
firewall --disabled
# 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-8

# Network information
network  --bootproto=dhcp --device=ens33 --activate
network  --hostname=localhost.localdomain
# Reboot after installation
reboot
# Use network installation
url --url="http://10.0.17.100/centos"
# Root password
rootpw --plaintext root
# SELinux configuration
selinux --enforcing
# System services
services --enabled="chronyd"
# System timezone
timezone Asia/Shanghai
user --name=noz --password=$6$R3b.LTR/NkobA1Sv$quYMCv3b6czowr6o6y9Yz53yg/DR9PSQxlUMJCD.GnbMewAPeFePAzL7pQQ4HEW.LdGjJw4OUnPCVWjg12UKV/ --iscrypted --gecos="noz"
# X Window System configuration information
xconfig  --startxonboot
# System bootloader configuration
bootloader --location=mbr --boot-drive=sda
# Clear the Master Boot Record
zerombr
# Partition clearing information
clearpart --none --initlabel
# Disk partitioning information
part /boot/efi --fstype="efi" --ondisk=sda --size=200 --fsoptions="umask=0077,shortname=winnt"
part /boot --fstype="xfs" --ondisk=sda --size=1024
part pv.304 --fstype="lvmpv" --ondisk=sda --size=19254
volgroup centos --pesize=4096 pv.304
logvol swap  --fstype="swap" --size=2047 --name=swap --vgname=centos
logvol /  --fstype="xfs" --grow --maxsize=51200 --size=1024 --name=root --vgname=centos

%post
sudo cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
cat >  /etc/yum.repos.d/CentOS-Base.repo << EOF  
[base]
name=CentOS-$releasever - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/os/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/os/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates 
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/updates/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/extras/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/centosplus/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
 
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/$releasever/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/$releasever/contrib/$basearch/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7
EOF
mkdir /etc/yum.repos.d/bak
mv /etc/yum.repos.d/C* /etc/yum.repos.d/bak
cat> /etc/yum.repos.d/local.repo << EOF
[local]
name=Local Repository
baseurl=http://10.0.17.100/centos
enabled=1
gpgcheck=0
EOF


sudo yum clean all
sudo yum makecache
reboot
%end

%packages
@base
@core
@development
chrony

%end

%addon com_redhat_kdump --disable --reserve-mb='auto'

%end

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
CentOS 7 PXE是指通过网络预引导环境(Preboot Execution Environment)来安装CentOS 7操作系统。具体步骤如下: 1. 首先,在PXE服务器上创建一个名为centos7的目录,并将vmlinuz和initrd.img文件复制到该目录中。这些文件可以从/var/www/html/centos7/images/pxeboot/目录下复制到/var/lib/tftpboot/centos7/目录中。 2. 在PXE服务器上设置syslinux加载器,这样可以将PXE引导文件与CentOS 7的安装文件关联起来。 3. 如果要通过MAC地址分配IP,可以编辑DHCP服务器的配置文件/etc/dhcp/dhcpd.conf,并在其中指定IP地址范围、网关等信息,并为每个客户端分配特定的IP地址和引导文件。 4. 完成以上步骤后,就可以使用PXE网络引导来安装CentOS 7了。在启动时,选择PXE引导选项并按照提示进行操作,即可开始安装CentOS 7操作系统。 总结来说,CentOS 7 PXE是通过网络预引导环境来实现在PXE服务器上安装CentOS 7操作系统。通过设置syslinux加载器和DHCP服务器配置文件,将PXE引导文件与CentOS 7的安装文件关联起来,并根据需要分配IP地址和引导文件给每个客户端。然后,通过选择PXE引导选项来启动并安装CentOS 7。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [CentOS 7 安装大全 之 PXE网络篇(CentOS系统)](https://blog.csdn.net/SQA_STAR/article/details/84029965)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值