On Thu 20 Oct 2022 at 15:32:20 (+0100), Tixy wrote: > On Thu, 2022-10-20 at 17:41 +0700, Max Nikulin wrote: > > On 17/10/2022 22:50, Tixy wrote: > > > # Set spindown time for disk > > > if NAS1=`findmnt -n -o SOURCE /nas1/main`; then /sbin/hdparm -S120 > > > $NAS1; fi > > > > > > Rather than hard code the disk as /dev/sdc I use 'findmnt' to get the > > > disk name from the point it's mounted at (/nas1/main in this case). > > > > Are there known problems with using e.g. WWN (/dev/disk/by-id/... in > > /etc/hdparm.conf) for per-disk configuration? > > I didn't know of /dev/disk/by-id/wwn-* file or of /etc/hdparm.conf > until I just googled that, that looks like they would be designed for > the task. Assuming however that you can rely on udev (?) having already > created those paths before hdparm is run. (I seem to remember having > had race conditions related to those paths in the past.)
>From your post, I don't know how you're running hdparm. But AFAICT, if you run hdparm from udev, you'll see that udev sets up the symlinks at /lib/udev/rules.d/60-persistent-storage.rules and runs hdparm at /lib/udev/rules.d/85-hdparm.rules so in this case, you shouldn't get a race. > In my case, I spread out wear by rotating disks through different uses: > main NAS drive, nearline backup mirror of that, and offline backup. So > I decided rather than mount by UUID or similar, I'd mount by filesystem > label instead, then I could just relabel the disks when I rotated them. > > Of course, having just written that, I realise I don't need findmnt and > can just use the label in /dev/disk/by-label/ (again, assuming they > exist in time). Cheers, David.