|
| 1 | +# Create, test and publish new guest/host OS images |
| 2 | + |
| 3 | +You are advised to refer to the linux distribution files in [mkosi upstream distribution](https://github.com/systemd/mkosi/tree/main/mkosi/distribution) to determine OS support for configuring and building new OS support within the `sev-certify` project. If the OS support is unavailable, you can connect with mkosi community via forums, mailing lists, or the [mkosi GitHub issue tracker](https://github.com/systemd/mkosi/issues). |
| 4 | + |
| 5 | +You can create and publish new host or guest images in `sev-certify` with `mkosi` tool in the following steps: |
| 6 | + |
| 7 | +- <u>**Fork sev-certify:**</u> Begin by creating your own fork of the [sev-certify](https://github.com/AMDEPYC/sev-certify.git) project. |
| 8 | + |
| 9 | +- <u>**Develop New mkosi Templates for Host and Guest OS Images:**</u> Within your forked repository, you should: |
| 10 | + - Create new OS directories named `host-<new-os-name>-<new-os-release>` and `guest-<new-os-name>-<new-os-release>` in the `sev-certify/images` directory. |
| 11 | + - Find an existing OS template in the `sev-certify` project that resembles your new OS. For example, to create a CentOS linux image, you can refer to the Fedora linux mkosi template. |
| 12 | + - Start configuring your new mkosi template by copying the identified similar linux templates into your new OS directories. |
| 13 | + |
| 14 | + If your new mkosi template differs from all existing templates, ensure to meet the minimum linux package requirements as detailed in the configuration [section](#configure-new-mkosi-template-for-host-and-guest-os-images). |
| 15 | + |
| 16 | +- <u>**Integrate New OS Release into GitHub Workflow**</u> Add new host/guest OS images to your forked `sev-certify` GitHub repository by including the new OS release in the `distro matrix` of the `build-and-release.yml` workflow located in `sev-certify/.github/workflows`: |
| 17 | + ``` |
| 18 | + - distro: <new-os-name> |
| 19 | + release: <new-os-release> |
| 20 | + ``` |
| 21 | + |
| 22 | +- <u>**Build new Host and Guest OS images:**</u> You can choose between two methods to build new host and guest OS images: |
| 23 | + - **Option 1:** Preferred for the users who plan to build their new host/guest OS images <u>within their forked `sev-certify` GH repository</u> after pushing their new mkosi templates. |
| 24 | + |
| 25 | + Trigger `build-and-release.yml` GitHub workflow manually in your forked `sev-certify` github repository to create the new OS host and guest images. Then, verify for successful execution with the built new host and guest OS images under `devel` tag. |
| 26 | + |
| 27 | + If the `build-and-release` workflow fails, you need to troubleshoot for the error in the workflow log, implement changes, and retest until successful execution. |
| 28 | + |
| 29 | + - **Option 2**: Suitable for those who want to build locally using the `mkosi` command before updating their forked repository. |
| 30 | + |
| 31 | + Ensure that the mkosi tool compatible with the `sev-certify` project is installed on your system. `mkosi` installation instructions are available [here](#install-mkosi-on-your-system) |
| 32 | + |
| 33 | + Then, build new host/guest OS images using `mkosi` in `sev-certify` directory: |
| 34 | + |
| 35 | + ``` |
| 36 | + mkosi --image-id=host-<new-os-name>-<new-os-release> \ |
| 37 | + -C images/host-<new-os-name>-<new-os-release> build |
| 38 | + ``` |
| 39 | + Host image, host Kernel, host boot ramfs are generated in the `host-<new-os-name>-<new-os-release>` directory. |
| 40 | +
|
| 41 | + ``` |
| 42 | + mkosi --image-id=host-<new-os-name>-<new-os-release> \ |
| 43 | + -C images/host-<new-os-name>-<new-os-release> build |
| 44 | + ``` |
| 45 | + Guest image, guest Kernel, guest boot ramfs are generated in the `host-<new-os-name>-<new-os-release>` directory. |
| 46 | +
|
| 47 | + Ubuntu users encountering AppArmor-related permission errors with mkosi should refer to this [exception](#exceptions). |
| 48 | +
|
| 49 | +- <u>**Test the New OS Host/Guest Images:**</u> To test the built guest image, you should: |
| 50 | + - **Retrieve the built guest image** either by downloading the new guest OS image `guest-<new-os-name>-<new-os-release>` under `devel` tag of your forked repository, (or) use the locally built guest OS image `images/guest-<new-os-name>-<new-os-release>/guest-<new-os-name>-<new-os-release>.efi` on the system. |
| 51 | + - Launch the built guest image on SEV-enabled host following the instructions in this [guide](https://github.com/AMDEPYC/sev-certify/blob/main/docs/how-to-run-guest-manually.md). |
| 52 | +
|
| 53 | +
|
| 54 | +To test the host image, you should: |
| 55 | + - **Fetch the built host image** either by downloading the new host OS image `host-<new-os-name>-<new-os-release>` under `devel` tag of your forked repository (or) use the locally built host OS image `images/guest-<new-os-name>-<new-os-release>/guest-<new-os-name>-<new-os-release>.efi` on the system. |
| 56 | + - Boot the built host image on your SNP-enabled test server using HTTPboot/dispatch process to test the newly built host OS image on bare metal and generate new OS certificate under your forked `sev-certify` issues using this [guide](https://github.com/AMDEPYC/sev-certify/blob/main/docs/how-to-generate-certs.md#forking-amdepycsev-certify-for-certification-testing). Host image will automatically reboot when done. |
| 57 | +
|
| 58 | +- <u>**Submit a Pull Request for the New OS:**</u> Once all tests are passed, create a pull request to integrate your new OS support into the `sev-certify` upstream. |
| 59 | +
|
| 60 | +**NOTE:** Ensure that all GitHub workflow tests pass on your last pushed commit to facilitate integration into the upstream repository. |
| 61 | +
|
| 62 | +## Configure new mkosi template for Host and Guest OS images |
| 63 | +### Host OS Image Configuration |
| 64 | +Create a `mkosi.conf` file under `sev-certify/images/host-<new-os-name>-<new-os-release>` folder. Ensure it includes: |
| 65 | + ``` |
| 66 | + [Include] |
| 67 | + # Include required modules in the host image |
| 68 | + Include=../../modules/host |
| 69 | + |
| 70 | + [Distribution] |
| 71 | + Distribution=<new-os-name> |
| 72 | + Release=<new-os-release> |
| 73 | + |
| 74 | + [Content] |
| 75 | + Packages= |
| 76 | + # Required host OS packages to certify Host OS in sev-certify |
| 77 | + <host-kernel-package> |
| 78 | + <qemu-package> |
| 79 | + <ovmf-package> |
| 80 | + |
| 81 | + # Required host OS package dependencies for sev-certify framework execution |
| 82 | + <systemd-package> |
| 83 | + <systemd-resolved-package> |
| 84 | + <systemd-journal-remote-package> |
| 85 | + <openssl-package> |
| 86 | + <xxd-package> |
| 87 | + <python3-pip-package> |
| 88 | + <python3-emoji-package> |
| 89 | + <jq-package> |
| 90 | + <avahi-daemon-package> |
| 91 | + ``` |
| 92 | +
|
| 93 | +### Guest OS Image Configuration |
| 94 | +Create a `mkosi.conf` in `sev-certify/images/guest-<new-os-name>-<new-os-release>` folder. It should contain: |
| 95 | +
|
| 96 | +Sample `mkosi.conf` content for new guest OS image has below minimum requirements: |
| 97 | + ``` |
| 98 | + [Include] |
| 99 | + # Include required modules in the guest image |
| 100 | + Include=../../modules/guest |
| 101 | + |
| 102 | + [Distribution] |
| 103 | + Distribution=<new-os-distro> |
| 104 | + Release=<new-os-release> |
| 105 | + |
| 106 | + [Content] |
| 107 | + Packages= |
| 108 | + # Required guest OS packages to certify Guest OS in sev-certify |
| 109 | + <guest-kernel-package> |
| 110 | + |
| 111 | + # Required guest OS package dependencies for sev-certify framework execution |
| 112 | + <systemd-package> |
| 113 | + <systemd-boot-package> |
| 114 | + <systemd-boot-resolved-package> |
| 115 | + <systemd-journal-remote-package> |
| 116 | + <openssl-package> |
| 117 | + <ca-certificates-package> |
| 118 | + <jq-package> |
| 119 | + <xxd-package> |
| 120 | + ``` |
| 121 | +## Install mkosi on your System |
| 122 | +You should: |
| 123 | +- Identify the mkosi version compatible with the sev-certify project in `Install dependencies` task from the workflow [build-and-release.yml](https://github.com/AMDEPYC/sev-certify/blob/main/.github/workflows/build-and-release.yml). For now, it uses Ubuntu Plucky release version 25.3. |
| 124 | +- Install mkosi: |
| 125 | + - **Option 1:** Use your OS package manager to install a compatible mkosi version. A list of supported Linux Distributions for mkosi package can be found under `tags` on the [mkosi GitHub page](https://github.com/systemd/mkosi). Alternatively, you can build from the source following Option 2 instructions. |
| 126 | + - **Option 2:** Build and install mkosi from the source repository |
| 127 | +
|
| 128 | + Build mkosi from source and update `MKOSI_VERSION` to match with the `mkosi` version used in the sev-certify upstream. |
| 129 | + ```bash |
| 130 | + cd /tmp |
| 131 | + export MKOSI_VERSION=v25.3 |
| 132 | + git clone https://github.com/systemd/mkosi.git |
| 133 | + cd mkosi |
| 134 | + git checkout $MKOSI_VERSION |
| 135 | + ``` |
| 136 | +
|
| 137 | + Install it manually since mkosi might not be in all package managers by default. Inside the /tmp/mkosi directory, run the following: |
| 138 | + ```bash |
| 139 | + sudo make install |
| 140 | + ``` |
| 141 | +
|
| 142 | + After make finishes, optionally move the mkosi script. For example: |
| 143 | + ```bash |
| 144 | + sudo mv mkosi /usr/local/bin |
| 145 | + ``` |
| 146 | + Verify mkosi installation with: |
| 147 | + ```bash |
| 148 | + mkosi --version |
| 149 | + ``` |
| 150 | + The displayed version should match the version used in sev-certify upstream. |
| 151 | +
|
| 152 | +## Exceptions |
| 153 | +
|
| 154 | +### Important Note for Ubuntu Users |
| 155 | +Permission errors related to AppArmor while running mkosi are recognized and documented in [systemd/mkosi#3265](https://github.com/systemd/mkosi/issues/3265). Please take a look at this issue to tackle this permission error. |
| 156 | +
|
| 157 | +## References |
| 158 | +- **Debian based OS:** Sample PR to add Ubuntu 25.10 OS Support into the `sev-certify` project is available in this [link](https://github.com/AMDEPYC/sev-certify/pull/222). |
| 159 | +- **RH based OS:** Sample PR to add Rocky 10 OS Support into the `sev-certify` project is available in this [link](https://github.com/AMDEPYC/sev-certify/pull/87/). |
0 commit comments