-
Notifications
You must be signed in to change notification settings - Fork 47
Description
Generating an ISO with livefs-edit will incorrectly include the resolv.conf file with nameserver configuration from the VM that was used to generate the ISO. This doesn't work if the ISO is used to install Ubuntu on a host in a different network.
it looks like /etc/resolv.conf is coming from: ubuntu-server-minimal.ubuntu-server.installer.generic.custom.squashfs
the only files in that squashfs are /etc/resolv.conf :
root@<hostname>:~/2404squash/squashfs-root2/etc# ls -alrt
total 16
lrwxrwxrwx 1 root root 39 Feb 16 20:58 resolv.conf.tmp -> ../run/systemd/resolve/stub-resolv.conf
-rw-r--r-- 1 root root 92 Jul 8 14:58 resolv.conf
drwxr-xr-x 3 root root 4096 Jul 8 14:58 ..
drwxr-xr-x 2 root root 4096 Jul 8 14:58 .
For some reason it isn’t recreated with the DNS servers provided on the command line. The resulting build does setup /run/systemd/resolve/resolv.conf properly from /etc/netplan/50-cloud-init.yaml. It’s just the contents of the squashfs that isn’t updated during boot.
I've been able to reproduce the issue by re-generating an ISO with:
sudo livefs-edit /srv/tftp/ubuntu-24.04.2-live-server-amd64.iso /srv/tftp/ubuntu-24.04.2-live-server-amd64-mod5.iso --setup-rootfs
And this will include the resolv.conf as we can see:
ubuntu@pxesrv-aptlylab:~$ sudo mount -o loop /srv/tftp/ubuntu-24.04.2-live-server-amd64-mod5.iso /mnt
mount: /mnt: WARNING: source write-protected, mounted read-only.
ubuntu@pxesrv-aptlylab:~$ sudo unsquashfs -d /tmp/squash5 /mnt/casper/ubuntu-server-minimal.ubuntu-server.installer.generic.custom.squashfs
Parallel unsquashfs: Using 4 processors
2 inodes (2 blocks) to write
[=================================================================================================================================================================================================================================================================================================================|] 2/2 100%
created 1 file
created 2 directories
created 1 symlink
created 0 devices
created 0 fifos
created 0 sockets
ubuntu@pxesrv-aptlylab:~$ sudo ls -l /tmp/squash5/
total 8
drwxr-xr-x 2 root root 4096 Jul 9 12:21 etc
ubuntu@pxesrv-aptlylab:~$ sudo ls -l /tmp/squash5/etc/
total 4
-rw-r--r-- 1 root root 802 Jul 9 12:21 resolv.conf
lrwxrwxrwx 1 root root 39 Feb 16 20:58 resolv.conf.tmp -> ../run/systemd/resolve/stub-resolv.conf
ubuntu@pxesrv-aptlylab:~$ sudo cat /tmp/squash5/etc/resolv.conf
# This is /run/systemd/resolve/resolv.conf managed by man:systemd-resolved(8).
# Do not edit.
#
# This file might be symlinked as /etc/resolv.conf. If you're looking at
# /etc/resolv.conf and seeing this text, you have followed the symlink.
#
# This is a dynamic resolv.conf file for connecting local clients directly to
# all known uplink DNS servers. This file lists all configured search domains.
#
# Third party programs should typically not access this file directly, but only
# through the symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a
# different way, replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 192.168.148.1
search fabiomirmar.net
ubuntu@pxesrv-aptlylab:~$
In parallel, this seems to be a valid workaround:
On top of your already modified ISO, edit once again with:
sudo livefs-edit <source.iso> <new.iso> --edit-squashfs ubuntu-server-minimal.ubuntu-server.installer.generic.custom.squashfs add_sys_mounts=false --shell 'rm -rf new/ubuntu-server-minimal.ubuntu-server.installer.generic.custom/etc/'
This will generate a new ISO without the resolv.conf override file.