top of page

HƯỚNG DẪN CÀI PXE SERVER TRÊN CENTOS 7 VỚI FTP

Writer's picture: Tuan NguyenTuan Nguyen

Updated: Aug 8, 2018

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 vsftpd


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.


Trên CentOS 7


1. Install syslinux bootloaders

# yum install syslinux -y

Tất cả các file pxe bootloader nằm trong /usr/share/syslinux



2. Install TFTP-Server and xinitd

# yum install tftp-server xinitd -y

Đườ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/

Cấu hình file tftp trong xinetd.d

# vim /etc/xinetd.d/tftp

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=ftp://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=ftp://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/ftp/pub/.

4. Add CentOS 7 Boot Images to PXE Server


Bỏ đĩa chứa scource 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

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 vmlinuzinitrd.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 vsftpd


# yum install vsftpd -y
# mkdir -p /var/ftp/pub/centos/7

Copy src cài đã mount đến /mnt vào thư mục đã tạo.

# cp -fr /mnt/* /var/ftp/ pub/centos/7/
# umount /mnt

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 vsftpd
# systemctl enable vsftpd

Trên DHCP Server


Vào option 66, string value: Nhập địa chỉ IP của PXE Server


Vào option 67, string value: Nhập vào pxelinux.0



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.

3 views0 comments

Comments


 

© 2018 by Tuấn Nguyễn

 Liên hệ tôi
  • Facebook - Black Circle
  • Google+ - Black Circle
bottom of page