search
HomeOperation and MaintenanceCentOSTeach you to install Centos system through the network

下面由centos入门教程栏目给大家介绍通过网络安装Centos系统的方法,希望对需要的朋友有所帮助!

一、基础:

  PXE(Pre-bootExecution Environment),预启动执行环境,运行在Client/Server的工作模式; 

  PXE Client会调用网际协议(IP)、用户数据报协议(UDP)、动态主机设定协议(DHCP)、小型文件传输协议(TFTP)等网络协议。

  PXE Client存放在网卡的ROM 中。当计算机引导时,BIOS 把 PXE Client 调入内存中执行,PXE BootROM(自启动芯片)会发送一个UDP广播请求,向本网络中的DHCP服务器索取IP。

PXE的工作过程:

  PXE协议运行的详细工作流程,请参考以下图文描述:

  1. PXE Client 从自己的PXE网卡启动,向本网络中的DHCP服务器请求IP;

  2. DHCP 服务器返回分配给客户机的IP 以及PXE文件的放置位置(该文件一般是放在一台TFTP服务器上) ;

  3. PXE Client 向本网络中的TFTP服务器索取pxelinux.0 文件(在 PXE Client 的 ROM 中,已经存在 TFTP Client);

  4. PXE Client 取得pxelinux.0 文件后之执行该文件;

  5. 根据pxelinux.0 的执行结果,通过TFTP服务器加载内核和文件系统 ;

  6. 进入安装画面, 此时可以通过选择HTTP、FTP、NFS 方式之一进行安装;

   

二、涉及软件安装及配置(syslinux、DHCP服务器、TFTP服务器、File server)

  1、syslinux

    通过网络引导Linux的引导文件是pxelinux.0,这个文件由syslinux程序提供。SYSLINUX is a suite of bootloaders。

    通过yum install syslinux安装程序后,使用rpm -ql syslinux查看文件的时候,竟然没有显示pxelinux.0这个文件,以为自己安装程序的问题,后来才发现只是未显示而已,文件还是在/usr/share/syslinux/目录下,使用ls /usr/share/syslinux/就可以看到了。

    将pxelinux.0复制到tftp目录: ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/

  2、将安装光盘images/pxeboot/目录下的initrd.img、vmlinuz复制到tftp目录:cp images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot

    复制isolinux目录下的三个文件至tftp目录:mnt]# cp isolinux/{boot.cat,vesamenu.c32,splash.jpg} /var/lib/tftpboot/

    注:经验证boot.cat、splash.jpg可以不用复制;boot.cat不复制不影响启动,splash.jpg不复制显示菜单的时候没有背景图片(如下图)。 

                     

    但是vesamenu.c32文件必须要有,不然会报找不到该文件的错误

          

    在/var/lib/tftpboot/下创建pxelinux.cfg:mnt]# mkdir /var/lib/tftpboot/pxelinux.cfg

    将isolinux/isolinux.cfg复制到 /var/lib/tftpboot/pxelinux.cfg目录下并命令为default:mnt]# cp isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default

   3、dhcp   

      subnet 172.16.0.0 netmask 255.255.0.0 {
              range 172.16.100.151 172.16.100.170;
              option routers 172.16.100.67;
              filename "pxelinux.0";
              next-server 172.16.100.67;
      }

  4、然后启动虚拟机,就可以显示熟悉的安装引导菜单了。(连接不是tftp服务器,检查服务是否有开,iptables和selinux)

三、全自动通过http安装Centos

以下内容为我整理的流程图,从图中可以看出pxelinux.0的文件功能相当于bootloader和isolinux.bin的集成版。

 

 1、修改default,增加一项ks;如果想在菜单项时间短一些,可以修改timeout时间。

label ks
  menu label ^Install system based ks
  menu default
  kernel vmlinuz
  append initrd=initrd.img 
text ks=http://172.16.100.67/ks.cfg
label linux
  menu label ^Install or upgrade an existing system
  kernel vmlinuz
  append initrd=initrd.img

2、修改ks.cfg文件,指定从http服务器加载安装程序

# Kickstart file automatically generated by anaconda.
#version=DEVELinstall#cdromurl --url=http://172.16.100.67/centos6.6/lang en_US.UTF-8keyboard usnetwork --onboot no --device eth0 --bootproto dhcp --noipv6rootpw  --iscrypted $6$3.bn6KZ9zigMQq.Z$V/Q8xF2asfM8KCWm6GsjhYBvTTmMM6B50i6A/AFFx38xkg1sP2kL.ECBAda4SLwG6itOZhLXG/41sgRCJBLf11firewall --service=sshauthconfig --enableshadow --passalgo=sha512selinux --enforcingtimezone --utc Asia/Shanghaibootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"# The following is the partition information you requested# Note that any partitions you deleted are not expressed# here so unless you clear all partitions first, this is# not guaranteed to workclearpart --all
part /boot --fstype=ext4 --size=200part / --fstype=ext4 --size=7000part swap --size=2000
#repo --name="CentOS"  --baseurl=cdrom:repodata/ --cost=100reboot%packages --nobase@core%end

