Netboot Alpine Linux using iPXE: Difference between revisions
m (Fix typo in ipxeboot network name) |
(use mediawiki syntax instead of html) |
||
Line 1: | Line 1: | ||
== Copy the files needed by iPXE to a web server == | |||
< | * For this guide we will provide the files at http://ipxe-boot.example.com/ from the directory <code>/var/www/ixpe-boot.example.com/</code> on the web server, which is writable by your non-root admin user. We also assume the web server follows symlinks within <code>/var/www/ipxe-boot.example.com</code> (but not outside that directory tree). | ||
* Copy the netboot tarball (for example the [https://dl-cdn.alpinelinux.org/alpine/v3.16/releases/x86_64/alpine-netboot-3.16.0-x86_64.tar.gz 3.16.0 stable release of Alpine's netboot image for x86_64]) to your non-root admin user on your web server. | |||
* Extract the netboot tarball to your webserver directory. For example: | |||
{{Cmd|tar -C /var/www/ipxe-boot.example.com -xzf alpine-netboot-3.16.0-x86_64.tar.gz}} | |||
* This will create a directory structure such as: | |||
<pre>boot/ | <pre>boot/ | ||
Line 26: | Line 21: | ||
boot/vmlinuz-lts</pre> | boot/vmlinuz-lts</pre> | ||
== Create an iPXE boot script == | |||
For example, create a script called {{Path|boot.ipxe}} with contents: | |||
{{Cat|boot.ipxe|#!ipxe | |||
set base-url http://ipxe-boot.example.com | set base-url http://ipxe-boot.example.com | ||
kernel ${base-url}/boot/vmlinuz-virt console=tty0 modules=loop,squashfs quiet nomodeset alpine_repo=https://dl-cdn.alpinelinux.org/alpine/v3.16/main modloop=http://ipxe-boot.example.com/boot/modloop-virt | kernel ${base-url}/boot/vmlinuz-virt console{{=}}tty0 modules{{=}}loop,squashfs quiet nomodeset alpine_repo{{=}}https://dl-cdn.alpinelinux.org/alpine/v3.16/main modloop{{=}}http://ipxe-boot.example.com/boot/modloop-virt | ||
initrd ${base-url}/boot/initramfs-virt | initrd ${base-url}/boot/initramfs-virt | ||
boot | boot | ||
}} | |||
== Boot using the iPXE boot script == | |||
=== Using QEMU (for testing) === | |||
Assuming you have the binary <code>qemu-system-x86_64</code> on your system: | |||
< | {{Cmd|<nowiki>qemu-system-x86_64 -boot n -m 512M -enable-kvm -device virtio-net,netdev=n1 -netdev user,id=n1,tftp=$(pwd),bootfile=/boot.ipxe</nowiki>}} | ||
=== Using Libvirt === | |||
* Copy the {{Path|boot.ipxe}} script to your webserver at {{Path|/var/www/ipxe-boot.example.com/boot.ipxe}} (substituting for your actual directory, of course). | |||
* Create a new NAT network with XML such: | |||
<pre><network> | <pre><network> | ||
<name>ipxeboot</name> | <name>ipxeboot</name> | ||
Line 68: | Line 60: | ||
</network></pre> | </network></pre> | ||
* Use <code>virt-install</code> such as: | |||
{{Cmd|<nowiki>virt-install -n vm-name --memory 512 --vcpus 1 --pxe --disk size=5,bus=virtio --network network=ipxeboot,model=virtio --input tablet --video virtio --os-variant id=http://alpinelinux.org/alpinelinux/3.13</nowiki>}} | |||
=== On Vultr.com === | |||
<em>NOTE</em>: Other cloud providers have similar features, but I haven't used them. | |||
[https://www.vultr.com/docs/ipxe-boot-feature/ iPXE Boot Feature - Vultr.com] | |||
== See Also == | |||
* [https://boot.alpinelinux.org/ Alpine linux netboot server] | |||
Revision as of 18:25, 25 August 2023
Copy the files needed by iPXE to a web server
- For this guide we will provide the files at http://ipxe-boot.example.com/ from the directory
/var/www/ixpe-boot.example.com/
on the web server, which is writable by your non-root admin user. We also assume the web server follows symlinks within/var/www/ipxe-boot.example.com
(but not outside that directory tree). - Copy the netboot tarball (for example the 3.16.0 stable release of Alpine's netboot image for x86_64) to your non-root admin user on your web server.
- Extract the netboot tarball to your webserver directory. For example:
tar -C /var/www/ipxe-boot.example.com -xzf alpine-netboot-3.16.0-x86_64.tar.gz
- This will create a directory structure such as:
boot/ boot/initramfs-lts boot/config-virt boot/dtbs-virt/ boot/System.map-lts boot/vmlinuz-virt boot/System.map-virt boot/config-lts boot/initramfs-virt boot/modloop-lts boot/modloop-virt boot/dtbs-lts/ boot/vmlinuz-lts
Create an iPXE boot script
For example, create a script called boot.ipxe with contents:
Contents of boot.ipxe
#!ipxe
set base-url http://ipxe-boot.example.com
kernel ${base-url}/boot/vmlinuz-virt console=tty0 modules=loop,squashfs quiet nomodeset alpine_repo=https://dl-cdn.alpinelinux.org/alpine/v3.16/main modloop=http://ipxe-boot.example.com/boot/modloop-virt
initrd ${base-url}/boot/initramfs-virt
boot
Boot using the iPXE boot script
Using QEMU (for testing)
Assuming you have the binary qemu-system-x86_64
on your system:
qemu-system-x86_64 -boot n -m 512M -enable-kvm -device virtio-net,netdev=n1 -netdev user,id=n1,tftp=$(pwd),bootfile=/boot.ipxe
Using Libvirt
- Copy the boot.ipxe script to your webserver at /var/www/ipxe-boot.example.com/boot.ipxe (substituting for your actual directory, of course).
- Create a new NAT network with XML such:
<network> <name>ipxeboot</name> <forward mode="nat"> <nat> <port start="1024" end="65535"/> </nat> </forward> <bridge name="virbr1" stp="on" delay="0"/> <mac address="52:54:00:a4:10:b3"/> <domain name="ipxeboot"/> <ip address="192.168.129.1" netmask="255.255.255.0"> <dhcp> <range start="192.168.129.128" end="192.168.129.254"/> <bootp file="http://ipxe-boot.example.com/boot.ipxe"/> </dhcp> </ip> </network>
- Use
virt-install
such as:
virt-install -n vm-name --memory 512 --vcpus 1 --pxe --disk size=5,bus=virtio --network network=ipxeboot,model=virtio --input tablet --video virtio --os-variant id=http://alpinelinux.org/alpinelinux/3.13
On Vultr.com
NOTE: Other cloud providers have similar features, but I haven't used them. iPXE Boot Feature - Vultr.com