Skip to content

Instantly share code, notes, and snippets.

@neofob
Forked from rikka0w0/pxe_tftp_openwrt.md
Created February 21, 2025 02:04
Show Gist options
  • Save neofob/60b8200ccab5de0b3143f09edd3c053b to your computer and use it in GitHub Desktop.
Save neofob/60b8200ccab5de0b3143f09edd3c053b to your computer and use it in GitHub Desktop.

Revisions

  1. @rikka0w0 rikka0w0 revised this gist Jan 12, 2020. 1 changed file with 3 additions and 15 deletions.
    18 changes: 3 additions & 15 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -30,40 +30,28 @@ apt install tftpd-hpa
    (nothing, they are identical)
    ```

    # 5. Download Ubuntu NetBoot

    ```
    cd /srv/tftp
    wget -r --no-parent --reject="index.html*" "http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/"
    mv archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/* .
    ls
    ```
    ```
    boot.img.gz ldlinux.c32 mini.iso netboot.tar.gz pxelinux.0 pxelinux.cfg ubuntu-installer xen
    ```

    # 6. Setup NFS server
    # Setup NFS server
    ```
    sudo apt install nfs-kernel-server
    echo "/srv/nfs 192.168.0.0/16(async,no_root_squash,no_subtree_check,ro)" >> /etc/exports
    systemctl restart nfs-kernel-server.service
    ```

    # 7. Mount ISO image
    # Mount ISO image
    ```
    sudo mkdir /mnt/ubuntu_18_desktop_iso
    sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs/
    ```

    # 8. Prepare Live Boot files
    # Add a Ubuntu LiveCD entry
    ```
    mkdir /srv/tftp/casper
    cp /srv/nfs/casper/initrd /srv/tftp/casper
    cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
    ```

    # 9. Add LiveCD entry
    Append to `/srv/tftp/ubuntu-installer/amd64/boot-screens`
    ```
    label live
  2. @rikka0w0 rikka0w0 revised this gist Jan 6, 2020. 1 changed file with 3 additions and 0 deletions.
    3 changes: 3 additions & 0 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -88,6 +88,9 @@ systemctl restart nfs-kernel-server
    systemctl restart tftpd-hpa.service
    ```

    # Delete these files to save some space
    `rm -rf boot.img.gz netboot.tar.gz xen`

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
  3. @rikka0w0 rikka0w0 revised this gist Jan 6, 2020. 1 changed file with 7 additions and 4 deletions.
    11 changes: 7 additions & 4 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -66,18 +66,21 @@ cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
    # 9. Add LiveCD entry
    Append to `/srv/tftp/ubuntu-installer/amd64/boot-screens`
    ```
    label ubuntudesktop
    menu label Ubuntu Desktop 18.04 Live
    kernel casper/vmlinuz
    append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
    label live
    menu label Ubuntu Desktop 18.04 Live
    menu default
    kernel casper/vmlinuz
    append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
    ```
    Replace `default install ` with `default live`, delete `menu default` under `label install`. This only controls which menu item is selected by default.

    # 10. Add timeout to the boot menu
    In `/srv/tftp/pxelinux.cfg/default` (NOT `/srv/tftp/ubuntu-installer/amd64/pxelinux.cfg/default`), replace `timeout 0` with:
    ```
    timeout 50
    ONTIMEOUT live
    ```
    This controls the timeout action.

    # Restart NFS / TFTP server:
    ```
  4. @rikka0w0 rikka0w0 revised this gist Jan 6, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -63,7 +63,8 @@ cp /srv/nfs/casper/initrd /srv/tftp/casper
    cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
    ```

    # 9. Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
    # 9. Add LiveCD entry
    Append to `/srv/tftp/ubuntu-installer/amd64/boot-screens`
    ```
    label ubuntudesktop
    menu label Ubuntu Desktop 18.04 Live
  5. @rikka0w0 rikka0w0 revised this gist Jan 6, 2020. 1 changed file with 7 additions and 0 deletions.
    7 changes: 7 additions & 0 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -71,6 +71,13 @@ label ubuntudesktop
    append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
    ```

    # 10. Add timeout to the boot menu
    In `/srv/tftp/pxelinux.cfg/default` (NOT `/srv/tftp/ubuntu-installer/amd64/pxelinux.cfg/default`), replace `timeout 0` with:
    ```
    timeout 50
    ONTIMEOUT live
    ```

    # Restart NFS / TFTP server:
    ```
    systemctl restart nfs-kernel-server
  6. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -63,14 +63,20 @@ cp /srv/nfs/casper/initrd /srv/tftp/casper
    cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
    ```

    # 8. Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
    # 9. Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
    ```
    label ubuntudesktop
    menu label Ubuntu Desktop 18.04 Live
    kernel casper/vmlinuz
    append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
    ```

    # Restart NFS / TFTP server:
    ```
    systemctl restart nfs-kernel-server
    systemctl restart tftpd-hpa.service
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
  7. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -53,7 +53,14 @@ systemctl restart nfs-kernel-server.service
    ```
    sudo mkdir /mnt/ubuntu_18_desktop_iso
    sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs
    ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs/
    ```

    # 8. Prepare Live Boot files
    ```
    mkdir /srv/tftp/casper
    cp /srv/nfs/casper/initrd /srv/tftp/casper
    cp /srv/nfs/casper/vmlinuz /srv/tftp/casper
    ```

    # 8. Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
  8. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 3 additions and 2 deletions.
    5 changes: 3 additions & 2 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -61,12 +61,13 @@ ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs
    label ubuntudesktop
    menu label Ubuntu Desktop 18.04 Live
    kernel casper/vmlinuz
    append nfsroot = 192.168.1.150:/var/www/html/desktop/bionic netboot=nfs ro file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz systemd.mask=tmp.mount --
    append nfsroot=192.168.x.x:/srv/nfs netboot=nfs boot=live boot=casper initrd=/casper/initrd systemd.mask=tmp.mount --
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
    3. https://wiki.debian.org/PXEBootInstall
    4. Another solution, https://forum.openwrt.org/t/solved-dhcp-config-pxe-boot-from-external-tftp-server/5880/2
    5. Openwrt doc, https://openwrt.org/docs/guide-user/base-system/dhcp
    5. Openwrt doc, https://openwrt.org/docs/guide-user/base-system/dhcp
    6. Ubuntu Live PXE, http://c-nergy.be/blog/?p=13243
  9. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 8 additions and 0 deletions.
    8 changes: 8 additions & 0 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -56,6 +56,14 @@ sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs
    ```

    # 8. Append to /srv/tftp/ubuntu-installer/amd64/boot-screens
    ```
    label ubuntudesktop
    menu label Ubuntu Desktop 18.04 Live
    kernel casper/vmlinuz
    append nfsroot = 192.168.1.150:/var/www/html/desktop/bionic netboot=nfs ro file=/cdrom/preseed/ubuntu.seed boot=casper initrd=/casper/initrd.lz systemd.mask=tmp.mount --
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
  10. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -52,8 +52,8 @@ systemctl restart nfs-kernel-server.service
    # 7. Mount ISO image
    ```
    sudo mkdir /mnt/ubuntu_18_desktop_iso
    sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso
    sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso /srv/nfs
    ```

    Reference:
  11. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 6 additions and 1 deletion.
    7 changes: 6 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -49,7 +49,12 @@ echo "/srv/nfs 192.168.0.0/16(async,no_root_squash,no_subtree_check,ro)" >> /etc
    systemctl restart nfs-kernel-server.service
    ```


    # 7. Mount ISO image
    ```
    sudo mkdir /mnt/ubuntu_18_desktop_iso
    sudo mount -o loop ubuntu-18.04.3-desktop-amd64.iso
    ln -s /mnt/ubuntu_18_desktop_iso
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
  12. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 10 additions and 1 deletion.
    11 changes: 10 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,7 @@ apt install tftpd-hpa
    (nothing, they are identical)
    ```

    # 5 Download Ubuntu NetBoot
    # 5. Download Ubuntu NetBoot

    ```
    cd /srv/tftp
    @@ -42,6 +42,15 @@ ls
    boot.img.gz ldlinux.c32 mini.iso netboot.tar.gz pxelinux.0 pxelinux.cfg ubuntu-installer xen
    ```

    # 6. Setup NFS server
    ```
    sudo apt install nfs-kernel-server
    echo "/srv/nfs 192.168.0.0/16(async,no_root_squash,no_subtree_check,ro)" >> /etc/exports
    systemctl restart nfs-kernel-server.service
    ```



    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
  13. @rikka0w0 rikka0w0 revised this gist Jan 4, 2020. 1 changed file with 12 additions and 0 deletions.
    12 changes: 12 additions & 0 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -29,6 +29,18 @@ apt install tftpd-hpa
    # diff test /srv/tftp/test
    (nothing, they are identical)
    ```

    # 5 Download Ubuntu NetBoot

    ```
    cd /srv/tftp
    wget -r --no-parent --reject="index.html*" "http://archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/"
    mv archive.ubuntu.com/ubuntu/dists/bionic-updates/main/installer-amd64/current/images/netboot/* .
    ls
    ```
    ```
    boot.img.gz ldlinux.c32 mini.iso netboot.tar.gz pxelinux.0 pxelinux.cfg ubuntu-installer xen
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
  14. @rikka0w0 rikka0w0 revised this gist Jan 3, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -34,4 +34,5 @@ Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
    3. https://wiki.debian.org/PXEBootInstall
    4. Another solution:https://forum.openwrt.org/t/solved-dhcp-config-pxe-boot-from-external-tftp-server/5880/2
    4. Another solution, https://forum.openwrt.org/t/solved-dhcp-config-pxe-boot-from-external-tftp-server/5880/2
    5. Openwrt doc, https://openwrt.org/docs/guide-user/base-system/dhcp
  15. @rikka0w0 rikka0w0 revised this gist Jan 3, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -33,4 +33,5 @@ apt install tftpd-hpa
    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
    3. https://wiki.debian.org/PXEBootInstall
    3. https://wiki.debian.org/PXEBootInstall
    4. Another solution:https://forum.openwrt.org/t/solved-dhcp-config-pxe-boot-from-external-tftp-server/5880/2
  16. @rikka0w0 rikka0w0 revised this gist Jan 3, 2020. 1 changed file with 25 additions and 4 deletions.
    29 changes: 25 additions & 4 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -2,14 +2,35 @@ In this configuration, DHCP will run on the OpenWrt Box, while the TFTP server (

    # 1. Add to `/etc/config/dhcp` on OpenWrt Box

    ```config boot linux
    option filename 'pxelinux.0'
    ```
    config boot linux
    option filename 'pxelinux.0'
    option serveraddress '192.168.?.?'
    option servername '?'
    ```
    # 2. Restart DHCP server
    # 2. Restart DHCP server on OpenWrt Box
    `/etc/init.d/dnsmasq restart`

    # 3. Install TFTP server on another computer
    ```
    apt install tftpd-hpa
    # vi /etc/default/tftpd-hpa
    # systemctl status tftpd-hpa
    # systemctl restart tftpd-hpa
    ```

    # 4. Test TFTP server (Optional)
    ```
    # cd /tmp
    # uname -a >/srv/tftp/test
    # tftp 192.168.0.2
    tftp> get test
    tftp> quit
    # diff test /srv/tftp/test
    (nothing, they are identical)
    ```

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
    3. https://wiki.debian.org/PXEBootInstall
  17. @rikka0w0 rikka0w0 revised this gist Jan 3, 2020. 1 changed file with 6 additions and 3 deletions.
    9 changes: 6 additions & 3 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -1,11 +1,14 @@
    In this configuration, DHCP will run on the OpenWrt Box, while the TFTP server (the one serves the boot files) runs on a different computer.

    # 1. Add to `/etc/config/dhcp` on OpenWrt Box

    `config boot linux
    ```config boot linux
    option filename 'pxelinux.0'
    option serveraddress '192.168.?.?'
    option servername '?'
    `
    # 2. `` and `/etc/init.d/dnsmasq restart`
    ```
    # 2. Restart DHCP server
    `/etc/init.d/dnsmasq restart`

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
  18. @rikka0w0 rikka0w0 revised this gist Jan 3, 2020. 1 changed file with 4 additions and 2 deletions.
    6 changes: 4 additions & 2 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    1. Add to `/etc/config/dhcp` on OpenWrt Box
    # 1. Add to `/etc/config/dhcp` on OpenWrt Box

    `config boot linux
    option filename 'pxelinux.0'
    option serveraddress '192.168.?.?'
    option servername '?'
    `
    # 2. `` and `/etc/init.d/dnsmasq restart`

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/
    2. TFTP boot, https://openwrt.org/docs/guide-user/base-system/dhcp_configuration
  19. @rikka0w0 rikka0w0 created this gist Jan 3, 2020.
    10 changes: 10 additions & 0 deletions pxe_tftp_openwrt.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    1. Add to `/etc/config/dhcp` on OpenWrt Box

    `config boot linux
    option filename 'pxelinux.0'
    option serveraddress '192.168.?.?'
    option servername '?'
    `

    Reference:
    1. https://stelfox.net/blog/2013/12/configuring-pxe-booting-on-openwrt/