Hello, was curious to try setting my host name via a DBUS call using this example.
However, it fails with error: Error System.Error.EROFS: Failed to set static hostname: Read-only file system
Is this intended? If you’re interested, here is how I’ve always done it which works well for me:
hostnamectl set-hostname "$DEVICE_NAME"
if ! grep "${DEVICE_NAME}" /etc/hosts; then
echo "127.0.1.1 ${DEVICE_NAME}" >> /etc/hosts
fi
hostnamectl status
Edit: I still had the issue with hostnamectl when I had the DBUS system address variable set. If it’s unset, then my workaround works OK. Probably related to this thread:
export DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket
hostnamectl set-hostname ...
Could not set property: Failed to set static hostname: Read-only file system
Before I spin my wheels on this I’m curious if there are any advancements in setting the hostname? I saw in a related thread it may be possible to use DBUS but this thread is giving me a bit of FUD. In my case I want to change the hostname and maybe spoof the MAC address of my device.
The device is running resinOS and is not connected to resin.io. I have physical access to the device.
@balibebas using dbus will work but I think it will not persist over reboots so you’ll have to do it every time your app starts.
Alternatively since you have physical access you can modify config.json in the resin-boot partition and add a “hostname” field.
If you’re sshing into the host this’d be at /mnt/boot. If you do this at runtime, you’ll have to reboot or restart the resin-hostname systemd service (which you can do using dbus if you want).
(I think sometime in the future you should be able to do this using the supervisor API even on a standalone resinOS device, but it’s still not quite there)