Các bước thực hiện:
Install syslinux bootloaders
Install TFTP-Server and xinitd
Setup PXE Server Configuration File
Add CentOS 7 Boot Images to PXE Server
Install apche web-server
![](https://static.wixstatic.com/media/68165d_d8fd5a2f6c764b09a566b9dcf87a8985~mv2.png/v1/fill/w_709,h_375,al_c,q_85,enc_auto/68165d_d8fd5a2f6c764b09a566b9dcf87a8985~mv2.png)
Hệ thống của bạn có nhiều máy client dùng HĐH Linux, khi có yêu cầu cài lại máy, thay vì chúng ta phải cầm đĩa cài hay usb boot đến từng máy để cài thì ta tạo một menu boot cài HĐH trên server hoặc PC. Yêu cầu hệ thống phải có server làm DHCP, máy client có hỗ trợ boot network.
![](https://static.wixstatic.com/media/68165d_f5b4fce7ccf64a46825e34b6a5eb4dad~mv2.jpg/v1/fill/w_980,h_545,al_c,q_85,usm_0.66_1.00_0.01,enc_auto/68165d_f5b4fce7ccf64a46825e34b6a5eb4dad~mv2.jpg)
Trên CentOS 7
1. Install syslinux bootloaders
# yum install syslinux -y
![](https://static.wixstatic.com/media/68165d_f4d40c64d2b3403b9164a19f2481f590~mv2.png/v1/fill/w_643,h_343,al_c,q_85,enc_auto/68165d_f4d40c64d2b3403b9164a19f2481f590~mv2.png)
Tất cả các file pxe bootloader nằm trong /usr/share/syslinux
![](https://static.wixstatic.com/media/68165d_98eb86142db24429b2f467dc3146a036~mv2.png/v1/fill/w_640,h_258,al_c,q_85,enc_auto/68165d_98eb86142db24429b2f467dc3146a036~mv2.png)
2. Install TFTP-Server and xinitd
# yum install tftp-server xinitd -y
![](https://static.wixstatic.com/media/68165d_c067475fea414f599149a1911a8514d8~mv2.png/v1/fill/w_649,h_327,al_c,q_85,enc_auto/68165d_c067475fea414f599149a1911a8514d8~mv2.png)
Đường dẫn mặc định sau khi cài tftp-server: /var/lib/tftpboot/
Copy các file pxe bootloader vào tftp-server.
# cp -r /usr/share/syslinux/* /var/lib/tftpboot/
![](https://static.wixstatic.com/media/68165d_95bb11a4234040c1ba4d84cc0b951048~mv2.png/v1/fill/w_644,h_273,al_c,q_85,enc_auto/68165d_95bb11a4234040c1ba4d84cc0b951048~mv2.png)
Cấu hình file tftp trong xinetd.d
# vim /etc/xinetd.d/tftp
![](https://static.wixstatic.com/media/68165d_ab89cc652da04881877b802d4eec3207~mv2.png/v1/fill/w_690,h_363,al_c,q_85,enc_auto/68165d_ab89cc652da04881877b802d4eec3207~mv2.png)
Lưu ý:
disable = no : mặc định là yes ta chỉnh thành no
server_args = -s /var/lib/tftpboot : đường dẫn mặc định trỏ đến tftp-server, đường dẫn này sẽ chứa tất cả các file pxe bootloader. Có thể thay đường dẫn này bằng đường dẫn khác
3. Setup PXE Server Configuration File
Tạo thư mục pxelinux.cfg nằm trong /var/lib/tftpboot.
# cd /var/lib/tftpboot
# mkdir pxelinux.cfg
Tạo file default nằm trong pxelinux.cfg
# cd pxelinux.cfg
# vim default
default menu.c32
prompt 0
timeout 300
ONTIMEOUT local
menu title ########## PXE Boot Menu ##########
label 1
menu label ^1) Install CentOS 7 x64 with Local Repo
kernel centos7/vmlinuz
append initrd=centos7/initrd.img method=http://192.168.100.75/centos/7 devfs=nomount
Lưu ý:
kernel centos7/vmlinuz : đường dẫn chứa file vmlinux chúng ta sẽ tạo thư mục centos7 nằm trong tftp-server (/var/lib/tftpboot/).
initrd=centos7/initrd.img : đường dẫn chứa file initrd.img chúng ta sẽ tạo thư mục centos7 nằm trong tftp-server (/var/lib/tftpboot/).
method=http://192.168.100.75/centos/7 : Đường dẫn chứa source cài nằm trong web-server (apache web server chúng ta sẽ cài sau). Ta sẽ tạo hai thư mục centos/7 nằm trong /var/www/html/.
4. Add CentOS 7 Boot Images to PXE Server
Bỏ đĩa chứa source cài vào server hoặc file iso vào, sau đó tiến hành mount vào /mnt.
# mount -o loop /đường dẫn chứa file iso /mnt
![](https://static.wixstatic.com/media/68165d_e554459adc204ee3a37870fcff0b77cd~mv2.png/v1/fill/w_688,h_235,al_c,q_85,enc_auto/68165d_e554459adc204ee3a37870fcff0b77cd~mv2.png)
Tạo thư mục centos7 nằm trong tftpboot để chứa file vmlinuz và initrd.img.
# cd /var/lib/tftpboot/
# mkdir centos7
Copy 2 file vmlinuz và initrd.img trong source cài vào thư mục centos7(chúng ta đã mount vào /mnt/)
# cp /mnt/images/pxeboot/vmlinuz centos7/
# cp /mnt/images/pxeboot/initrd.img centos7/
5. Install apche web-server
# yum install httpd -y
Tạo thư mục chứa src cài nằm trong /var/www/html
# cd /var/www/html
# mkdir -p centos/7
Copy src cài đã mount đến /mnt vào thư mục đã tạo.
# cp -fr /mnt/* /var/www/html/centos/7/
# umount /mnt
Tạo file config trong httpd
# cd /etc/httpd/conf.d
# vi pxeboot.conf
![](https://static.wixstatic.com/media/68165d_57ce8a8c4621451596d7e4bf7f73132d~mv2.png/v1/fill/w_683,h_232,al_c,q_85,enc_auto/68165d_57ce8a8c4621451596d7e4bf7f73132d~mv2.png)
![](https://static.wixstatic.com/media/68165d_307a6cff96fb4c60a08bea34e0f69423~mv2.png/v1/fill/w_681,h_379,al_c,q_85,enc_auto/68165d_307a6cff96fb4c60a08bea34e0f69423~mv2.png)
6. Bật tắt các dịch vụ cần thiết
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl start xinetd
# systemctl enable xinetd
# systemctl start tftp
# systemctl enable tftp
# systemctl start httpd
# systemctl enable httpd
Trên DHCP Server
Vào option 66, string value: Nhập địa chỉ IP của PXE Server
![](https://static.wixstatic.com/media/68165d_e2f008aab50840ce83587706fed8c9c1~mv2.png/v1/fill/w_746,h_456,al_c,q_85,enc_auto/68165d_e2f008aab50840ce83587706fed8c9c1~mv2.png)
Vào option 67, string value: Nhập vào pxelinux.0
![](https://static.wixstatic.com/media/68165d_301b76fbdf514582b08eb972e7a865d9~mv2.png/v1/fill/w_735,h_457,al_c,q_85,enc_auto/68165d_301b76fbdf514582b08eb972e7a865d9~mv2.png)
Tiến hành boot từ máy client qua LAN chọn menu rồi ta tiến hành cài đặt HĐH Linux.
Kommentare