Skip to content

Instantly share code, notes, and snippets.

@cywang117
Created January 5, 2022 20:59
Show Gist options
  • Save cywang117/98f959c74ad7621dec1d0099f585615b to your computer and use it in GitHub Desktop.
Save cywang117/98f959c74ad7621dec1d0099f585615b to your computer and use it in GitHub Desktop.
Instructions for how to restore a corrupt /etc/resin-supervisor/supervisor.conf

For all commands below, if OS is v2.78.0 or newer, replace resin-supervisor with balena-supervisor. See: https://github.com/balena-os/meta-balena/blob/master/CHANGELOG.md#v2780

Verify issue

  1. cat /etc/resin-supervisor/supervisor.conf should show corrupted file.
  2. Verify no other files are corrupt with grep -v "/var/cache/ldconfig/aux-cache" /resinos.fingerprint | md5sum --quiet -c - See: https://www.balena.io/docs/learn/more/masterclasses/device-debugging/#112-storage-media-corruption
  3. Note last reboot time and when the device was observed to stop working (i.e. Supervisor could not start), notify support agents if possible

Acquire necessary data to regenerate file from API

  1. From the dashboard page, open Chrome / Firefox developer's console with Ctrl/Cmd + Shift + I. Run the following:
let uuid = 'REPLACE_ME_WITH_DEVICE_UUID';
await sdk.models.device.get(uuid, { $select: ['is_ofdevice_type', 'should_be_managed_bysupervisor_release', 'supervisor_version'], $expand: 'should_be_managed_bysupervisor_release' })

.then((result) => {

let targetSupervisor = result.should_be_managed_bysupervisor_release.filter(release => release.is_fordevice_type.id === result.is_ofdevice_type.id);

return { target: targetSupervisor[0], current: result.supervisor_version }

})
  1. This step depends on whether target in the result is undefined or not a. If target is defined, grab image_name from the result. This will be the value of SUPERVISOR_IMAGE later on. The value of SUPERVISOR_TAG will be latest. b. If undefined, run balena images | grep 'supervisor' in a host OS terminal:
root@252e214:~# balena images | grep 'supervisor'
balena/aarch64-supervisor                                        v12.2.11                 1f14799a438b        12 months ago       72.3MB

In this case, the value of SUPERVISOR_IMAGE is balena/aarch64-supervisor and the value of SUPERVISOR_TAG is v12.2.11. 3. On your dashboard, if the "blink" action is available (there is a lightbulb button), the value of LED_FILE will be /sys/class/leds/led0/brightness. If no button is available, it will be /dev/null. 4. rm /etc/resin-supervisor/supervisor.conf; vi /etc/resin-supervisor/supervisor.conf 5. Paste the following, replacing the fields with the data you acquired in the previous steps:

# This file represents the last known version of the supervisor
SUPERVISOR_IMAGE=REPLACE_ME
SUPERVISOR_TAG=REPLACE_ME
LED_FILE=REPLACE_ME

Run update-resin-supervisor if the Supervisor doesn't automatically update and start running.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment