<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>pxe &#8211; richliu&#039;s blog</title>
	<atom:link href="https://blog.richliu.com/tag/pxe/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.richliu.com</link>
	<description>Linux, 工作, 生活, 家人</description>
	<lastBuildDate>Fri, 23 Feb 2024 15:57:10 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.6.2</generator>
	<item>
		<title>Ubuntu/Fedora PXE Boot</title>
		<link>https://blog.richliu.com/2023/04/16/5181/ubuntu-fedora-pxe-boot/</link>
					<comments>https://blog.richliu.com/2023/04/16/5181/ubuntu-fedora-pxe-boot/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Sat, 15 Apr 2023 16:56:38 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[pxe]]></category>
		<category><![CDATA[pxeboot]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=5181</guid>

					<description><![CDATA[<p>Before setting up Ubuntu/Fedora PXE boot, it needs to p [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/04/16/5181/ubuntu-fedora-pxe-boot/">Ubuntu/Fedora PXE Boot</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>Before setting up Ubuntu/Fedora PXE boot, it needs to prepare several items on your PXE server:</p>



<ul class="wp-block-list">
<li>* The Ubuntu/Fedora rootfs on tftp/nfs server:<br />It can refer to the my article <a href="https://blog.richliu.com/2017/02/23/2098/mips_arm64_debian_ubuntu_debootstrap/" target="_blank" rel="noreferrer noopener">MIPS/ARM64 Debian/Ubuntu debootstrap</a> for building the Ubuntu rootfs. <br />If want to build the Fedora rootfs, it can install a new system on qemu and copy it from the qcow2 image.</li>
</ul>



<ul class="wp-block-list">
<li>* PXE Server:<br />You can refer my article  <a href="https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/" target="_blank" rel="noreferrer noopener">ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</a>  to build a PXE server.</li>
</ul>



<ul class="wp-block-list">
<li>NFS Server:<br /> Assume the rootfs for Ubuntu is on /nfs/ubuntu2204 and Fedora 36 is on /nfs/fedora36.</li>
</ul>



<span id="more-5181"></span>



<h2 class="wp-block-heading">Ubuntu PXE Boot</h2>



<p>Copy vmlinux and initramfs to tftp server. Copy your current system’s vmlinux to your tftpboot. For example, create a directory for Ubuntu 22.04 in /tftpboot/nfs/ubuntu2204, and copy the vmlinuz to the folder using the following command:</p>



<pre class="wp-block-preformatted">$ cp /boot/vmlinuz-$(uname -r) /tftpboot/nfs/ubuntu2204/vmlinuz</pre>



<p>Copy the initrd.img to the folder using the following command:</p>



<pre class="wp-block-preformatted">$ cp /boot/initrd.img-$(uname -r) /tftpboot/nfs/ubuntu2204/initrd.img</pre>



<p>Setup your PXE server’s grub.cfg and add a record. Use the following example for the record:</p>



<pre class="wp-block-preformatted">menuentry 'Ubuntu22.04 nfsboot' { 
    linux nfs/ubuntu2204/vmlinuz ip=dhcp root=/dev/nfs nfsroot=&lt;NFS server IP>:/nfs/ubuntu2204,nolock rw netboot=nfs 
    initrd nfs/ubuntu2204/initrd.img 
}
</pre>



<h2 class="wp-block-heading">Fedora PXE Boot</h2>



<p>The procedure is similar to Ubuntu, but the default Fedora initramfs doesn&#8217;t support nfs boot.<br />1. Rebuild the initramfs with dracut. You need to add nfs and network support to your Fedora initramfs using the following command:</p>



<pre class="wp-block-preformatted">$ dracut --add nfs --add network --force</pre>



<p>It will generate the same name vmlinuz and initramfs. Copy it to your directory just like Ubuntu.<br />2. Disable selinux. <br />Default Fedora selinux is enabled, but it cannot enable on nfs rootfs (or it can but needs to set up something). You can disable it by adding selinux=0 on boot kernel parameter. Use the following example for the record:</p>



<pre class="wp-block-preformatted">linux nfs/fedora36/vmlinuz boot=nfs root=/dev/nfs nfsroot=&lt;NFS server IP>:/nfs/fedora36,nolock rw netboot=nfs ip=dhcp selitarnux=0</pre>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2023/04/16/5181/ubuntu-fedora-pxe-boot/">Ubuntu/Fedora PXE Boot</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2023/04/16/5181/ubuntu-fedora-pxe-boot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</title>
		<link>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/</link>
					<comments>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/#respond</comments>
		
		<dc:creator><![CDATA[richliu]]></dc:creator>
		<pubDate>Wed, 08 Apr 2020 08:21:38 +0000</pubDate>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[ARM]]></category>
		<category><![CDATA[aarch64]]></category>
		<category><![CDATA[arm64]]></category>
		<category><![CDATA[centos8]]></category>
		<category><![CDATA[fedora]]></category>
		<category><![CDATA[pxe]]></category>
		<category><![CDATA[pxeboot]]></category>
		<category><![CDATA[ubuntu]]></category>
		<guid isPermaLink="false">https://blog.richliu.com/?p=4263</guid>

					<description><![CDATA[<p>This document will introduce how to setup a centos PXE  [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/">ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p>This document will introduce how to setup a centos PXE boot environment on ubuntu 18.04 for install centos8 to your ARM64 machine. <br /><br />In this document, it uses CentOS 8 version is 8.1.1911, it might also work on later version if you change file name accordingly .&nbsp;<br /><br />all command in this document we assume you already run with root permission.&nbsp;<br /></p>



<span id="more-4263"></span>



<h2 class="wp-block-heading">Hardware topology&nbsp;</h2>



<p>[ARM64 CLIENT] &lt;&#8212;&#8212;-&gt; [Server]&nbsp; &lt;&#8212;&#8212;-&gt; Internet&nbsp;</p>



<p>SERVER ethernet ip is 10.0.0.1 , another interface connect to internet.&nbsp;</p>



<p></p>



<h2 class="wp-block-heading">Install necessary packages&nbsp;<br /></h2>



<p>Install TFTP, HTTP and DHCPD Server and rpm2cpio&nbsp;<br /></p>



<p>$ apt install tftpd-hpa apache2 isc-dhcp-server rpm2cpio<br /></p>



<h2 class="wp-block-heading">Modify dhcpd server configuration&nbsp;<br /></h2>



<p>$ vim /etc/dhcp/dhcpd.conf<br /></p>



<p>following is example configuration,it can be changed to fit your environment&nbsp;</p>



<pre class="wp-block-verse">authoritative;
default-lease-time&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 259200;
max-lease-time&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 518400;
option routers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 10.0.0.1;
option subnet-mask&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 255.255.255.0;
option domain-name-servers&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 168.95.1.1,8.8.8.8;
ddns-update-style &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; interim;
ignore client-updates;
allow booting;
allow bootp;
allow unknown-clients;
server-name &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; pxis;

subnet 10.0.0.0 netmask 255.255.255.0 {
&nbsp;&nbsp;&nbsp;&nbsp;range 10.0.0.100 10.0.0.200;
&nbsp;&nbsp;&nbsp;&nbsp;option ip-forwarding off;
&nbsp;&nbsp;&nbsp;&nbsp;option subnet-mask&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 255.255.255.0;
&nbsp;&nbsp;&nbsp;&nbsp;next-server 10.0.0.1;
&nbsp;&nbsp;&nbsp;&nbsp;filename "shim.efi";

}</pre>



<h2 class="wp-block-heading">Modify tftpd setting&nbsp;<br /></h2>



<p>$ vim /etc/default/tftpd-hpa<br /></p>



<p>Add &#8211;create to TFTP_OPTIONS and change tftp directory to /tftpboot&nbsp;<br /></p>



<p>following is example configuration file&nbsp;</p>



<pre class="wp-block-preformatted">TFTP_USERNAME="tftp"<br />TFTP_DIRECTORY="/tftpboot"<br />TFTP_ADDRESS=":69"<br />TFTP_OPTIONS="--secure&nbsp; --create"</pre>



<h2 class="wp-block-heading">Restart Service&nbsp;<br /></h2>



<pre class="wp-block-preformatted">mkdir /tftpboot&nbsp;
/etc/init.d/tftpd-hpa restart
/etc/init.d/apache2 restart
/etc/init.d/isc-dhcp-server restart
</pre>



<h2 class="wp-block-heading">Get ARM64 pxeboot file&nbsp;</h2>



<p>some times the shim and grub2-efi would be erase, just visit mirror.centos.org and find new one than download it. </p>



<pre class="wp-block-preformatted">cd /tftpboot&nbsp;
wget http://mirror.centos.org/centos/8-stream/BaseOS/aarch64/os/Packages/shim-aa64-15-15.el8_2.aarch64.rpm
wget http://mirror.centos.org/centos/8-stream/BaseOS/aarch64/os/Packages/grub2-efi-aa64-2.02-106.el8.aarch64.rpm
rpm2cpio shim-aa64-15-15.el8_2.aarch64.rpm | cpio -dimv
rpm2cpio grub2-efi-aa64-2.02-106.el8.aarch64.rpm | cpio -dimv
cp ./boot/efi/EFI/centos/shim.efi .
cp ./boot/efi/EFI/centos/grubaa64.efi .
chmod +rx *.efi</pre>



<h2 class="wp-block-heading">Configure grub.conf&nbsp;<br /></h2>



<p>$ vim /tftpboot/grub.cfg<br /></p>



<p>Following is grub.conf example&nbsp;</p>



<pre class="wp-block-verse">set timeout=60<br />menuentry 'CentOS' {<br /> &nbsp;linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/<br />&nbsp;&nbsp;initrd images/pxeboot/initrd.img<br />}</pre>



<p>If your system support secure boot and you want to do it, please replace linux with linuxefi and replace initrd with initrdefi.&nbsp;</p>



<h2 class="wp-block-heading">Get CentOS 8 stream image and copy it to web server&nbsp;</h2>



<pre class="wp-block-preformatted">cd /var/www/html&nbsp;
wget <a href="https://mirror01.idc.hinet.net/centos/8-stream/isos/aarch64/CentOS-Stream-8-aarch64-20211202-dvd1.iso" target="_blank" rel="noopener">http://ftp.twaren.net/Linux/CentOS/8-stream/isos/x86_64/CentOS-Stream-8-x86_64-20220215-dvd1.iso</a>
mkdir disk&nbsp;
mount -o loop CentOS-Stream-8-x86_64-20220215-dvd1.iso disk
cp -a disk centos8&nbsp;
umount disk&nbsp;
rmdir disk

# copy boot file into tftp directory </pre>



<p>cd /tftpboot<br />cp /var/www/html/centos8/images/ . -a<br /></p>



<p>After copy all file into http file directory, it can visit via browser on server with URL <a href="http://10.0.0.1/centos8/">http://10.0.0.1/centos8/</a> to check whether file exist or not.&nbsp;<br /></p>



<h2 class="wp-block-heading">NAT<br /></h2>



<p>Server should support NAT function to forward packet.&nbsp;<br /><br />assume interface connect to internet is wls3 <br />Following is a sample command to enable Linux NAT function which can make client to access internet or intranet .&nbsp;</p>



<p>$ echo 1 &gt; /proc/sys/net/ipv4/ip_forward ==&gt; enable it immediately&nbsp;<br />$ iptables -t nat -A POSTROUTING -o wls3 -j MASQUERADE</p>



<p></p>



<p>Now, you can choose pxeboot on your ARM64 machine. if everything successful, you can see CentOS on your console if everything is ok .&nbsp;<br /></p>



<h2 class="wp-block-heading">Known Issue</h2>



<h3 class="wp-block-heading">Stdin: Invalid argument</h3>



<p>My system cannot boot into the Ubuntu install program for an unknown reason. After checking the system, it seems that the issue may be caused by an inability to access internet resources for some reason, even though the DNS and network appear to be fine. An alternative solution is to put the ISO on a website and assign the argument to the parameter. Here is an example using Ubuntu 22.04.</p>



<pre class="wp-block-preformatted">menuentry 'Ubuntu22.04 Net Install' {<br />linux ubuntu2204/vmlinuz ip=dhcp url=http://10.0.0.1/ubuntu-22.04.1-live-server-arm64.iso only-ubiquity<br />initrd ubuntu2204/initrd<br />}</pre>



<h2 class="wp-block-heading">Debug&nbsp;<br /></h2>



<p>Wireshark is your good friend, use it.&nbsp;<br /></p>



<h2 class="wp-block-heading">Ubuntu PXE Environment</h2>



<p>It can download Ubuntu Netboot images from this url. <br /> <a href="http://cdimage.ubuntu.com/netboot/" target="_blank" rel="noopener">http://cdimage.ubuntu.com/netboot/</a> <br /><br />Choice what you want, for example, url below is Ubuntu 18.04 for ARM64 image<br /> <a href="http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/" target="_blank" rel="noopener">http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/</a> <br />Ubuntu 20.04 Netboot file <br />http://ports.ubuntu.com/ubuntu-ports/dists/focal-updates/main/installer-arm64/current/legacy-images/netboot/netboot.tar.gz</p>



<p><br />Download netboot image to tftp directory, I prefer to put different version to different directory. </p>



<pre class="wp-block-code"><code>$ cd /tftpboot
$ wget http://ports.ubuntu.com/ubuntu-ports/dists/bionic-updates/main/installer-arm64/current/images/netboot/netboot.tar.gz
$ mkdir ubuntu1804
$ cd ubuntu1804
$ tar xvf ../netboot.tar.gz</code></pre>



<p>Modify grub.cfg and add Ubuntu option to grub.cfg, save it, now, this server can also provide ubuntu net install</p>



<pre class="wp-block-code"><code>set timeout=60
menuentry 'CentOS8 Install' {
  linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/
  initrd images/pxeboot/initrd.img
}
menuentry 'Ubuntu18.04 Install' {
  linux ubuntu1804/ubuntu-installer/arm64/linux ip=dhcp
  initrd ubuntu1804/ubuntu-installer/arm64/initrd.gz
}
</code></pre>



<h2 class="wp-block-heading">Ubuntu ISO environment </h2>



<p>It can download iso file and use the iso file as install media. <br /><br />in Linux, download Ubuntu 20.04 ARM64 iso file</p>



<pre class="wp-block-preformatted">$ wget https://cdimage.ubuntu.com/releases/20.04/release/ubuntu-20.04.3-live-server-arm64.iso
$ mount -o loop ubuntu-20.04.3-live-server-arm64.iso disk
$ mkdir ubuntu2004
$ cp disk/casper ubuntu2004/ -a 
$ umount disk</pre>



<p>Modify grub.cfg as below (not test)</p>



<pre class="wp-block-preformatted">set timeout=60
menuentry 'CentOS8 Install' {
  linux images/pxeboot/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/centos8/
  initrd images/pxeboot/initrd.img
}
menuentry 'Ubuntu20.04 Install' {
  linux ubuntu2004/casper/vmlinuz ip=dhcp
  initrd ubuntu2004/casper/initrd
}
</pre>



<p>It also can use HWE kernel </p>



<pre class="wp-block-preformatted">menuentry 'Ubuntu20.04 Install' {
  linux ubuntu2004/casper/hwe-vmlinux ip=dhcp
  initrd ubuntu2004/casper/hwe-initrd
}

</pre>



<h2 class="wp-block-heading">Note for GRUB Install Command</h2>



<h2 class="wp-block-heading">CentOS</h2>



<pre class="wp-block-preformatted">svr=10.0.0.1; root=boot/centos8/images/pxeboot
linux (http,$svr)/$root/vmlinuz inst.stage2=http://$svr/boot/centos8 text
initrd (http,$svr)/$root/initrd.img
</pre>



<h2 class="wp-block-heading">Ubuntu</h2>



<pre class="wp-block-preformatted">svr=192.168.110.254; root=boot/ubuntu2004/casper
iso=ubuntu-20.04.3-live-server-arm64.iso
linux (http,$svr)/$root/vmlinuz url=http://192.168.110.254/boot/$iso only-ubiquity ip=dhcp ---
initrd (http,$svr)/$root/initrd

linux (http,$svr)/$root/hwe-vmlinuz url=http://192.168.110.254/boot/$iso only-ubiquity ip=dhcp ---
initrd (http,$svr)/$root/hwe-initrd

</pre>



<h2 class="wp-block-heading">Fedora 36</h2>



<p>Fedora&#8217;s setting is more closed to CentOS, due to CentOS might be dropped recently, so, moved to Fedora environment is necessary. </p>



<h3 class="wp-block-heading">Get initrd/vmlinux image</h3>



<p>Other parts like CentOS, <br />Download the PXE initrd and vmlinuz image, free.nchc.org.tw is Taiwan local Fedora server, you can replace it with local server. </p>



<pre class="wp-block-preformatted">mkdir -p /tftpboot/f36

cd /tftpboot/f36
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/os/images/pxeboot/initrd.img
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/os/images/pxeboot/vmlinuz

cd /var/www/html
wget http://free.nchc.org.tw/fedora/linux/releases/36/Server/aarch64/iso/Fedora-Server-dvd-aarch64-36-1.5.iso
mkdir disk 
mount -o loop Fedora-Server-dvd-aarch64-36-1.5.iso disk
cp -a disk f36
umount disk</pre>



<h3 class="wp-block-heading">Grub Fedora Setting</h3>



<p>Add following grub entry text into /tftpboot/grub.cfg, thus, it can insert a &#8220;Fedora36&#8221; menu on pxe boot.</p>



<pre class="wp-block-preformatted">menuentry 'Fedora36' {
  linux f36/vmlinuz ip=dhcp inst.repo=http://10.0.0.1/f36/
  initrd f36/initrd.img
}
</pre>



<p>Ref.&nbsp;</p>



<p><a href="https://docs.centos.org/en-US/centos/install-guide/pxe-server/#sect-network-boot-setup-uefi" target="_blank" rel="noopener">https://docs.centos.org/en-US/centos/install-guide/pxe-server/#sect-network-boot-setup-uefi</a><br /><a href="https://docs.centos.org/en-US/8-docs/advanced-install/assembly_preparing-for-a-network-install/" target="_blank" rel="noopener">https://docs.centos.org/en-US/8-docs/advanced-install/assembly_preparing-for-a-network-install/</a><br /><a href="https://forums.opensuse.org/showthread.php/501075-error-cannot-find-commands-linuxefi-or-initrdefi" target="_blank" rel="noopener">https://forums.opensuse.org/showthread.php/501075-error-cannot-find-commands-linuxefi-or-initrdefi</a></p>
<p>The post <a rel="nofollow" href="https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/">ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server</a> appeared first on <a rel="nofollow" href="https://blog.richliu.com">richliu&#039;s blog</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://blog.richliu.com/2020/04/08/4263/arm64-centos8-pxe-boot/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
