Pxe files - kernel, initrd


How to find out which files in /srv/tftp/boot directory belongs to which OS?

Depending on the Foreman version, those files will be named after the OS type name. E.g. Redhat-x86_64-7.7-initram.img for OS of the type “Redhat” architecture “x86_64” and version 7.7.

However if you have another OS of this same kind named differently “e.g. My RHEL 7.7”, then the file will be overwritten on every provisioning. Newer versions of Foreman add first 12 characters SHA1 hash of the installation media URL encoded in base64 so it will be two different names.

I think it would be easy to include Operating System database ID to the name, so it would read something like Redhat-12-x86_86-7.7-vmlinuz, or the whole operating system name instead like My_RHEL_7.7-vmlinuz. I slightly prefer the former one because people tend to create weird names to things.

When using Katello, this is completely overriden. Then the naming convention is Product name and Content View ID. We would like to change that however because on deployments with many promotions this create unnecessary amount of boot files as the CV ID increases.

1 Like

My names contain only mirror name and SHA1 hash.
It would be much easier to have something like “debian_9.9” in file name.

root@foreman-2-proxy-1:/srv/tftp/boot# ls -w1 *linu*

My current workaround is to do file command and google default kernel version for different distributions :slight_smile:

root@foreman-2-proxy-1:/srv/tftp/boot# file debian-mirror-*-linux | cut -d',' -f2
 version 4.9.0-11-amd64 (debian-kernel@lists.debian.org) #1 SMP Debian 4.9.189-3 (2019-09-02)
 version 3.16.0-6-amd64 (debian-kernel@lists.debian.org) #1 SMP Debian 3.16.56-1+deb8u1 (2018-05-08)
 version 4.19.0-6-amd64 (debian-kernel@lists.debian.org) #1 SMP Debian 4.19.67-2 (2019-08-28)

BTW; foreman doesn’t allow me to create same OS with identical major/minor numbers.

Oh you are right, what I described in my previous post was the previous behavior. Now the name is made of installation media name and SHA1 hash of the URL. Out of curiosity, why you need that? Foreman should manage PXE files for you.

I agree this is probably more confusing than it was (we occasionally saw incorrect OS entries but that was misconfiguration). We can put it back with planned refactoring Feature #26709: Rethink TFTP naming conventions for PXE files - Foreman

There was an error on debian mirror or somewhere in my squid, and i finished with wrong version of kernel and initrd and netinstall from that point failed.

Nevertheless, please confirm what I found:
It is always safe to delete this files, foreman will re-download latest version from mirror (installation media) if these files are missing (on next provisioning action)… In other words, if someone encounters a problem with debian netinstall kernel and initrd, it is safe to do: rm -rf /srv/tftp/boot/debian-mirror-* :slight_smile: )

Ehm, ehm. Yes, plus it will download with wget -c which means continue. If a file is refreshed on the server and bigger, it will actually append the rest and this will cause random issues (depending on the initramdisk data - weird stuff). Be aware, I always recommend to wipe out the TFTP directory. Exit and enter build mode to redownload TFTP files.

The issue I have linked actually aim to fix this problem.

I am having problems with this again. Now it is CentOS new minor release (7.7). I have deleted centos files from /srv/tftp/boot and let foreman to re-download. I have following problem:

Foreman initiated download of pxe files, but build started BEFORE download of this files finished, which led to host trying to boot partially downloaded kernel and crashed :frowning: … how can i avoid this situation?

You can’t avoid it, it’s a known issue and the solution is more complex and that’s the reason why we delay to fix so long. It’s just matter of resources to refactor everything. In the meantime, pick a faster mirror or add a delay to the PXELinux or Grub2 (timeout).

@lzap, anything changed here in 2.0 and later releases?
I am still on 1.23 … Is it a good time to upgrade? :smiley:

Nothing changes here, just make your timeout in your PXE template long enough so files gets downloaded.

Newer versions of Foreman add first 12 characters SHA1 hash of the installation media URL encoded in base64 so it will be two different names.

Can you please explain this in detail or point me to exact script which generates initrd and kernel file names like “debian-mirror-dgxKgBg5J79O-linux”.

I have tried to do something like:

echo "media_url" | sha1sum | base64 | cut -c1-12

but without success. I need a way to recreate names with my custom script.

If you dont use Katello then it is:

While if you use Katello there is a different provider (search the codebase for the same file/method).