{"id":533,"date":"2022-03-26T19:58:33","date_gmt":"2022-03-26T19:58:33","guid":{"rendered":"https:\/\/andrejacobs.org\/?p=533"},"modified":"2022-04-11T20:22:59","modified_gmt":"2022-04-11T20:22:59","slug":"spinning-down-seagate-hard-drives-in-ubuntu-20-04","status":"publish","type":"post","link":"https:\/\/andrejacobs.org\/linux\/spinning-down-seagate-hard-drives-in-ubuntu-20-04\/","title":{"rendered":"Spinning down Seagate Hard Drives in Ubuntu 20.04"},"content":{"rendered":"\n
Photo by Denny M\u00fcller<\/a> on Unsplash<\/a><\/p>\n\n\n\n I noticed that none of my Seagate Hard Drives were spinning down while being idle. This is after I upgraded to Ubuntu 20.04 as well as installing completely new drives. For some reason or other My Linux server runs 24\/7 and most of the time the hard drives are idle. So for me it is important to save as much power as needed while at the same time to not wear the drives out by constantly loading and unloading the heads.<\/p>\n NOTE:<\/strong> Some of my scripts can be found here<\/a>.<\/p>\n This being Linux, I just know things are never going to be easy and most of the time you end up deep diving and learning a ton of stuff along the way (whether it is useful or not).<\/p>\n Turns out that Seagate has free and open source tools for Linux to manage their drives.<\/p>\n https:\/\/github.com\/Seagate\/openSeaChest<\/a><\/p>\n The next steps will show you how I installed it on Ubuntu 20.04.<\/p>\n Looking at this I can see that none of the new drives have a timer set to go into Idle C or Standby Z mode.<\/p>\n Disable writing file and directory access times to disk. As mentioned earlier that directories like hdparm<\/code> no longer seem to be working on my system.<\/p>\n
What have I tried?<\/h3>\n
\n
sudo hdparm -y \/dev\/___<\/code> with no issues.<\/li>\n
\/proc\/sys\/vm\/block_dump<\/code> and that monitors the power state of each drive.<\/li>\n
inotify-tools<\/code> and wrote a script to log which directories are being accessed and at what time. This did reveal that
lost+found<\/code> is accessed at 12am and 8am everyday like clockwork.<\/li>\n
\/usr\/lib\/hdparm\/hdparm-functions<\/code> .<\/li>\n
hdparm<\/code> and instrumented the scripts with logging to a file to see what is going on. Note that at this point I have tried many many things.<\/li>\n
udev<\/code> commands to run
hdparm<\/code> and also tried
openSeaChest<\/code>.<\/li>\n
What worked?<\/h3>\n
\n
openSeaChest<\/code> to set the different timers for the newer Seagate IronWolf and IronWolf Pro drives. More details in the next section.<\/li>\n
hd-idle<\/code> to manage the older Seagate drives.<\/li>\n
noatime<\/code> flag when mounting the
ext4<\/code> filesystem.
noatime<\/code> specifies that the access time for files and directories should not be written. This solved the
lost+found<\/code> directories being accessed everyday at 12am and 8am and that results in the drives being spin up.<\/li>\n<\/ul>\n
Seagate\u2019s openSeaChest tools<\/h2>\n
\n
$ sudo apt-get install python3 python3-pip python3-setuptools python3-wheel ninja-build\n$ pip3 install --user meson\n<\/code><\/pre>\n
\n
$ git clone --recurse-submodules -j8 https:\/\/github.com\/Seagate\/openSeaChest.git\n$ cd openSeaChest\/\n\n$ \/home\/andre\/.local\/bin\/meson --buildtype=release builddir\n$ ninja -C builddir\n\n# All the binaries are located inside the builddir directory\n<\/code><\/pre>\n
\n
$ sudo .\/openSeaChest_Info -d \/dev\/___ -i\n<\/code><\/pre>\n
\n
# Most of my drives don't have APM (so this is useless)\n$ sudo .\/openSeaChest_PowerControl -d \/dev\/___ --showAPMLevel\n$ sudo .\/openSeaChest_PowerControl -d \/dev\/___ --setAPMLevel 127\n<\/code><\/pre>\n
\n
$ sudo .\/openSeaChest_PowerControl -d \/dev\/___ --checkPowerMode\n<\/code><\/pre>\n
\n
$ sudo .\/openSeaChest_PowerControl -d \/dev\/___ --showEPCSettings\n\n===EPC Settings===\n\t* = timer is enabled\n\tC column = Changeable\n\tS column = Savable\n\tAll times are in 100 milliseconds\n\nName Current Timer Default Timer Saved Timer Recovery Time C S\nIdle A *1 *1 *1 1 Y Y\nIdle B *1200 *1200 *1200 4 Y Y\nIdle C 0 6000 6000 37 Y Y\nStandby Z 0 9000 9000 105 Y Y\n<\/code><\/pre>\n
\n
$ sudo .\/openSeaChest_PowerControl -d \/dev\/... --idle_c 600000 --standby_z 1800000\n\n$ sudo .\/openSeaChest_PowerControl -d \/dev\/... --showEPCSettings\n...\n===EPC Settings===\n\t* = timer is enabled\n\tC column = Changeable\n\tS column = Savable\n\tAll times are in 100 milliseconds\n\nName Current Timer Default Timer Saved Timer Recovery Time C S\nIdle A *1 *1 *1 1 Y Y\nIdle B *1200 *1200 *1200 4 Y Y\nIdle C *6000 6000 *6000 37 Y Y\nStandby Z *18000 9000 *18000 105 Y Y\n<\/code><\/pre>\n
\n
noatime<\/h2>\n
lost+found<\/code> gets accessed periodically and then the drives get woken up just to write the access times.<\/p>\n
$ sudo vi \/etc\/fstab\n\n# Add noatime option to each drive\n...\n\/dev\/mapper\/megalodon \/media\/megalodon ext4 defaults,noatime 0 2\n<\/code><\/pre>\n
smartd scans the drives every 30 minutes<\/h2>\n