WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: How To HTTP PXE Boot  (Read 8430 times)

Offline gmc

  • Full Member
  • ***
  • Posts: 141
How To HTTP PXE Boot
« on: May 20, 2019, 02:57:41 AM »
Greetings,

I have been trying to PXE boot clients over HTTP in Tiny Core 10.0 and could not find simple, direct, clear instructions on how to do this anywhere on the Web.  I figured others might like to know just how easy it can be.  This short note will be of most help to those that already have a PXE server up and running using syslinux (pxelinux.0) and tftp.  If you don't have aWeb server set up yet you will also need to install something like apache or lightpd, etc.  And you will need to configure it to share out the netboot/tftpboot/pxeboot files.

To change from using tftp to serve up the boot files you will need to make two changes.  The first change is to whatever program you are using to serve pxelinux.0 to your PXE clients.  I am currently using dnsmasq.  For that I would edit /etc/dnsmasq.conf and change:

Code: [Select]
# The boot filename.
dhcp-boot=pxelinux.0

To:

Code: [Select]
# The boot filename.
dhcp-boot=lpxelinux.0

Note that the only change to dnsmasq.conf is the lower-case 'L' before 'pxelinux.0', which is now 'lpxelinux.0'.

Save the dnsmasq.conf file and restart dnsmasq.


For a typical tftp PXE setup you might have an entry like this in your 'default' file:

Code: [Select]
LABEL core1
MENU LABEL 0^1 - Tiny Core Linux 10.0 (base only)
KERNEL images/tc10/vmlinuz
APPEND quiet vga=786 initrd=images/tc10/core.gz

Now comes the easy part.  To change from using tftp to serve the two boot files, just add the URL of your web server that is sharing out the netboot/pxeboot/tftpboot files to the path.  Here is the same 'default' file snippet as above but with the URL added:

Code: [Select]
LABEL core1
MENU LABEL 0^1 - Tiny Core Linux 10.0 (base only)
KERNEL http://192.168.2.2:/images/tc10/vmlinuz
APPEND quiet vga=786 initrd=http://192.168.2.2:/images/tc10/core.gz

All that was added was the URL: http://192.168.2.2:/.  It doesn't get much easier than that!

I hope that this information proves useful to others.  Any corrections, improvements, observations, etc., would be welcome.

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: How To HTTP PXE Boot
« Reply #1 on: May 20, 2019, 09:01:02 AM »
Here's what I use to boot server VM's in ESXi. The virtual hard drives are data only, mounted at /srv. I have set the MAC addresses of the VMs in their configuration in ESXi so they will get the right files. What I like about having this type of server setup is when testing or if some process gets hung I can reboot it in less than a minute.

I'm using ISC dhcpd (to work with BIND), with a config file like this:

Code: [Select]
# dhcpd.conf
#
authoritative;

key DHCP_UPDATER {
        algorithm hmac-md5;
        secret "your-secret-bind-key-here";
}
zone asjohnson.com. {
        primary 192.168.3.2;
        key DHCP_UPDATER;
}
zone 168.192.in-addr.arpa. {
        primary 192.168.3.2;
        key DHCP_UPDATER;
}

subnet 192.168.3.0 netmask 255.255.255.0 {
        range 192.168.3.101 192.168.3.199;
        option domain-name "example.com";
        option domain-name-servers 192.168.3.6, 192.168.3.7;
        option routers 192.168.3.2;
        option broadcast-address 192.168.3.255;
        server-name "192.168.3.5";
        filename "pxelinux.0";
        default-lease-time 86400;
        max-lease-time 604800;
        ddns-updates on;
        ddns-update-style interim;
        ddns-ttl 30;
        one-lease-per-client on;
        ignore client-updates;
}


Start dhcpd in /opt/bootlocal like this:

Code: [Select]
/usr/local/sbin/dhcpd -cf /usr/local/etc/dhcpd.conf -lf /mnt/sda1/tce64/dhcpd.leases \
  -tf /var/log/dhcpd.log -pf /var/run/dhcpd.pid eth0 >>/var/log/dhcpd-sh.log 2>&1 &

Start the busybox tftp server in /opt/bootlocal:

Code: [Select]
/usr/bin/udpsvd -E 0 69 tftpd /opt/tftproot &

I use lighttpd for serving the extensions. Here is lighttpd.conf:

