adelolmo/hd-idle

Question / Clarification: How does hd-idle parse options (disks vs. partitions, LUKS, precedence in case of contradictions)

Closed this issue · 1 comments

ph1248 commented

Hello adelolmo,

I'm a bit confused about how to specify disks in the hd-idle options.

I found a comment of yours in an older issue:

One thing about using symlinks:
Please make sure that the symlink resolves to a disk and not to a partition.
tree /dev/disk/
tree shows the structure of the devices and resolves the symlinks. Make sure to use only synlinks resolving to e.g. ../../sda and not to ../../sda1.
hd-idle won't apply specific configuration to devices if the symlinks don't resolve to disks. Instead it will use the default configuration."

Originally posted by @adelolmo in #9 (comment)

This is what I take away from the comment:

If an option specify a partition and not a disk, hd-idle will ignore this option, but uses the default parameters instead.
If an option specifies a disk, hd-idle will use this option to override the default parameters for this disk.

Do I understand this right?

Now I have some questions:

  1. I don't understand how LUKS container fit into this concept. I have a disk (Samsung EVO 840 SSD, here as sda) with two LUKS partitions (please don't be confused that they are called sdb1_crypt / sdb2_crypt even though they are now listed as sda1 and sda2; apparently the list was different during installation):
root@server:/dev/disk# tree /dev/disk
/dev/disk
|-- by-diskseq
|   |-- 1 -> ../../sda
|   |-- 10 -> ../../loop6
|   |-- 11 -> ../../loop7
|   |-- 12 -> ../../sdb
|   |-- 13 -> ../../sdc
|   |-- 4 -> ../../loop0
|   |-- 5 -> ../../loop1
|   |-- 6 -> ../../loop2
|   |-- 7 -> ../../loop3
|   |-- 8 -> ../../loop4
|   `-- 9 -> ../../loop5
|-- by-id
|   |-- ata-2GB_ATA_Flash_Disk_C191147937A1Yk99G8Jd -> ../../sdb
|   |-- ata-2GB_ATA_Flash_Disk_C191147937A1Yk99G8Jd-part1 -> ../../sdb1
|   |-- ata-Samsung_SSD_840_EVO_250GB_S1DBNSBD909545X -> ../../sda
|   |-- ata-Samsung_SSD_840_EVO_250GB_S1DBNSBD909545X-part1 -> ../../sda1
|   |-- ata-Samsung_SSD_840_EVO_250GB_S1DBNSBD909545X-part2 -> ../../sda2
|   |-- dm-name-sdb1_crypt -> ../../dm-0
|   |-- dm-name-sdb2_crypt -> ../../dm-1
|   |-- dm-uuid-CRYPT-LUKS2-00065115XXXXXXXXXXXXXXXXXXXXXXXX-sdb1_crypt -> ../../dm-0
|   |-- dm-uuid-CRYPT-LUKS2-4fd4a67cXXXXXXXXXXXXXXXXXXXXXXXX-sdb2_crypt -> ../../dm-1
|   |-- usb-Seagate_Expansion_Desk_NAAAXL51-0:0 -> ../../sdc
|   |-- usb-Seagate_Expansion_Desk_NAAAXL51-0:0-part1 -> ../../sdc1
|   |-- usb-Seagate_Expansion_Desk_NAAAXL51-0:0-part2 -> ../../sdc2
|   |-- wwn-0x50025388a003c78a -> ../../sda
|   |-- wwn-0x50025388a003c78a-part1 -> ../../sda1
|   `-- wwn-0x50025388a003c78a-part2 -> ../../sda2
|-- by-label
|   |-- backup_glienicke -> ../../sdc2
|   |-- boot -> ../../sdb1
|   |-- debian12 -> ../../dm-0
|   `-- sammlungen -> ../../sdc1
|-- by-partlabel
|   |-- debian12 -> ../../sda1
|   `-- swap -> ../../sda2
|-- by-partuuid
|   |-- 56841497-01 -> ../../sdb1
|   |-- 591281fc-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sda1
|   |-- 91816802-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sdc2
|   |-- 934fd9c0-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sdc1
|   `-- e45cf2b9-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sda2
|-- by-path
|   |-- pci-0000:00:1a.7-usb-0:1:1.0-scsi-0:0:0:0 -> ../../sdc
|   |-- pci-0000:00:1a.7-usb-0:1:1.0-scsi-0:0:0:0-part1 -> ../../sdc1
|   |-- pci-0000:00:1a.7-usb-0:1:1.0-scsi-0:0:0:0-part2 -> ../../sdc2
|   |-- pci-0000:00:1f.2-ata-2 -> ../../sdb
|   |-- pci-0000:00:1f.2-ata-2-part1 -> ../../sdb1
|   |-- pci-0000:00:1f.2-ata-2.0 -> ../../sdb
|   |-- pci-0000:00:1f.2-ata-2.0-part1 -> ../../sdb1
|   |-- pci-0000:00:1f.5-ata-1 -> ../../sda
|   |-- pci-0000:00:1f.5-ata-1-part1 -> ../../sda1
|   |-- pci-0000:00:1f.5-ata-1-part2 -> ../../sda2
|   |-- pci-0000:00:1f.5-ata-1.0 -> ../../sda
|   |-- pci-0000:00:1f.5-ata-1.0-part1 -> ../../sda1
|   `-- pci-0000:00:1f.5-ata-1.0-part2 -> ../../sda2
`-- by-uuid
    |-- 00065115-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sda1
    |-- 0207a61d-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../dm-0
    |-- 0e8959cc-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../dm-1
    |-- 308f6684-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sdb1
    |-- 4230f530-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sdc2
    |-- 4fd4a67c-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sda2
    `-- fb5d2e03-XXXX-XXXX-XXXX-XXXXXXXXXXXX -> ../../sdc1

