How to remotely install linux on pxe

Source: Internet
Author: User
Pxe Remote Installation of linux system-Linux Enterprise Application-Linux server application information. The following is a detailed description. Today, I went to the data center with my colleagues to install the hard disk and split the machine. I found that the SCSI line was not long enough to connect to only one hard disk. it seems that the old hard disk can only be replaced with a new hard disk, but the new hard disk is not equipped with any CD, and the operating system cannot be installed on the new hard disk. Colleagues say they can go back and use PXE to remotely install the system. I have some knowledge about PXE before, but I have never practiced it. I checked the following information online:

Basic Principles

1) What is PXE?
PXE (Pre-boot Execution Environment) is a protocol designed by Intel that enables computers to start over the network. The Protocol is divided into two ends: client and server. The PXE client is in the ROM of the NIC. When the computer boots, the BIOS transfers the PXE client to the memory for execution and displays the command menu. After the user selects the client, the PXE client downloads the operating system on the remote end to the local computer for running.
To successfully run the PXE protocol, you must solve the following two problems:

A. Since it is transmitted over the network, who will configure the IP address of the computer when it is started;

B. protocols used to download the Linux kernel and the root file system

The first problem can be solved through the DHCP Server. The DHCP server assigns an IP address to the PXE client. The DHCP Server is a protocol used to dynamically allocate IP addresses to the DHCP Client, however, because the IP address is assigned to the PXE Client, you need to add a specific PXE configuration When configuring the DHCP Server.
As for the second problem, TFTP client already exists in the ROM where the PXE Client is located. PXE Client uses the TFTP Client to download the required files to the TFTP Server through the TFTP protocol.
In this way, the conditions for running the PXE protocol are met. Let's take a look at the working process of the PXE protocol.
2) Work Process




In, PXE client is a computer that requires Linux installation. TFTP Server and DHCP Server run on another Linux Server. The Bootstrap file, configuration file, Linux kernel, and Linux root file system are all stored in the root directory of the TFTP Server on Linux Server.
The PXE client requires three binary files: bootstrap, Linux kernel, and Linux root file system. The Bootstrap file is an executable program that provides you with a simple control interface and downloads the appropriate Linux kernel and Linux root file system based on your selections.

The specific configuration process is as follows:
First install the necessary services, DHCPD, TFTP-SERVER, NFS (usually by default)
Both dhcpd and tftp-server have the corresponding rpm, which can be directly installed.
# Vi/etc/xinetd. d/tftp
======================= =============
Service tftp
{
Disable = no (the default value is yes. Change it to no here to enable it)
Socket_type = dgram
Protocol = udp
Wait = yes
User = root
Server =/usr/sbin/in. tftpd
Server_args =-u nobody-s/tftpboot //-s indicates that/tftpboot is used as the root directory of the tftp directory.
Per_source = 11
CPIs = 100 2
Flags = IPv4
}
Tftp is started by xinted. After modification, remember service xinetd restart.
# Vi/etc/dhcpd. conf
======================= =============
Ddns-update-style interim;
Ignore client-updates;
Default-lease-time 21600;
Max-lease-time 43200;
Authourtative;
Next-server 192.168.1.103;
Subnet 192.168.1.0 netmask 255.255.255.0 {
Option routers 192.168.1.1;
Option subnet-mask limit 255.0;
Range 192.168.1.1 192.168.1.100;
Default-lease-time 21600;
Max-lease-time 43200;
Filename "/pxelinux.0 ";
Option domain-name-servers 202.106.0.20;
}
Pxelinux.0 is the bootstrap mentioned above. The root directory of tftp has been specified, so the relative path is used here.
Next-server 192.168.1.103; I did not add this statement at the beginning. When the machine to install the system is started, find pxelinux. the configuration file in the cfg directory cannot be found. after a long wait, a boot: prompt appears, telling me: can't load kernel image: linux. At first it was thought to be/tftpboot/pxelinux. the configuration file of cfg/default is incorrect. Check whether the file is correct.
After google for half a day, I finally found a Post saying that it may be a dhcp3.0 bug. I need to add this parameter to specify the IP address of the DHCP SERVER. after modifying the configuration file to add this sentence, restart dhcp and restart the client. This time, the speed is greatly accelerated and passes smoothly.
3. Support for PXE
# Mkdir/tftpboot
# Cp/usr/lib/syslinux/pxelinux.0/tftpboot
Install/image/pxeboot/initrd on the first installation disc of LINUX. img, vmlinuz, and isolinux /*. msg:/tftpboot directory (*. msg can also be copied, with emphasis on initrd. img and vmlinuz cannot be booted without the kernel)
# Cd/tftpboot
# Mkdir pxelinux. cfg
# Vi defaultdefault centos5
Prompt 1
Timeout 30
Label centos5
Kernel vmlinuz
Append ks = nfs: 192.168.1.103:/root/inst/ks initrd = initrd. img devfs = nomount ramdisk_size = 9216
# Append initrd = initrd. img devfs = nomount ramdisk_size = 9216


The ks = nfs: 192.168.1.103:/root/inst/ks file specifies the kickstart configuration file, which can be automatically installed according to the preset parameters without manual intervention during installation. the installation process is fully automated.
4. Configure the NFS service
# Vi/etc/exports
/Root/inst 192.168.1.0/24 (ro, sync) // here is/root/inst instead of/root/inst/
# Mkdir/home/iso
Copy and install the linux iso file to this directory.
5. system services to be enabled
/Dhcpd/network/nfs/portmap/syslog/tftp/xinetd/
Service dhcpd start
Service portmap start
Service nfs start
Finally, the content of the ks file is attached.
Install
Nfs -- server = 192.168.1.103 -- dir =/root/inst
Lang en_US.UTF-8
Keyboard us
Network -- device eth0 -- bootproto static -- ip 192.168.1.220 -- netmask 255.255.255.0 -- gateway 192.168.1.1 -- nameserver 192.168.1.1
# Network -- device eth0 -- bootproto DHCP
Rootpw -- iscrypted $1 $ WvFbqnpm $ m94fa4AopXI/kfYOYbWMW.
Firewall -- enabled -- port = 22: tcp
# Firewall -- disabled
Authconfig -- enableshadow -- enablemd5
Selinux -- disabled
Timezone -- utc Asia/Shanghai
Bootloader -- location = mbr -- driveorder = sda -- append = "rhgb quiet"
Clearpart -- all
Zerombr yes
Clearpart -- linux -- initlabel
Part/boot -- fstype ext2 -- size = 256
Part/-- fstype ext3 -- size = 8192
Part/opt -- fstype ext3 -- size = 8192
Part/usr -- fstype ext3 -- size = 16384
Part swap -- size = 4096
Part/home -- fstype ext3 -- size = 1 -- grow
Reboot // after this line is added, the system can be automatically restarted after the system is installed. Note that the Starting sequence of the machine cannot be the NIC priority; otherwise, the system will be installed cyclically ........
% Packages -- resolvedeps
@ Everything
Grub
Kernel
Kernel-devel
E2fsprogs

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.