Defino o nível de APM e o tempo limite de espera de meus HDDs durante a inicialização com uma regra do udev:
ACTION=="add|change", KERNEL=="sd[b-z]", ATTR{queue/rotational}=="1", RUN+="/usr/bin/hdparm -B 63 -S 36 /dev/%k"
Eu verifiquei que a regra é executada tocando em um arquivo no comando RUN e por udevadm test /sys/class/block/sdb
:
calling: test
version 227
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.
=== trie on-disk ===
tool version: 227
file size: 6660537 bytes
header size 80 bytes
strings 1715721 bytes
nodes 4944736 bytes
Load module index
timestamp of '/etc/systemd/network' changed
Parsed configuration file /usr/lib/systemd/network/99-default.link
Created link configuration context.
timestamp of '/etc/udev/rules.d' changed
Reading rules file: /usr/lib/udev/rules.d/10-dm.rules
Reading rules file: /usr/lib/udev/rules.d/11-dm-lvm.rules
Reading rules file: /usr/lib/udev/rules.d/13-dm-disk.rules
Reading rules file: /etc/udev/rules.d/50-hdparm.rules
Reading rules file: /usr/lib/udev/rules.d/50-udev-default.rules
Reading rules file: /etc/udev/rules.d/51-tests.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-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-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-serial.rules
Reading rules file: /usr/lib/udev/rules.d/63-md-raid-arrays.rules
Reading rules file: /usr/lib/udev/rules.d/64-btrfs.rules
Reading rules file: /usr/lib/udev/rules.d/64-md-raid-assembly.rules
Reading rules file: /usr/lib/udev/rules.d/69-dm-lvm-metad.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-uaccess.rules
Reading rules file: /usr/lib/udev/rules.d/71-seat.rules
Reading rules file: /usr/lib/udev/rules.d/73-seat-late.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/78-sound-card.rules
Reading rules file: /usr/lib/udev/rules.d/80-drivers.rules
Reading rules file: /usr/lib/udev/rules.d/80-net-setup-link.rules
Reading rules file: /usr/lib/udev/rules.d/85-regulatory.rules
Reading rules file: /usr/lib/udev/rules.d/90-vconsole.rules
Reading rules file: /usr/lib/udev/rules.d/95-dm-notify.rules
Reading rules file: /usr/lib/udev/rules.d/99-systemd.rules
rules contain 24576 bytes tokens (2048 * 12 bytes), 11755 bytes strings
1710 strings (21440 bytes), 1124 de-duplicated (10272 bytes), 587 trie nodes used
RUN '/usr/bin/hdparm -B 63 -S 36 /dev/%k' /etc/udev/rules.d/50-hdparm.rules:1
GROUP 6 /usr/lib/udev/rules.d/50-udev-default.rules:55
RUN '/usr/bin/touch /tmp/udev-%k' /etc/udev/rules.d/51-tests.rules:1
IMPORT 'ata_id --export /dev/sdb' /usr/lib/udev/rules.d/60-persistent-storage.rules:22
starting 'ata_id --export /dev/sdb'
'ata_id --export /dev/sdb'(out) 'ID_ATA=1'
'ata_id --export /dev/sdb'(out) 'ID_TYPE=disk'
'ata_id --export /dev/sdb'(out) 'ID_BUS=ata'
'ata_id --export /dev/sdb'(out) 'ID_MODEL=ST2000VN000-1HJ164'
'ata_id --export /dev/sdb'(out) 'ID_MODEL_ENC=ST2000VN000-1HJ164\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20'
'ata_id --export /dev/sdb'(out) 'ID_REVISION=SC60'
'ata_id --export /dev/sdb'(out) 'ID_SERIAL=ST2000VN000-1HJ164_W7209GX3'
'ata_id --export /dev/sdb'(out) 'ID_SERIAL_SHORT=W7209GX3'
'ata_id --export /dev/sdb'(out) 'ID_ATA_WRITE_CACHE=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_WRITE_CACHE_ENABLED=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_HPA=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_HPA_ENABLED=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_PM=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_PM_ENABLED=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SECURITY=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SECURITY_ENABLED=0'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=236'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=236'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SMART=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_SMART_ENABLED=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_PUIS=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_PUIS_ENABLED=0'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_APM=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_APM_ENABLED=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=63'
'ata_id --export /dev/sdb'(out) 'ID_ATA_DOWNLOAD_MICROCODE=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_SATA=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_SATA_SIGNAL_RATE_GEN2=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_SATA_SIGNAL_RATE_GEN1=1'
'ata_id --export /dev/sdb'(out) 'ID_ATA_ROTATION_RATE_RPM=5900'
'ata_id --export /dev/sdb'(out) 'ID_WWN=0x5000c5008b32e037'
'ata_id --export /dev/sdb'(out) 'ID_WWN_WITH_EXTENSION=0x5000c5008b32e037'
Process 'ata_id --export /dev/sdb' succeeded.
LINK 'disk/by-id/ata-ST2000VN000-1HJ164_W7209GX3' /usr/lib/udev/rules.d/60-persistent-storage.rules:36
IMPORT builtin 'path_id' /usr/lib/udev/rules.d/60-persistent-storage.rules:54
LINK 'disk/by-path/pci-0000:01:00.0-ata-1' /usr/lib/udev/rules.d/60-persistent-storage.rules:55
IMPORT builtin 'blkid' /usr/lib/udev/rules.d/60-persistent-storage.rules:66
probe /dev/sdb raid offset=0
LINK 'disk/by-id/wwn-0x5000c5008b32e037' /usr/lib/udev/rules.d/60-persistent-storage.rules:73
handling device node '/dev/sdb', devnum=b8:16, mode=0660, uid=0, gid=6
preserve permissions /dev/sdb, 060660, uid=0, gid=6
preserve already existing symlink '/dev/block/8:16' to '../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fata-ST2000VN000-1HJ164_W7209GX3'
creating link '/dev/disk/by-id/ata-ST2000VN000-1HJ164_W7209GX3' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-id/ata-ST2000VN000-1HJ164_W7209GX3' to '../../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-id\x2fwwn-0x5000c5008b32e037'
creating link '/dev/disk/by-id/wwn-0x5000c5008b32e037' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-id/wwn-0x5000c5008b32e037' to '../../sdb'
found 'b8:16' claiming '/run/udev/links/\x2fdisk\x2fby-path\x2fpci-0000:01:00.0-ata-1'
creating link '/dev/disk/by-path/pci-0000:01:00.0-ata-1' to '/dev/sdb'
preserve already existing symlink '/dev/disk/by-path/pci-0000:01:00.0-ata-1' to '../../sdb'
created db file '/run/udev/data/b8:16' for '/devices/pci0000:00/0000:00:02.1/0000:01:00.0/ata3/host2/target2:0:0/2:0:0:0/block/sdb'
.ID_FS_TYPE_NEW=
ACTION=add
DEVLINKS=/dev/disk/by-path/pci-0000:01:00.0-ata-1 /dev/disk/by-id/wwn-0x5000c5008b32e037 /dev/disk/by-id/ata-ST2000VN000-1HJ164_W7209GX3
DEVNAME=/dev/sdb
DEVPATH=/devices/pci0000:00/0000:00:02.1/0000:01:00.0/ata3/host2/target2:0:0/2:0:0:0/block/sdb
DEVTYPE=disk
ID_ATA=1
ID_ATA_DOWNLOAD_MICROCODE=1
ID_ATA_FEATURE_SET_APM=1
ID_ATA_FEATURE_SET_APM_CURRENT_VALUE=63
ID_ATA_FEATURE_SET_APM_ENABLED=1
ID_ATA_FEATURE_SET_HPA=1
ID_ATA_FEATURE_SET_HPA_ENABLED=1
ID_ATA_FEATURE_SET_PM=1
ID_ATA_FEATURE_SET_PM_ENABLED=1
ID_ATA_FEATURE_SET_PUIS=1
ID_ATA_FEATURE_SET_PUIS_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY=1
ID_ATA_FEATURE_SET_SECURITY_ENABLED=0
ID_ATA_FEATURE_SET_SECURITY_ENHANCED_ERASE_UNIT_MIN=236
ID_ATA_FEATURE_SET_SECURITY_ERASE_UNIT_MIN=236
ID_ATA_FEATURE_SET_SMART=1
ID_ATA_FEATURE_SET_SMART_ENABLED=1
ID_ATA_ROTATION_RATE_RPM=5900
ID_ATA_SATA=1
ID_ATA_SATA_SIGNAL_RATE_GEN1=1
ID_ATA_SATA_SIGNAL_RATE_GEN2=1
ID_ATA_WRITE_CACHE=1
ID_ATA_WRITE_CACHE_ENABLED=1
ID_BUS=ata
ID_FS_TYPE=
ID_MODEL=ST2000VN000-1HJ164
ID_MODEL_ENC=ST2000VN000-1HJ164\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20
ID_PART_TABLE_TYPE=gpt
ID_PART_TABLE_UUID=fde78847-0d93-4ab7-bd9c-47d6dff3bf35
ID_PATH=pci-0000:01:00.0-ata-1
ID_PATH_TAG=pci-0000_01_00_0-ata-1
ID_REVISION=SC60
ID_SERIAL=ST2000VN000-1HJ164_W7209GX3
ID_SERIAL_SHORT=W7209GX3
ID_TYPE=disk
ID_WWN=0x5000c5008b32e037
ID_WWN_WITH_EXTENSION=0x5000c5008b32e037
MAJOR=8
MINOR=16
SUBSYSTEM=block
TAGS=:systemd:
USEC_INITIALIZED=5571888
run: '/usr/bin/hdparm -B 63 -S 36 /dev/sdb'
run: '/usr/bin/touch /tmp/udev-sdb'
Unload module index
Unloaded link configuration context.
Como você pode ver (perto do final), o comando
/usr/bin/hdparm -B 63 -S 36 /dev/sdb
é executado.
O problema agora é que os discos não ficam no modo de espera após 3 minutos após a inicialização, ou seja, a opção -S 36
não é aplicada. No entanto, o APM é definido como 63, como mostra hdparm -B
.
Se eu fizer o login como root após o boot e executar o comando hdparm acima novamente, o temporizador de espera será configurado para 3 minutos e os HDs irão, de fato, para o modo de espera conforme o esperado.
Alguma idéia por que hdparm -S 36
não é aplicado se for executado pelo udev durante a inicialização?
Tags udev arch-linux hdparm