Output from lsblk:

root@server:# lsblk /dev/sd* -o PATH,FSSIZE,LABEL,UUID,PARTLABEL,PARTUUID,MODEL,SIZE,SERIAL,TYPE,WWN
PATH          FSSIZE LABEL   UUID                                 PARTLABEL PARTUUID                             MODEL   SIZE SERIAL TYPE  WWN
/dev/sda                                                                                                         Samsu 232.9G S1DBNS disk  0x50025388a003c78a
/dev/sda1                    00065115-XXXX-XXXX-XXXX-XXXXXXXXXXXX debian12  591281fc-XXXX-XXXX-XXXX-XXXXXXXXXXXX       229.1G        part  0x50025388a003c78a
/dev/sda1                    00065115-XXXX-XXXX-XXXX-XXXXXXXXXXXX debian12  591281fc-XXXX-XXXX-XXXX-XXXXXXXXXXXX       229.1G        part  0x50025388a003c78a
/dev/sda2                    4fd4a67c-XXXX-XXXX-XXXX-XXXXXXXXXXXX swap      e45cf2b9-XXXX-XXXX-XXXX-XXXXXXXXXXXX         3.8G        part  0x50025388a003c78a
/dev/sda2                    4fd4a67c-XXXX-XXXX-XXXX-XXXXXXXXXXXX swap      e45cf2b9-XXXX-XXXX-XXXX-XXXXXXXXXXXX         3.8G        part  0x50025388a003c78a
/dev/sdb                                                                                                         2GB A   1.9G C19114 disk
/dev/sdb1     919.7M boot    308f6684-XXXX-XXXX-XXXX-XXXXXXXXXXXX           56841497-01                                  953M        part
/dev/sdb1     919.7M boot    308f6684-XXXX-XXXX-XXXX-XXXXXXXXXXXX           56841497-01                                  953M        part
/dev/sdc                                                                                                         Expan   7.3T NAAAXL disk
/dev/sdc1            sammlungen
                             fb5d2e03-XXXX-XXXX-XXXX-XXXXXXXXXXXX           934fd9c0-XXXX-XXXX-XXXX-XXXXXXXXXXXX         2.5T        part
/dev/sdc1            sammlungen
                             fb5d2e03-XXXX-XXXX-XXXX-XXXXXXXXXXXX           934fd9c0-XXXX-XXXX-XXXX-XXXXXXXXXXXX         2.5T        part
/dev/sdc2            backup_glienicke
                             4230f530-XXXX-XXXX-XXXX-XXXXXXXXXXXX           91816802-XXXX-XXXX-XXXX-XXXXXXXXXXXX         2.5T        part
/dev/sdc2            backup_glienicke
                             4230f530-XXXX-XXXX-XXXX-XXXXXXXXXXXX           91816802-XXXX-XXXX-XXXX-XXXXXXXXXXXX         2.5T        part
/dev/mapper/sdb1_crypt
              229.1G debian12
                             0207a61d-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                      229.1G        crypt
/dev/mapper/sdb1_crypt
              229.1G debian12
                             0207a61d-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                      229.1G        crypt
/dev/mapper/sdb2_crypt
                             0e8959cc-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                        3.8G        crypt
/dev/mapper/sdb2_crypt
                             0e8959cc-XXXX-XXXX-XXXX-XXXXXXXXXXXX                                                        3.8G        crypt

I would like to set up a default option to spin down all disks after 10 minutes, but not the ATA Flash disk (with the boot partition) and not the samsung SSD (with the two encrypted partitions). I would like to avoid using sda, sdb etc since I have the impression that these names could change over time.

Would the following line in the configuration file be correct?

HD_IDLE_OPTS="-i 600 -a /dev/disk/by-id/ata-2GB_ATA_Flash_Disk_C191147937A1Yk99G8Jd -i 0 -a /dev/disk/by-id/ata-Samsung_SSD_840_EVO_250GB_S1DBNSBD909545X -i 0"
START_HD_IDLE=true

Is there a better way to do it?

  1. Question: what does hd-idle do if there are contradicting options? E.g. if one would specify different options for the same disk, but one time via by-id and one time via dev/sdx?

Thanks for a clarification!
Philipp

Hi @ph1248

Sorry for the late answer but my head spins around with this kind of questions.

Honestly, every time that someone asks about devices, partitions, links and such, I jump into the test written for processing /proc/diskstats: https://github.com/adelolmo/hd-idle/blob/master/diskstats/snapshot_test.go
One piece omitted in the test is the device mapping to link LUKS devices to physical devices (which is resolved with the mock mockGetDiskHolder in the test).

About your second question: Your configuration approach makes sense. Default to 600s and use links for the disks you don't want to spin down.
The configuration is read in a loop, so the latest entry will override whatever configured previously.

I hope this brings some light and sorry if I sound too vague.
Andoni