Hard drive babysitting on linux



  • Hey everyone,

    I'm currently trying my hands on a small home server use as tivo, file storage and general linux tinkering tool. I've got a few configuration headaches however, and, since I'm still kind of a linux n00b, I'd like to ask if you guys have an idea.



    For OS, I'm using Arch Linux 3.8. Storage-wise, my setup consists of an SSD for the OS and two 500GB hard drives for data.

    As the data disks are quite noisy and will be accessed relatively rarely, I'd like to keep them spun down most of the time. After some playing around with hdparm, I found that the disks spin down perfectly fine if I tell them to (via hdparm -y) but don't seem to ever spin down on their own. Changed settings via hdparm -S or -B have no noticeable effect at all.



    The disks are basically empty and they stay off after I've put them into standby manually. That's why I suspect it's a hardware issue and not anything constantly accessing them.



    To work around this, I thought of writing a script that periodically checks disk activity and calls hdparm -y if one of the disks hasn't been accessed for a certain time.



    So, long story short, my questions are:

    • Is there any command or utility in linux that I can use to get the last access time for filesystems or block devices?
    • Is my approach the Real WTF? Are there additional settings I should check first? Is there already a daemon that does something like this?



      If, by any chance, we have any resident Linux geeks here (that haven't been scared away yet by blakeyrat) who could give some advice about this sort of stuff, I'd be very thankful.

  • Discourse touched me in a no-no place

    http://info4admins.com/tips-to-spindown-your-hard-disk-in-debian-or-ubuntu/: I'm assuming that since these are data disks you can ignore the services/logs stuff, but do you have the noatime option set on those mounts? Also do you have spindown_time set in /etc/hdparm.conf?



  • @PSWorx said:

    I'm currently trying my hands on a small home server use as tivo, file storage and general linux tinkering tool.
     

    You looked into any distros that are purpose-built with those uses in mind? Just tihnking of freeNAS, or an HTPC-type machine. They may already have this kinda thing covered.



  • @PJH said:

    http://info4admins.com/tips-to-spindown-your-hard-disk-in-debian-or-ubuntu/

    Well, like you said, the logs/cache/etc should be on the SSD, not on the disks. The kernel options looks quite useful though.

    @PJH said:

    do you have the noatime option set on those mounts?

    yup - that is, I think so. The disks are managed by lvm2 and are exposed as a single logical 1TB volume. I'm mounting that volume with noatime. I shouldn't need to tell lvm anything about noatime, should I?

    @PJH said:

    Also do you have spindown_time set in /etc/hdparm.conf?

    Didn't know of that option yet. Though, if I read this correctly, doesn't this just set the same timer hdparm -S does? I've already tried the latter without any effect. (And yes, APM is 127)

    @Cassidy said:

    You looked into any distros that are purpose-built with those uses in mind? Just tihnking of freeNAS, or an HTPC-type machine. They may already have this kinda thing covered.


    Well, part of the reason I'm doing this is to have a fun way to get more familiar with the linux utils, standard daemons, init process, etc. Hence I don't necessarily want to reinvent the wheel, but I would like to know what exactly is running on the system, why, and why it's configured the way it is. I also might use this box for some other things than a media center later on. I'd rather not use a ready-to-go distro where I've no idea which settings I can safely change without stuff breaking in obscure ways.



  • @PSWorx said:

    I'm mounting that volume with noatime. I shouldn't need to tell lvm anything about noatime, should I?
     

    Not AFAIK. "noatime" is a mount option, not a LVM option.

     



  • Check out the -S option to hdparm. If your hardware is anything approaching new, it should work. Be sure to read the man page for the -S option, the way you specify time is really fucked-in-the-head.

    Also consider checking out the -M option to hdparm. It will let you control how fast the head moves, which may reduce your noise to acceptable levels without having to spin down the HDD.

    All of this assumes you've nuked anything that is doing frequent I/O on the drive. Obviously spinning down doesn't do much good if some process is constantly spinning the disk back up.



  • @morbiuswilters said:

    Check out the -S option to hdparm. If your hardware is anything approaching new, it should work. Be sure to read the man page for the -S option, the way you specify time is really fucked-in-the-head.

    Previously on this thread:
    @PSWorx said:
    Changed settings via hdparm -S or -B have no noticeable effect at all.

    @PSWorx said:
    Didn't know of that option yet. Though, if I read this correctly, doesn't this just set the same timer hdparm -S does? I've already tried the latter without any effect. (And yes, APM is 127)

    So yeah, I tried that already and even if I set it to APM 1, timeout 5s (according to the manpages), no spindown happened.


    @morbiuswilters said:

    Also consider checking out the -M option to hdparm. It will let you control how fast the head moves, which may reduce your noise to acceptable levels without having to spin down the HDD.



    Hmm, will try out that one, thanks.

    @morbiuswilters said:

    All of this assumes you've nuked anything that is doing frequent I/O on the drive. Obviously spinning down doesn't do much good if some process is constantly spinning the disk back up.

    I've not yet installed anything that should access the drive on its own. I'm reasonably sure that's the case because the drives don't spin up on their own either after I've shut them down manually (as I they should do if something was accessing stuff on them).



  • @PSWorx said:

    @morbiuswilters said:
    Check out the -S option to hdparm. If your hardware is anything approaching new, it should work. Be sure to read the man page for the -S option, the way you specify time is really fucked-in-the-head.

    Previously on this thread:
    @PSWorx said:
    Changed settings via hdparm -S or -B have no noticeable effect at all.

    @PSWorx said:
    Didn't know of that option yet. Though, if I read this correctly, doesn't this just set the same timer hdparm -S does? I've already tried the latter without any effect. (And yes, APM is 127)

    So yeah, I tried that already and even if I set it to APM 1, timeout 5s (according to the manpages), no spindown happened.

    You can't really expect me to read your entire problem, can you? This is FOSS--I'm going to read the first sentence, assume you are too stupid to read a manual, give the most perfunctory answer and close as "User error".

    @PSWorx said:

    I've not yet installed anything that should access the drive on its own. I'm reasonably sure that's the case because the drives don't spin up on their own either after I've shut them down manually (as I they should do if something was accessing stuff on them).

    Yeah, your assumption sounds fine, if something was accessing it should trigger it to spin back up when you shut it down manually. Obvious question: you are using -S on the actual device nodes (/dev/sdX, most likely) and not on the LVM device, right? I mean, if you got it to work with -y you're surely doing it on the actual device nodes.

    Does dmesg show anything interesting after you try -S? It might be like "Hey, fuck you, your BIOS doesn't support that shit." It might be something you can enable in the BIOS (hell, in some newer BIOSes you can just set the spin down time for a HDD there and not have the OS worry about it at all--very nice for OSes like Linux where support for options like this is weak, at best.) Might as well check /var/log/{syslog,messages} as well, since something interesting might log there.

    I've never had to do this before. All my home Linux machines are SSDs and every server I've ever worked with was in a DC so it could sound like a jet taking all for all I care.



  • @morbiuswilters said:

    Obvious question: you are using -S on the actual device nodes (/dev/sdX, most likely) and not on the LVM device, right?
     

    Batted back atcha with just as daft a question: does LVM do any periodic accessing of the PVs themselves, even if the LVs aren't in use? Just thinking of how the VGDA is checked, and how often.



  • @Cassidy said:

    Batted back atcha with just as daft a question: does LVM do any periodic accessing of the PVs themselves, even if the LVs aren't in use? Just thinking of how the VGDA is checked, and how often.

    I doubt it, since he can manually spin down the disks. I hate LVM so I don't have a ton of experience using it, but I'd imagine volume metadata like the VGDA is kept in kernel memory. It should only have to read that stuff in when a volume is attached, I'd hope.



  • @morbiuswilters said:

    I hate LVM so I don't have a ton of experience using it,
     

    Aha, okay - I liked using it under AIX and was dead happy to see it ported over to Linux but still haven't found a great many people that use it.@morbiuswilters said:

    I'd imagine volume metadata like the VGDA is kept in kernel memory. It should only have to read that stuff in when a volume is attached, I'd hope.

    Was my thinking also, but  ISTR that AIX periodically scans the PVs to see if they've changed in any way (and compares the actual VGDAs against memcached stuff) so wondered if Linux's LVM does that. Or rather, wondered if you'd know this stuff to that level.

     


Log in to reply