湖濱散記部落格的樹心幽徑[login][主頁]
480:20190208用client的PXE連接Linux Fedora 28 NFS Server進行網路開機成功

續:20190207Boot Asus-Notbook from FC28 NetBoot Server ok

(0)伺服端cpu

$ lscpu
架構:               x86_64

Model name:          Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz

(1)安裝 tftp server 以支援無硬碟主機用有PXE功能的網路卡來進行網路開機:

(1-1)$ sudo dnf install -y tftp-server

(1-2) $ sudo firewall-cmd --add-service=tftp --permanent
success

(1-3) $ sudo firewall-cmd --reload
success

(1-4) $  sudo systemctl enable tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.

(1-5) $  sudo systemctl restart tftp

(1-6) $ sudo dnf install -y tftp

(1-7) $  echo "hello" | sudo tee /var/lib/tftpboot/hello.txt
hello

(1-8) $ cat /var/lib/tftpboot/hello.txt
hello

(1-9) $ echo "get hello.txt" | tftp 127.0.0.1
tftp> get hello.txt
tftp>

$ cat hello.txt
hello

(2)安裝 dhcp server 以支援完全無硬碟主機的netboot:

(2-1)$ sudo dnf install -y dhcp

(2-2)$ sudo firewall-cmd --add-service=dhcp --permanent
success

(2-3)$ sudo firewall-cmd --reload
success

(2-4)$ sudo systemctl enable dhcpd
Created symlink /etc/systemd/system/multi-user.target.wants/dhcpd.service → /usr/lib/systemd/system/dhcpd.service.

(2-5)$  sudo systemctl restart dhcpd
Job for dhcpd.service failed because the control process exited with error code.
See "systemctl status dhcpd.service" and "journalctl -xe" for details.

(2-6)設定讓筆電可用網卡的mac位址10:7B:44:33:59:6F自dhcp server租用取得ip:192.168.1.4 及pxelinux.0

$ sudo vi  /etc/dhcp/dhcpd.conf

$ sudo cat  /etc/dhcp/dhcpd.conf

default-lease-time 600;
max-lease-time 7200;
allow booting;
allow bootp;

subnet 192.168.1.0 netmask 255.255.255.0 {
  option domain-name "home.idv.tw";
  option domain-name-servers 192.168.1.1, 163.25.20.1;
  option routers 192.168.1.1;
}

host client03 {
  hardware ethernet 2c:56:dc:27:bb:05;

  next-server     192.168.1.103;

  fixed-address 192.168.1.3;
  option host-name "client03.home.idv.tw";
}
host client04 {
  hardware ethernet 10:7B:44:33:59:6F;

 next-server     192.168.1.103;

 filename "pxelinux.0";

  fixed-address 192.168.1.4;
  option host-name "client04.home.idv.tw";
}


(2-7)$ sudo systemctl restart dhcpd

$ ps ax|grep dhcp
 9104 ?        Ss     0:00 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid
 9115 pts/0    S+     0:00 grep --color=auto dhcp

(3)安裝syslinux來取用pxelinux

(3-1) $ sudo dnf install syslinux

(3-2) $ sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg

(3-3) $ sudo cp /usr/share/syslinux/{pxelinux.0,vesamenu.c32,ldlinux.c32,libcom32.c32,libutil.c32} /var/lib/tftpboot/

(3-4) $ sudo dnf install shim grub2-efi --installroot=/tmp/fedora --releasever 28

(3-5) $ sudo  mkdir -p /var/lib/tftpboot/uefi

(3-6) $ sudo cp /tmp/fedora/boot/efi/EFI/fedora/{shim.efi,grubx64.efi} /var/lib/tftpboot/uefi/
cp: 無法 stat '/tmp/fedora/boot/efi/EFI/fedora/grubx64.efi': 沒有此一檔案或目錄

(3-7) $ sudo ls /tmp/fedora/boot/efi/EFI/fedora
BOOT.CSV  BOOTX64.CSV  grubia32.efi  loader  mmx64.efi    MokManager.efi    shim.efi  shimx64.efi  shimx64-fedora.efi

(4)製作pxelinux的開機設定檔

(4-1) $ sudo vi /var/lib/tftpboot/pxelinux.cfg/default

(4-2) $ sudo cat /var/lib/tftpboot/pxelinux.cfg/default
default vesamenu.c32
prompt 1
timeout 600

label linux
menu label ^Boot Fedora 28 64-bit
menu default

 kernel linux/vmlinuz-4.19.16-200.fc28.x86_64 root=nfs4:192.168.1.103:/fc28 console=tty0 console=ttyS0,115200n8 audit=0 selinux=0
append initrd=linux/initramfs-4.19.16-200.fc28.x86_64.img ip=dhcp

label local
menu label Boot from ^local drive
localboot 0xffff

(5)自$HOME/esp/linux拷取Boot用的vmlinuz及initramfs 到/var/lib/tftpboot

esp目錄內容請參考文章:建立EFI系統分割所需的目錄樹及檔案

(5-1) $ sudo cp  -r $HOME/esp/linux /var/lib/tftpboot/

(5-2) $ tree /var/lib/tftpboot

/var/lib/tftpboot

├── hello.txt
├── ldlinux.c32
├── libcom32.c32
├── libutil.c32
├── linux
│   ├── boot.cfg(用不上了)
│   ├── initramfs-4.19.16-200.fc28.x86_64.img
│   └── vmlinuz-4.19.16-200.fc28.x86_64
├── pxelinux.0
├── pxelinux.cfg
│   └── default
├── uefi
│   └── shim.efi
└── vesamenu.c32

3 directories, 11 files

(6)在用戶端機器的BIOS設定選取pxe來開機

:

Realtek PCEe GBE Family Controller Series v2.53....


DHCP取得ip:192.168.1.4


PXELINUX 6.04 PXE ....

:

(7) asus-notebook A 開機成功,抓圖如下:(用戶端ip:192.168.1.4、伺服端ip:192.168.1.103)

alt

(8) asus-notebook B 開機成功,抓圖如下:(用戶端ip:192.168.1.3、伺服端ip:192.168.1.103)

alt

(9)asus-PC  開機成功,抓圖如下:(用戶端ip:10.10.10.208、伺服端ip:10.10.10.100)

alt


 

(10)asus-PC  開機成功,抓圖如下:(用戶端ip:10.10.10.201、伺服端ip:10.10.10.100)

alt

 

 

REF 1: https://docs.fedoraproject.org/en-US/fedora/f29/install-guide/advanced/Network_based_Installations/

REF 0:https://fedoramagazine.org/how-to-build-a-netboot-server-part-1/

 


select id,article_id,topic,text from lt_articles_text where article_id =480; ok. update lt_articles set num_reads=num_reads +1 where id=480; ok.