I chrooted into my testsystem with
mount /dev/vg0/vm01.buster-test-disk /media/vm01.buster-test-disk/
mount -t proc none /media/vm01.buster-test-disk/proc
mount --bind /dev /media/vm01.buster-test-disk/dev
mount -t sysfs sysfs /media/vm01.buster-test-disk/sys
chroot /media/vm01.buster-test-disk/ /bin/bash
adapted the Hostname and exit
hostname buster-test
echo buster-test > /etc/hostname
echo "127.0.0.1 buster-test" >> /etc/hosts
exit
unmount
umount /media/vm01.buster-test-disk/proc
umount /media/vm01.buster-test-disk/dev
umount /media/vm01.buster-test-disk/sys
umount -l /media/vm01.buster-test-disk
Problem
now the host has its hostname set to buster-test
even if I login in in another shell
Why did the hostname change? And are there other things that could change outside the chroot, when doing stuff inside?
echo buster-test > /etc/hostname
would have been enough – rubo77 May 25 '20 at 10:27/etc/hostname
in the chroot would be sufficient. In fact you don’t even need a chroot here, you can write the two files inetc
in your mounted file system. – Stephen Kitt May 25 '20 at 12:37unshare --uts chroot /media/vm01.buster-test-disk/
Blocks changes tohostname
anddomainname
from affecting the rest of the system. – Cameron Tacklind Jul 18 '21 at 21:30