Code: [Select]
server.document-root = "/"
server.bind = "192.168.3.5"
server.port = 80
server.username = "nobody"
server.groupname = "nogroup"
server.chroot = "/mnt/sda1/tce"
server.upload-dirs = ( "/tmp" )

Start lighttpd in /opt/bootlocal:

Code: [Select]
/usr/local/sbin/lighttpd -D -m /usr/local/lib/lighttpd -f /usr/local/etc/lighttpd.conf &

In /opt/tftproot I have (not showing previous version cruft):

Code: [Select]
/opt/tftproot/pxelinux.cfg/default-boot/rootfs64-10.gz
/opt/tftproot/pxelinux.cfg/default-boot/vmlinuz64-10
/opt/tftproot/pxelinux.cfg/default-boot/modules64-10.gz
/opt/tftproot/pxelinux.cfg/default-boot/modules32-10.gz
/opt/tftproot/pxelinux.cfg/default-boot/rootfs32-10.gz
/opt/tftproot/pxelinux.cfg/default-boot/vmlinuz32-10
/opt/tftproot/pxelinux.cfg/default-boot/my-syslog-data.gz
/opt/tftproot/pxelinux.cfg/default-boot/my-www-data.gz
/opt/tftproot/pxelinux.cfg/default-boot/my-gw-data.gz
/opt/tftproot/pxelinux.cfg/01-00-50-56-03-06-01
/opt/tftproot/pxelinux.cfg/01-00-50-56-03-02-01
/opt/tftproot/pxelinux.cfg/01-00-50-56-03-11-01
/opt/tftproot/pxelinux.0

The boot file 01-00-50-56-03-06-01 for the web server I use to test apache and php on 32-bit has this:

Code: [Select]
DEFAULT pxe
LABEL pxe
KERNEL pxelinux.cfg/default-boot/vmlinuz32-10
INITRD pxelinux.cfg/default-boot/rootfs32-10.gz,pxelinux.cfg/default-boot/modules32-10.gz,pxelinux.cfg/default-boot/my-www-data.gz
APPEND host=www-vm printk.time=1 lang=en_US.UTF-8 cron rsyslog=192.168.3.11 quiet noswap nozswap nodhcp tce=/ httplist=192.168.3.5:/www.lst

Two things in this example are "my-www-data.gz" which is a cpio archive of the web server configuration files, functionally equivalent to the mydata.tgz file used by stock TC. The other is /www.lst, which is in the lighttpd root and has a list of extensions to load similar to onboot.lst, except that dependencies are not resolved so you must have all the dependent extensions in this file also.

Put the extensions you want to serve in /mnt/sda1/tce. You can create subdirectories in here for different TC versions so you can run 32-bit and 64-bit VMs at the same time, or upgrade them one at a time. Just remember to put the directory name before the extension name in the lst file:

Code: [Select]
tcz32-10/ipv6-4.19.10-tinycore.tcz
tcz32-10/glibc_gconv.tcz
tcz32-10/mylocale-en_US.UTF-8.tcz
tcz32-10/bash.tcz
tcz32-10/fuse.tcz
tcz32-10/glib2.tcz
tcz32-10/bzip2-lib.tcz
tcz32-10/libffi.tcz
tcz32-10/openssl.tcz
tcz32-10/ca-certificates.tcz
...

What the server needs to do when it starts is in my-www-data.gz archive, so you'll need to maintain one separately for each VM. They would be the same files as you would have in /opt/.filetool.lst. I maintain bind, apache, nginx, lighttpd and php along with a few other extensions fairly regularly to keep the security up to date. I use this setup for internet facing servers along with iptables and find them easier to maintain.

Offline gmc

  • Full Member
  • ***
  • Posts: 141
Re: How To HTTP PXE Boot
« Reply #2 on: May 20, 2019, 02:09:40 PM »
Awesome!  I feel like Dr. Einstein just walked in to my freshman Computers 101 class to give a lecture.  Someday maybe I can grow up to this level?  Nah, not gonna happen...

I am curious though, do you use Tiny Core for any of that process you listed above?

Offline andyj

  • Hero Member
  • *****
  • Posts: 1036
Re: How To HTTP PXE Boot
« Reply #3 on: May 20, 2019, 02:39:49 PM »
I use TC for all my servers (dhcp/bootp/tftp, dns, postgresql, apache, nginx, php, syslog) except for MS SQL server and Oracle where I use openSUSE Leap. The dhcp server has a virtual hard drive to boot itself. The rest use PXE.