Network-booting Flatcar Linux

Flatcar logo

You can use iPXE to boot into Flatcar Container Linux in order to run container payloads. You can control the behaviour of Flatcar Linux by providing an Ignition configuration file generated by the Butane utility in order to configure networking, register SSH keys, define the running container services, etc.

Boot script

Create an iPXE script file flatcar.ipxe containing:

#!ipxe

set mirror http://stable.release.flatcar-linux.net/amd64-usr/current
    
kernel ${mirror}/flatcar_production_pxe.vmlinuz flatcar.first_boot=1
initrd ${mirror}/flatcar_production_pxe_image.cpio.gz
initrd config.ign /usr/share/oem/config.ign mkdir=1
boot

If you have mirrored the Flatcar tree locally, then you should change the line

set mirror http://stable.release.flatcar-linux.net/amd64-usr/current

to point to the URI of your local mirror. Booting and installing from a local mirror will be several times faster than using the public stable.release.flatcar-linux.net mirror.

Flatcar configuration

Create a Butane configuration file config.yml containing:

variant: flatcar
version: 1.0.0

systemd:
  units:
    - name: nginx-demo.service
      enabled: true
      contents: |
        [Unit]
        Description=Minimal NGINX demo
        After=network-online.target
        Wants=network-online.target

        [Service]
        ExecStart=/usr/bin/docker run --rm -p 80:80 nginxdemos/hello
        Restart=always

        [Install]
        WantedBy=multi-user.target

This example configuration file will just run a simple Nginx demo container.

Compile your config.yml file to the Ignition configuration file config.ign:

butane --strict --output config.ign config.yml

Place your config.ign configuration file in the same directory as your flatcar.ipxe script.

Booting

Boot using iPXE from the URI of your flatcar.ipxe script, e.g. http://my.web.server/flatcar.ipxe. You should see iPXE download and boot into Flatcar Linux, which will then download and start the specified container:

Booting from flatcar.ipxe script

Flatcar Linux up and running

You can verify that the Nginx demo container is running inside Flatcar Linux by browsing to its IP address to see a basic status page:

Flatcar Linux running Nginx demo container

You can now try modifying (and recompiling) the config.yml file to run whatever container workloads you want. Congratulations on successfully network-booting into Flatcar Container Linux!

Success

howto/flatcar.txt ยท Last modified: 2025/02/24 16:42 by mcb30
Recent changes RSS feed CC Attribution-Share Alike 4.0 International Driven by DokuWiki
All uses of this content must include an attribution to the iPXE project and the URL https://ipxe.org
References to "iPXE" may not be altered or removed.