Tiny Core Linux

Tiny Core Extensions => TCE Tips & Tricks => Topic started by: gmc on May 19, 2019, 11:57:41 PM

Title: How To HTTP PXE Boot
Post by: gmc on May 19, 2019, 11:57:41 PM

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.


Code: [Select]
# The boot filename.

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)
APPEND quiet vga=786 initrd=

All that was added was the URL:  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.
Title: Re: How To HTTP PXE Boot
Post by: andyj on May 20, 2019, 06: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

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

subnet netmask {
        option domain-name "example.com";
        option domain-name-servers,;
        option routers;
        option broadcast-address;
        server-name "";
        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 = ""
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]

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]
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= quiet noswap nozswap nodhcp tce=/ httplist=

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]

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.
Title: Re: How To HTTP PXE Boot
Post by: gmc on May 20, 2019, 11:09:40 AM
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?
Title: Re: How To HTTP PXE Boot
Post by: andyj on May 20, 2019, 11:39:49 AM
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.