From 0bf3f2662f2820a18deaa2ae8c035f6575d72992 Mon Sep 17 00:00:00 2001 From: Job Date: Mon, 23 Nov 2026 20:01:51 +0000 Subject: [PATCH] fix: set the hostname on the kernel command line The first boot had another hostname than later boots, because /etc/hostname only exists once tmpfiles links it, after PID 1 has set the hostname. Remote Control shows the hostname, so the VM changed name in claude.ai after its first reboot. PID 1 has the command line from the start. Co-Authored-By: Claude Opus 5.5 --- mkosi.conf | 6 ++++-- mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/mkosi.conf b/mkosi.conf index ecbbd44..cb5967e 100644 --- a/mkosi.conf +++ b/mkosi.conf @@ -24,7 +24,6 @@ ManifestFormat=json [Content] # Content sets what goes into the image: -# - Hostname is agentos- and four hex digits of the machine ID. # - WithDocs leaves out man pages. The image has no man to read them. # - Packages lists the packages installed into the image. # - UnifiedKernelImageFormat names the UKI agentos_.efi, which matches @@ -32,6 +31,9 @@ ManifestFormat=json # - KernelCommandLine: # - rw has the initrd mount the root filesystem writable. It finds it by its # partition type (mkosi.extra/usr/lib/repart.d/50-root.conf). +# - The hostname is agentos- and four hex digits of the machine ID, also the +# name Remote Control shows. Unlike /etc/hostname, which only exists once +# tmpfiles links it, the command line has it from the first boot on. # - The image policy only accepts an encrypted root filesystem (or none, at # first boot) and a verity-checked /usr. Otherwise someone with the disk # could swap in a plain root filesystem. Our UKI would boot it, and their @@ -50,7 +52,6 @@ ManifestFormat=json # - RemoveFiles drops System.map, which is only for debugging the kernel, and # the udev hwdb, which holds hardware names and quirks a VM doesn't need. # Without hwdb.d, systemd-hwdb-update can't build it again at boot. -Hostname=agentos-???? WithDocs=no Packages= kernel-core # Unlike kernel, this has no extra drivers. @@ -82,6 +83,7 @@ UnifiedKernelImageFormat=%i_%v KernelCommandLine= quiet rw + systemd.hostname=agentos-???? systemd.image_policy=root=encrypted+absent:usr=verity:esp=unprotected systemd.setenv=SYSTEMD_REPART_MKFS_OPTIONS_BTRFS=--metadata=single SYSTEMD_DEFAULT_MOUNT_RATE_LIMIT_BURST=50 diff --git a/mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf b/mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf index bdeb4f3..4d6046e 100644 --- a/mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf +++ b/mkosi.extra/usr/lib/tmpfiles.d/factory-etc.conf @@ -40,5 +40,4 @@ L /etc/profile L /etc/profile.d L /etc/protocols L /etc/services -L /etc/hostname L /etc/claude-code -- 2.54.1