|
| 1 | +# Azure Linux Image Customizer PXE Support |
| 2 | + |
| 3 | +## PXE Overview |
| 4 | + |
| 5 | +Booting a host with an OS served over the network is one of the most popular |
| 6 | +methods for booting baremetal hosts. It requires no physical access to individual |
| 7 | +hosts and also centralizes the deployment configuration to a single server. |
| 8 | + |
| 9 | +One way of enabling such setup is using the PXE (Preboot eXecution Environment) |
| 10 | +Boot protocol. The user can setup a server with all the OS artifacts, a DHCP |
| 11 | +endpoint, and a tftp connection endpoint. When a client machine is powered on, |
| 12 | +and its firmware will look for a DHCP server on the same network and find the |
| 13 | +one configured by the user. |
| 14 | + |
| 15 | +The DHCP server will serve information about the tftp endpoint to the client, |
| 16 | +and the client firmware can then proceed with retrieving the OS artifacts over |
| 17 | +tftp, then loading them into memory, and finally handing control over to the |
| 18 | +loaded OS. |
| 19 | + |
| 20 | +The tftp protocol expects certain artifacts to be present on the server: |
| 21 | + |
| 22 | +- the boot loader (the shim and something like grub). |
| 23 | +- the boot loader configuration (like grub.cfg). |
| 24 | +- the kernel image. |
| 25 | +- the initrd image. |
| 26 | + |
| 27 | +Once retrieved, the boot loader is run. Then the boot loader reads the |
| 28 | +boot loader configuration and then transfers control over to the kernel image |
| 29 | +with the retrieved initrd image as its file system. |
| 30 | + |
| 31 | +The initrd image is customized to perform the next set of tasks now that an |
| 32 | +OS is running. The tasks can range from just running some local scripts all |
| 33 | +the way to installing another OS. |
| 34 | + |
| 35 | +## LiveOS ISOs and PXE Support |
| 36 | + |
| 37 | +A LiveOS ISO image is a bootable ISO image that runs all the necessary |
| 38 | +components from memory (i.e. does not need to install anything to the host |
| 39 | +persistent storage). |
| 40 | + |
| 41 | +The necessary components can be either embedded into the initrd image itself |
| 42 | +or embedded into a separate 'rootfs' image (to allow much smaller |
| 43 | +initrd images). If separate, then, the initrd image must be configured with an |
| 44 | +agent that will look for the rootfs image, and transition control over to the |
| 45 | +rootfs at boot time. |
| 46 | + |
| 47 | +Dracut provides the `dmsquash-live` module which managed this transition from |
| 48 | +the initrd image over to the rootfs image. |
| 49 | + |
| 50 | +The **Azure Linux Image Customizer** produces such LiveOS ISO images. A typical |
| 51 | +image holds the following artifacts: |
| 52 | + |
| 53 | +- the boot loader (the shim and something like grub). |
| 54 | +- the boot loader configuration. |
| 55 | +- the kernel image. |
| 56 | +- the initrd image. |
| 57 | +- the rootfs image. |
| 58 | +- other user defined artifacts (optional). |
| 59 | + |
| 60 | +Note that the first 4 artifacts are what is necessary to get an OS kernel up |
| 61 | +and running in a network boot scenario. What remains for a successful booting |
| 62 | +of a LiveOS over the network is to make the rootfs image available for the final |
| 63 | +transition (during the initrd phase). |
| 64 | + |
| 65 | +Dracut enables that entire flow through the use of the `livenet` module - where |
| 66 | +it inspects the `root=live:liveos-iso-url` kernel parameter from the boot loader |
| 67 | +config file, and if it recognizes the `liveos-iso-url` protocol, it downloads |
| 68 | +the ISO, and then proceeds to pivot to the embedded rootfs image. |
| 69 | + |
| 70 | +The user can customize the rootfs using the Azure Linux Image Customizer as |
| 71 | +usual. In case of additional artifacts that need downloading, the user can |
| 72 | +install a daemon on the rootfs which will run when control is transferred to |
| 73 | +the rootfs image and download any additional items. |
| 74 | + |
| 75 | +## Creating and Deploying PXE Boot Artifacts |
| 76 | + |
| 77 | +The Azure Linux Image Customizer produces LiveOS ISO images that are also PXE |
| 78 | +bootable. So, the user can simply create an ISO image as usual, and the output |
| 79 | +can be taken and deployed to a PXE server. |
| 80 | + |
| 81 | +To make the deployment of the generated artifacts easier for the user, the |
| 82 | +Azure Linux Image Customizer offers the following configurations: |
| 83 | + |
| 84 | +- In the input configuration, there is a `pxe` node under which the user can |
| 85 | + configure PXE related properties - like the URL of the LiveOS ISO image to |
| 86 | + download (note that this image is the same image being built). |
| 87 | + See the [Azure Linux Image Customizer configuration](./configuration.md#pxe-type) |
| 88 | + page for more information. |
| 89 | +- When invoking the Azure Linux Image Customizer, the user can also elect to |
| 90 | + export the artifacts to a local folder. |
| 91 | + See the [Azure Linux Image Customizer command line](./cli.md#output-pxe-artifacts-dir) |
| 92 | + page for more information. |
| 93 | + |
| 94 | +Below is a list of required artifacts and where on the PXE server they should |
| 95 | +be deployed: |
| 96 | + |
| 97 | +``` |
| 98 | +ISO media layout artifacts local folder target on PXE server |
| 99 | +----------------------- ------------------------ ------------------------------ |
| 100 | +|- efi | <tftp-server-root> |
| 101 | + |- boot | | |
| 102 | + |- bootx64.efi |- bootx64.efi |- bootx64.efi |
| 103 | + |- grubx64.efi |- grubx64.efi |- grubx64.efi |
| 104 | +|- boot |- boot |- boot |
| 105 | + |- grub2 |- grub2 |- grub2 |
| 106 | + |- grub-pxe.cfg |- grub.cfg |- grub.cfg |
| 107 | + |- grubenv |- grubenv |- grubenv |
| 108 | + |- grub.cfg |
| 109 | + |- vmlinuz |- vmlinuz |- vmlinuz |
| 110 | + |- initrd.img |- initrd.img |- initrd.img |
| 111 | +
|
| 112 | + <yyyy-server-root> |
| 113 | +|- other-user-artifacts |- other-user-artifacts |- other-user-artifacts |
| 114 | + |- <liveos>.iso |- <liveos>.iso |
| 115 | +``` |
| 116 | + |
| 117 | +Notes: |
| 118 | + |
| 119 | +- Note that the `/boot/grub2/grub.cfg` file in the ISO media is not used for |
| 120 | + PXE booting. Instead, the `/boot/grub2/grub-pxe.cfg` gets renamed to `grub.cfg` |
| 121 | + and is used instead. |
| 122 | +- `yyyy` can be any protocol supported by Dracut's `livenet` module (i.e |
| 123 | + tftp, http, etc). |
| 124 | +- The ISO image file location under the server root is customizable - |
| 125 | + but it must be such that its URL matches what is specified in the grub.cfg |
| 126 | + `root=live:<URL>`. |
| 127 | +- While the core OS artifacts (the bootloader, its configuration, the kernel, |
| 128 | + initrd image, and rootfs image) will be downloaded and used automatically, |
| 129 | + the user will need to independently implement a way to download any |
| 130 | + additional artifacts. For example, the user can implement a daemon (and place |
| 131 | + it on the root file system) that will reach out and download the additional |
| 132 | + artifacts when it is up and running. The daemon can be configured with where |
| 133 | + to download the artifacts from, and what to do with them. |
0 commit comments