3、开启dchpd、tftpd、httpd,关闭iptable、selinux,就可以完成自动安装了。

后续:

在安装的时候出现一个问题,提示this device may need to be reinitialized。

 

解决方法:

在ks文件中增加zeromb就可以了,#号这一行,可有可无,不影响。

# Clear the Master Boot Record
 zeromb

配置修改为:

url --url=http://172.16.100.67/centos6.6/
lang en_US.UTF-8
keyboard us
network --onboot no --device eth0 --bootproto dhcp --noipv6
rootpw  --iscrypted $6$3.bn6KZ9zigMQq.Z$V/Q8xF2asfM8KCWm6GsjhYBvTTmMM6B50i6A/AFFx38xkg1sP2kL.ECBAda4SLwG6itOZhLXG/41sgRCJBLf11
firewall --service=ssh
authconfig --enableshadow --passalgo=sha512
selinux --enforcing
timezone --utc Asia/Shanghai
bootloader --location=mbr --driveorder=sda --append="crashkernel=auto rhgb quiet"
zerombr
PEX部分内容来自于:https://www.cnblogs.com/sunhongleibibi/archive/2017/11/17/7851382.html

The above is the detailed content of Teach you to install Centos system through the network. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:cnblogs. If there is any infringement, please contact admin@php.cn delete
CentOS: A Community-Driven Linux DistributionCentOS: A Community-Driven Linux DistributionApr 17, 2025 am 12:03 AM

CentOS is a stable, enterprise-grade Linux distribution suitable for server and enterprise environments. 1) It is based on RedHatEnterpriseLinux and provides a free, open source and compatible operating system. 2) CentOS uses the Yum package management system to simplify software installation and updates. 3) Support advanced automation management, such as using Ansible. 4) Common errors include package dependency and service startup issues, which can be solved through log files. 5) Performance optimization suggestions include the use of lightweight software, regular cleaning of the system and optimization of kernel parameters.

What Comes After CentOS: The Road AheadWhat Comes After CentOS: The Road AheadApr 16, 2025 am 12:07 AM

Alternatives to CentOS include RockyLinux, AlmaLinux, OracleLinux, and SLES. 1) RockyLinux and AlmaLinux provide RHEL-compatible binary packages and long-term support. 2) OracleLinux provides enterprise-level support and Ksplice technology. 3) SLES provides long-term support and stability, but commercial licensing may increase costs.

CentOS: Exploring the AlternativesCentOS: Exploring the AlternativesApr 15, 2025 am 12:03 AM

Alternatives to CentOS include UbuntuServer, Debian, Fedora, RockyLinux, and AlmaLinux. 1) UbuntuServer is suitable for basic operations, such as updating software packages and configuring the network. 2) Debian is suitable for advanced usage, such as using LXC to manage containers. 3) RockyLinux can optimize performance by adjusting kernel parameters.

Centos shutdown command lineCentos shutdown command lineApr 14, 2025 pm 09:12 PM

The CentOS shutdown command is shutdown, and the syntax is shutdown [Options] Time [Information]. Options include: -h Stop the system immediately; -P Turn off the power after shutdown; -r restart; -t Waiting time. Times can be specified as immediate (now), minutes ( minutes), or a specific time (hh:mm). Added information can be displayed in system messages.

Difference between centos and ubuntuDifference between centos and ubuntuApr 14, 2025 pm 09:09 PM

The key differences between CentOS and Ubuntu are: origin (CentOS originates from Red Hat, for enterprises; Ubuntu originates from Debian, for individuals), package management (CentOS uses yum, focusing on stability; Ubuntu uses apt, for high update frequency), support cycle (CentOS provides 10 years of support, Ubuntu provides 5 years of LTS support), community support (CentOS focuses on stability, Ubuntu provides a wide range of tutorials and documents), uses (CentOS is biased towards servers, Ubuntu is suitable for servers and desktops), other differences include installation simplicity (CentOS is thin)

Centos configuration IP addressCentos configuration IP addressApr 14, 2025 pm 09:06 PM

Steps to configure IP address in CentOS: View the current network configuration: ip addr Edit the network configuration file: sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0 Change IP address: Edit IPADDR= Line changes the subnet mask and gateway (optional): Edit NETMASK= and GATEWAY= Lines Restart the network service: sudo systemctl restart network verification IP address: ip addr

How to install centosHow to install centosApr 14, 2025 pm 09:03 PM

CentOS installation steps: Download the ISO image and burn bootable media; boot and select the installation source; select the language and keyboard layout; configure the network; partition the hard disk; set the system clock; create the root user; select the software package; start the installation; restart and boot from the hard disk after the installation is completed.

Centos8 restarts sshCentos8 restarts sshApr 14, 2025 pm 09:00 PM

The command to restart the SSH service is: systemctl restart sshd. Detailed steps: 1. Access the terminal and connect to the server; 2. Enter the command: systemctl restart sshd; 3. Verify the service status: systemctl status sshd.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Chat Commands and How to Use Them
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment