Ok, so, I got the log, and the interesting part is this:
+ '[' -z myhostname ']'
+ ebegin 'Setting hostname to myhostname from /etc/hostname'
* Setting hostname to myhostname from /etc/hostname ...
+ hostname myhostname
+ eend 0 'Failed to set the hostname'
Here is the corresponding part in /etc/init.d/hostname, from the line
if [ -z "$h" ]; then
start()
{
local h source
if read -r h _ 2> /dev/null < /etc/hostname; then
source="/etc/hostname"
elif [ -n "${hostname}" ]; then
h=${hostname}
source="/etc/conf.d/${RC_SVCNAME}"
fi
if [ -z "$h" ]; then
einfo "Using default system hostname"
return 0
fi
ebegin "Setting hostname to $h from $source"
hostname "$h"
eend $? "Failed to set the hostname"
}
I have no idea why the command hostname myhostname would fail!!
Here is the full part of the log produced by set -x :
++ description='Sets the hostname of the machine.'
+ yesno ''
+ '[' -z '' ']'
+ return 1
+ for _cmd in "$@"
+ '[' start '!=' status -a start '!=' describe ']'
+ '[' -n '' ']'
++ command -v cgroup_add_service
+ '[' cgroup_add_service = cgroup_add_service ']'
+ grep -qs /sys/fs/cgroup /proc/1/mountinfo
+ '[' -d /sys/fs/cgroup -a '!' -w /sys/fs/cgroup ']'
+ cgroup_add_service
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/blkio/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/cpu/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/cpuacct/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/cpuset/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/devices/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/freezer/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/hugetlb/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/memory/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/misc/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/net_cls/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/net_prio/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/openrc/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/perf_event/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/pids/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/rdma/tasks ']'
+ printf %d 0
+ for d in /sys/fs/cgroup/*
+ '[' -w /sys/fs/cgroup/unified/tasks ']'
+ openrc_cgroup=/sys/fs/cgroup/openrc
+ '[' -d /sys/fs/cgroup/openrc ']'
+ cgroup=/sys/fs/cgroup/openrc/hostname
+ mkdir -p /sys/fs/cgroup/openrc/hostname
+ '[' -w /sys/fs/cgroup/openrc/hostname/tasks ']'
+ printf %d 0
++ command -v cgroup_set_limits
+ '[' cgroup_set_limits = cgroup_set_limits ']'
+ cgroup_set_limits
+ local blkio=
+ '[' -n '' ']'
+ local cpu=
+ '[' -n '' ']'
+ local cpuacct=
+ '[' -n '' ']'
+ local cpuset=
+ '[' -n '' ']'
+ local devices=
+ '[' -n '' ']'
+ local hugetlb=
+ '[' -n '' ']'
+ local memory=
+ '[' -n '' ']'
+ local net_cls=
+ '[' -n '' ']'
+ local net_prio=
+ '[' -n '' ']'
+ local pids=
+ '[' -n '' ']'
+ return 0
++ command -v cgroup2_set_limits
+ '[' cgroup2_set_limits = cgroup2_set_limits ']'
+ '[' start = start ']'
+ cgroup2_set_limits
+ local cgroup_path
++ cgroup2_find_path
++ grep -qw cgroup2 /proc/filesystems
++ case "${rc_cgroup_mode:-hybrid}" in
++ printf /sys/fs/cgroup/unified
++ return 0
+ cgroup_path=/sys/fs/cgroup/unified
+ '[' -z /sys/fs/cgroup/unified ']'
+ mountinfo -q /sys/fs/cgroup/unified
+ rc_cgroup_path=/sys/fs/cgroup/unified/hostname
+ '[' '!' -d /sys/fs/cgroup/unified/hostname ']'
+ mkdir /sys/fs/cgroup/unified/hostname
+ '[' -f /sys/fs/cgroup/unified/hostname/cgroup.procs ']'
+ printf 0
+ '[' -z '' ']'
+ return 0
+ break
+ eval 'printf '\''%s\n'\'' '
++ printf '%s\n'
+ read _d
+ '[' -n '' ']'
+ read _d
+ '[' 0 -ne 0 ']'
+ unset _d
+ eval 'printf '\''%s\n'\'' '
+ read _f
++ printf '%s\n'
+ '[' -n '' ']'
+ read _f
+ '[' 0 -ne 0 ']'
+ unset _f
+ '[' -n '' ']'
+ '[' -n start ']'
+ '[' start = depend ']'
+ for _cmd in describe start stop status ${extra_commands:-$opts} $extra_started_commands $extra_stopped_commands
+ '[' describe = start ']'
+ for _cmd in describe start stop status ${extra_commands:-$opts} $extra_started_commands $extra_stopped_commands
+ '[' start = start ']'
++ command -v start
+ '[' start = start ']'
+ yesno
+ '[' -z '' ']'
+ return 1
+ for _cmd in $extra_stopped_commands
+ '[' cgroup_cleanup = start ']'
+ unset _cmd
+ case $1 in
+ verify_boot
+ '[' '!' -e /run/openrc/softlevel ']'
+ return 0
++ command -v start_pre
+ '[' '' = start_pre ']'
+ start
+ local h source
+ read -r h _
+ source=/etc/hostname
+ '[' -z myhostname ']'
+ ebegin 'Setting hostname to myhostname from /etc/hostname'
* Setting hostname to myhostname from /etc/hostname ...
+ hostname myhostname
+ eend 0 'Failed to set the hostname'
[ ok ]
++ command -v start_post
+ '[' '' = start_post ']'
++ command -v cgroup_cleanup
+ '[' cgroup_cleanup = cgroup_cleanup ']'
+ '[' start = stop ']'
++ command -v cgroup2_remove
+ '[' cgroup2_remove = cgroup2_remove ']'
+ '[' start = stop ']'
+ '[' -z '' ']'
+ cgroup2_remove
+ local cgroup_path rc_cgroup_path
++ cgroup2_find_path
++ grep -qw cgroup2 /proc/filesystems
++ case "${rc_cgroup_mode:-hybrid}" in
++ printf /sys/fs/cgroup/unified
++ return 0
+ cgroup_path=/sys/fs/cgroup/unified
+ '[' -z /sys/fs/cgroup/unified ']'
+ rc_cgroup_path=/sys/fs/cgroup/unified/hostname
+ '[' '!' -d /sys/fs/cgroup/unified/hostname ']'
+ '[' '!' -e /sys/fs/cgroup/unified/hostname/cgroup.events ']'
+ grep -qx 1864 /sys/fs/cgroup/unified/hostname/cgroup.procs
+ printf %d 0
+ local key populated vvalue
+ read -r key value
+ case "${key}" in
+ populated=0
+ read -r key value
+ case "${key}" in
+ read -r key value
+ '[' 0 = 1 ']'
+ rmdir /sys/fs/cgroup/unified/hostname
+ return 0
+ shift
+ continue 2
+ '[' -n '' ']'
+ exit 0
There seem to be a lot of cgroup incantations mixed in, maybe that's the problem...
And, for reference, here is the full /etc/init.d/hostname file:
#!/usr/bin/openrc-run
set -x
# Copyright (c) 2007-2015 The OpenRC Authors.
# See the Authors file at the top-level directory of this distribution and
# https://github.com/OpenRC/openrc/blob/HEAD/AUTHORS
#
# This file is part of OpenRC. It is subject to the license terms in
# the LICENSE file found in the top-level directory of this
# distribution and at https://github.com/OpenRC/openrc/blob/HEAD/LICENSE
# This file may not be copied, modified, propagated, or distributed
# except according to the terms contained in the LICENSE file.
description="Sets the hostname of the machine."
depend()
{
after clock
keyword -docker -lxc -prefix -systemd-nspawn
}
start()
{
local h source
if read -r h _ 2> /dev/null < /etc/hostname; then
source="/etc/hostname"
elif [ -n "${hostname}" ]; then
h=${hostname}
source="/etc/conf.d/${RC_SVCNAME}"
fi
if [ -z "$h" ]; then
einfo "Using default system hostname"
return 0
fi
ebegin "Setting hostname to $h from $source"
hostname "$h"
eend $? "Failed to set the hostname"
}