Skip to content

Commit fc30af4

Browse files
committed
base_image: trigger SELinux relabeling for Fedora guests on first boot
Fedora guest images created on Debian hosts fail to boot because the filesystem lacks proper SELinux contexts. All binaries fail with exit code 127 (command not found) as SELinux blocks execution of files with unlabeled_t context. Creating the /.autorelabel file triggers Fedora's automatic SELinux relabeling on first boot, ensuring all files receive correct contexts before systemd starts services. This allows Fedora guests to boot successfully when provisioned from non-SELinux hosts. Generated-by: Claude AI Signed-off-by: Daniel Gomez <[email protected]>
1 parent 88f94e7 commit fc30af4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

playbooks/roles/base_image/templates/virt-builder.j2

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,3 +86,11 @@ firstboot-command systemctl start ssh
8686

8787
{% endif %}
8888
{% endif %}
89+
90+
{% if guestfs_fedora is defined and guestfs_fedora %}
91+
{# Fedora uses SELinux in enforcing mode by default. When creating a Fedora #}
92+
{# guest image on a non-SELinux host (like Debian), the filesystem will not #}
93+
{# have proper SELinux contexts, causing boot failures with "command not found" #}
94+
{# errors (exit 127) for all binaries. Trigger automatic relabeling on first boot. #}
95+
write /.autorelabel:
96+
{% endif %}

0 commit comments

Comments
 (0)