Estou tentando desabilitar uma placa de rede integrada com defeito com a solução sugerida nesta resposta: https://unix.stackexchange.com/a/467085 . Mas, por alguns motivos, os scripts/comandos não conseguem gravar nada no sistema de arquivos.
Meu cat /etc/udev/rules.d/90-disable-ens32.rules
é:
ACTION=="add", SUBSYSTEM=="net", ENV{ID_NET_NAME_SLOT}=="ens32", RUN+="/etc/udev/remove_onboard_ens32.sh $env{DEVPATH}"
Meu cat /etc/udev/remove_onboard_ens32.sh
é:
__DEV_PATH="$1"
echo "$(/usr/bin/date)" >> /tmp/ajt.bin_sh.log
/usr/bin/touch /sys$__DEV_PATH/device/remove
echo "1" > /sys$__DEV_PATH/device/remove
Não tenho certeza se remove_onboard_ens32.sh
o script está sendo executado pelas regras do udev, pois o log no /tmp
diretório não está sendo criado e também os comandos touch
e echo
não parecem estar funcionando.
A permissão /etc/udev/remove_onboard_ens32.sh
é 755 e o usuário/grupo é root/root. A permissão /etc/udev/rules.d/90-disable-ens32.rules
é 644 e o usuário/grupo é root/root.
O resultado depois sudo udevadm control --reload-rules && sudo udevadm trigger
seguido por udevadm test --action="add" /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/net/ens32 2>&1 | less
é:
This program is for debugging only, it does not run any program
specified by a RUN key. It may show incorrect results, because
some values may be different, or not available at a simulation run.
Trying to open "/etc/systemd/hwdb/hwdb.bin"...
Trying to open "/etc/udev/hwdb.bin"...
Trying to open "/usr/lib/systemd/hwdb/hwdb.bin"...
Trying to open "/lib/systemd/hwdb/hwdb.bin"...
Trying to open "/lib/udev/hwdb.bin"...
=== trie on-disk ===
tool version: 253
file size: 12364925 bytes
header size 80 bytes
strings 2509325 bytes
nodes 9855520 bytes
Loading kernel module index.
Failed to read $container of PID 1, ignoring: Permission denied
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
Using default interface naming scheme 'v253'.
Parsed configuration file "/usr/lib/systemd/network/99-default.link"
Parsed configuration file "/usr/lib/systemd/network/73-usb-net-by-mac.link"
Created link configuration context.
Reading rules file: /usr/lib/udev/rules.d/39-usbmuxd.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb-media-players.rules
Reading rules file: /usr/lib/udev/rules.d/40-usb_modeswitch.rules
Reading rules file: /usr/lib/udev/rules.d/40-vm-hotadd.rules
Reading rules file: /usr/lib/udev/rules.d/50-apport.rules
Reading rules file: /usr/lib/udev/rules.d/50-firmware.rules
Reading rules file: /usr/lib/udev/rules.d/50-udev-default.rules
Reading rules file: /usr/lib/udev/rules.d/55-dm.rules
Reading rules file: /usr/lib/udev/rules.d/56-hpmud.rules
Reading rules file: /usr/lib/udev/rules.d/60-autosuspend.rules
Reading rules file: /usr/lib/udev/rules.d/60-block.rules
Reading rules file: /usr/lib/udev/rules.d/60-cdrom_id.rules
Reading rules file: /usr/lib/udev/rules.d/60-drm.rules
Reading rules file: /usr/lib/udev/rules.d/60-evdev.rules
Reading rules file: /usr/lib/udev/rules.d/60-fido-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-infiniband.rules
Reading rules file: /usr/lib/udev/rules.d/60-input-id.rules
Reading rules file: /usr/lib/udev/rules.d/60-inputattach.rules
Reading rules file: /usr/lib/udev/rules.d/60-libgphoto2-6.rules
Reading rules file: /usr/lib/udev/rules.d/60-libsane1.rules
Reading rules file: /usr/lib/udev/rules.d/60-pcmcia.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-alsa.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-input.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-dm.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage-tape.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
Reading rules file: /usr/lib/udev/rules.d/60-sensor.rules
Reading rules file: /usr/lib/udev/rules.d/60-serial.rules
Reading rules file: /usr/lib/udev/rules.d/60-tpm-udev.rules
Reading rules file: /usr/lib/udev/rules.d/60-virtualbox-dkms.rules
Reading rules file: /usr/lib/udev/rules.d/60-virtualbox.rules
Reading rules file: /usr/lib/udev/rules.d/61-persistent-storage-android.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs.rules
Reading rules file: /usr/lib/udev/rules.d/64-xorg-xkb.rules
Reading rules file: /usr/lib/udev/rules.d/65-libwacom.rules
Reading rules file: /usr/lib/udev/rules.d/66-snapd-autoimport.rules
Reading rules file: /usr/lib/udev/rules.d/69-cd-sensors.rules
Reading rules file: /usr/lib/udev/rules.d/69-libmtp.rules
Reading rules file: /usr/lib/udev/rules.d/69-wacom.rules
Reading rules file: /usr/lib/udev/rules.d/70-camera.rules
Reading rules file: /usr/lib/udev/rules.d/70-joystick.rules
Reading rules file: /usr/lib/udev/rules.d/70-memory.rules
Reading rules file: /usr/lib/udev/rules.d/70-mouse.rules
Reading rules file: /usr/lib/udev/rules.d/70-power-switch.rules
Reading rules file: /usr/lib/udev/rules.d/70-printers.rules
Reading rules file: /etc/udev/rules.d/70-snap.firefox.rules
Reading rules file: /etc/udev/rules.d/70-snap.snapd.rules
Reading rules file: /usr/lib/udev/rules.d/70-spice-vdagentd.rules
Reading rules file: /usr/lib/udev/rules.d/70-touchpad.rules
Reading rules file: /usr/lib/udev/rules.d/70-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-ipp-usb.rules
Reading rules file: /usr/lib/udev/rules.d/71-power-switch-proliant.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/71-u-d-c-gpu-detection.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.rules
Reading rules file: /usr/lib/udev/rules.d/73-special-net-names.rules
Reading rules file: /usr/lib/udev/rules.d/75-net-description.rules
Reading rules file: /usr/lib/udev/rules.d/75-probe_mtd.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-broadmobi-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-cinterion-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dell-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-dlink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ericsson-mbm.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-fibocom-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-foxconn-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-gosuncn-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-haier-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-huawei-net-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-linktop-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-longcheer-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-mtk-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-nokia-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-qcom-soc.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-qdl-device-blacklist.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-quectel-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-sierra.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-simtech-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-telit-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-tplink-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-ublox-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-x22x-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/77-mm-zte-port-types.rules
Reading rules file: /usr/lib/udev/rules.d/78-graphics-card.rules
Reading rules file: /usr/lib/udev/rules.d/78-sound-card.rules
Reading rules file: /usr/lib/udev/rules.d/80-debian-compat.rules
Reading rules file: /usr/lib/udev/rules.d/80-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/80-libinput-device-groups.rules
Reading rules file: /usr/lib/udev/rules.d/80-mm-candidate.rules
Reading rules file: /usr/lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /usr/lib/udev/rules.d/80-udisks2.rules
Reading rules file: /usr/lib/udev/rules.d/81-net-dhcp.rules
Reading rules file: /usr/lib/udev/rules.d/84-nm-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/85-brltty.rules
Reading rules file: /usr/lib/udev/rules.d/85-hdparm.rules
Reading rules file: /usr/lib/udev/rules.d/85-hplj10xx.rules
Reading rules file: /usr/lib/udev/rules.d/85-nm-unmanaged.rules
Reading rules file: /usr/lib/udev/rules.d/90-alsa-restore.rules
Reading rules file: /usr/lib/udev/rules.d/90-bolt.rules
Reading rules file: /usr/lib/udev/rules.d/90-console-setup.rules
Reading rules file: /etc/udev/rules.d/90-disable-ens32.rules
Reading rules file: /usr/lib/udev/rules.d/90-fwupd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/90-libgpod.rules
Reading rules file: /usr/lib/udev/rules.d/90-libinput-fuzz-override.rules
Reading rules file: /run/udev/rules.d/90-netplan.rules
Reading rules file: /usr/lib/udev/rules.d/90-nm-thunderbolt.rules
Reading rules file: /usr/lib/udev/rules.d/90-pipewire-alsa.rules
Reading rules file: /usr/lib/udev/rules.d/90-pulseaudio.rules
Reading rules file: /usr/lib/udev/rules.d/95-cd-devices.rules
Reading rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-hid.rules
Reading rules file: /usr/lib/udev/rules.d/95-upower-wup.rules
Reading rules file: /usr/lib/udev/rules.d/96-e2scrub.rules
Reading rules file: /usr/lib/udev/rules.d/97-hid2hci.rules
Reading rules file: /etc/udev/rules.d/99-hdd-smart-dump-on-usb-trigger.udev.rules
Reading rules file: /usr/lib/udev/rules.d/99-libsane1.rules
Reading rules file: /usr/lib/udev/rules.d/99-systemd.rules
sd-device: Failed to chase symlinks in "/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/net/ens32".
value '[dmi/id]sys_vendor' is 'Maxtone'
value '[dmi/id]sys_vendor' is 'Maxtone'
ens32: /usr/lib/udev/rules.d/75-net-description.rules:6 Importing properties from results of builtin command 'net_id'
ens32: MAC address identifier: hw_addr=00:25:11:c8:3c:e7 → x002511c83ce7
sd-device: Failed to chase symlinks in "/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/of_node".
sd-device: Failed to chase symlinks in "/sys/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/physfn".
ens32: Parsing slot information from PCI device sysname "0000:01:00.0": success
ens32: dev_port=0
ens32: PCI path identifier: domain=0 bus=1 slot=0 func=0 phys_port= dev_port=0 → p1s0
ens32: Slot identifier: domain=0 slot=32 func=0 phys_port= dev_port=0 → s32
ens32: /usr/lib/udev/rules.d/75-net-description.rules:12 Importing properties from results of builtin command 'hwdb --subsystem=pci'
ens32: hwdb modalias key: "pci:v00001969d00002048sv00001019sd00002048bc02sc00i00"
ens32: /usr/lib/udev/rules.d/80-net-setup-link.rules:5 Importing properties from results of builtin command 'path_id'
ens32: /usr/lib/udev/rules.d/80-net-setup-link.rules:9 Importing properties from results of builtin command 'net_setup_link'
ens32: Device has name_assign_type=4
ens32: Device has addr_assign_type=0
ens32: Config file /usr/lib/systemd/network/99-default.link is applied
ens32: MAC address on the device already matches policy "persistent".
ens32: Policy *keep*: keeping existing userspace name
ens32: /usr/lib/udev/rules.d/80-net-setup-link.rules:11 NAME 'ens32'
ens32: /etc/udev/rules.d/90-disable-ens32.rules:1 RUN '/etc/udev/remove_onboard_ens32.sh $env{DEVPATH}'
ens32: /usr/lib/udev/rules.d/99-systemd.rules:66 RUN '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/$name --prefix=/net/ipv4/neigh/$name --prefix=/net/ipv6/conf/$name --prefix=/net/ipv6/neigh/$name'
ens32: Failed to update tags under /run/udev/tag/: Permission denied
DEVPATH=/devices/pci0000:00/0000:00:1c.0/0000:01:00.0/net/ens32
INTERFACE=ens32
IFINDEX=2
ACTION=add
SUBSYSTEM=net
TAGS=:systemd:
ID_MM_CANDIDATE=1
ID_NET_NAMING_SCHEME=v253
ID_NET_NAME_MAC=enx002511c83ce7
ID_OUI_FROM_DATABASE=Elitegroup Computer Systems Co.,Ltd.
ID_NET_NAME_PATH=enp1s0
ID_NET_NAME_SLOT=ens32
ID_BUS=pci
ID_VENDOR_ID=0x1969
ID_MODEL_ID=0x2048
ID_PCI_CLASS_FROM_DATABASE=Network controller
ID_PCI_SUBCLASS_FROM_DATABASE=Ethernet controller
ID_VENDOR_FROM_DATABASE=Qualcomm Atheros
ID_MODEL_FROM_DATABASE=Attansic L2 Fast Ethernet
ID_PATH=pci-0000:01:00.0
ID_PATH_TAG=pci-0000_01_00_0
ID_NET_DRIVER=atl2
ID_NET_LINK_FILE=/usr/lib/systemd/network/99-default.link
ID_NET_NAME=ens32
CURRENT_TAGS=:systemd:
SYSTEMD_ALIAS=/sys/subsystem/net/devices/ens32
USEC_INITIALIZED=1300330
run: '/etc/udev/remove_onboard_ens32.sh /devices/pci0000:00/0000:00:1c.0/0000:01:00.0/net/ens32'
run: '/lib/systemd/systemd-sysctl --prefix=/net/ipv4/conf/ens32 --prefix=/net/ipv4/neigh/ens32 --prefix=/net/ipv6/conf/ens32 --prefix=/net/ipv6/neigh/ens32'
Unload kernel module index.
Unloaded link configuration context.
Estou tentando descobrir onde estou cometendo o erro. Alguém pode descobrir onde?
Foi bobagem da minha parte omitir o hashbang no meu script. E precisa exportar a
$PATH
variável ou usar o caminho completo para o comando.Isso desativa a placa de rede e também pode gravar logs em
/dev/shm/
e/var/run/
, mas falha ao registrar um arquivo em/tmp/
porque o script é executado um pouco antes de o sistema de arquivos que contém/tmp
ser montado. Se precisarmos escrever para escrever/tmp
, podemos adicionar um atraso de cercasleep 5s
de antes de escrever.