set_netdev_labels() { local dir local label local netdev for dir in /sys/class/net/*; do [ -r "$dir/of_node/label" ] || continue read -r label < "$dir/of_node/label" netdev="${dir##*/}" [ "$netdev" = "$label" ] && continue ip link set "$netdev" name "$label" done } boot_hook_add preinit_main set_netdev_labels