1、dhcp服務 1) 分配地址 2) 指明tftp server的地址 next-server
2、檔案共用服務 用於共用對應安裝光碟中所有檔案 支援ftp, nfs, http
3、tftp服務 簡單檔案傳輸協定 udp/69 提供選單、vmlinuz內核、initrd.img初始化映象檔案
4、syslinux pxelinux.0 用於接收各種引導
[root@localhost ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 500M 0 part /boot
└─sda2 8:2 0 19.5G 0 part
├─centos-root 253:0 0 17.5G 0 lvm /
└─centos-swap 253:1 0 2G 0 lvm [SWAP]
sdb 8:16 0 50G 0 disk
sr0 11:0 1 4G 0 rom
[root@localhost ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
root@localhost ~]# vgextend centos /dev/sdb
Volume group "centos" successfully extended
[root@localhost ~]# lvextend -L +40G /dev/centos/root
Size of logical volume centos/root changed from <17.47 GiB (4472 extents) to <57.47 GiB (14712 extents).
Logical volume centos/root successfully resized.
root@localhost ~]# xfs_growfs /dev/centos/root
meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=1144832 blks
= sectsz=512 attr=2, projid32bit=1
= crc=0 finobt=0 spinodes=0
data = bsize=4096 blocks=4579328, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=0
log =internal bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
data blocks changed from 4579328 to 15065088
root@localhost ~]# yum install dhcp vsftpd tftp‐server xinetd syslinux ‐y
root@localhost ~]#systemctl stop firewalld
root@localhost ~]#setenforce 0
FTP服務主要提供系統安裝檔案共用服務
1.在服務的目錄下建立共用的系統資料夾Centos
[root@localhost ~]# cd /var/ftp/
[root@localhost ftp]# ls
pub
[root@localhost ftp]# mkdir Centos7
[root@localhost ftp]# ls
Centos7 pub
2.掛載Centos的系統光碟,並將裏面的所有檔案拷貝到剛剛建立的Centos目錄下
[root@localhost ftp]# cd
[root@localhost ~]# mkdir mnt
[root@localhost ~]# ls
anaconda-ks.cfg mnt
[root@localhost ~]# mount /dev/sr0 ./mnt/
mount: /dev/sr0 is write-protected, mounting read-only
[root@localhost ~]# ls ./mnt/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
[root@localhost ~]# cp -r ./mnt/* /var/ftp/Centos7/
[root@localhost ~]# ls /var/ftp/Centos7/
CentOS_BuildTag EULA images LiveOS repodata RPM-GPG-KEY-CentOS-Testing-7
EFI GPL isolinux Packages RPM-GPG-KEY-CentOS-7 TRANS.TBL
3.啓動FTP服務嘗試存取FTP檔案
[root@localhost ~]# systemctl start vsftpd
提供選單、內核、初始化映象檔案
1.將安裝光碟isolinux檔案目錄下的有關內核,選單,初始映象的檔案拷貝到/var/lib/tftpboot/下
[root@localhost ~]# cp ./mnt/isolinux/* /var/lib/tftpboot/
[root@localhost ~]# ls /var/lib/tftpboot/
boot.cat grub.conf isolinux.bin memtest TRANS.TBL vesamenu.c32
boot.msg initrd.img isolinux.cfg splash.png upgrade.img vmlinuz
2.將pxelinux.0通過tftp共用出去
[root@localhost ~]# cp /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
3.編輯安裝選單
[root@localhost ~]# mkdir /var/lib/tftpboot/pxelinux.cfg
[root@localhost ~]# cp ./mnt/isolinux/isolinux.cfg /var/lib/tftpboot/pxelinux.cfg/default
[root@localhost ~]# ls /var/lib/tftpboot/pxelinux.cfg/
default
[root@localhost ~]# vim /var/lib/tftpboot/pxelinux.cfg/default
61 label CentOS 7
62 menu label Install CentOS 7
63 kernel vmlinuz
64 append initrd=initrd.img inst.stage2=ftp://192.188.1.1/CentOS7 inst.repo=ftp://192.168.1.1/CentOS7
關鍵詞 | 說明 |
---|---|
kernel | 對應內核的儲存位置,相對路徑;相對於tftp預設數據目錄 |
append | 對應初始化映象檔案的儲存位置 |
inst.stage2 | 指定系統安裝檔案儲存位置 |
inst.repo | 指定軟體的儲存位置 |
4.啓動tftp服務
[root@localhost ~]# vim /etc/xinetd.d/tftp
14 disable = no
[root@localhost ~]# systemctl start xinetd
修改DHCP服務設定
[root@localhost ~]# vim /etc/dhcp/dhcpd.conf
27 subnet 192.168.1.0 netmask 255.255.255.0 {
28 range 192.168.1.100 192.168.1.200;
29 option routers 192.168.1.2;
30 option domain-name-servers 114.114.114.114,202.106.0.20;
31 next-server 192.168.1.1;
32 filename "pxelinux.0";
[root@localhost ~]# systemctl start dhcpd
1.注意測試機最小記憶體2GB