doc:appunti:hardware:raspberrypi_nas_smart_hard_disk
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| doc:appunti:hardware:raspberrypi_nas_smart_hard_disk [2021/03/10 11:42] – niccolo | doc:appunti:hardware:raspberrypi_nas_smart_hard_disk [2025/10/10 11:24] (current) – [udisks2.service] niccolo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Raspberry Pi NAS: Hard disk management ====== | ====== Raspberry Pi NAS: Hard disk management ====== | ||
| - | ===== smartctl | + | This page is about configuring the **hard disk power management** on a Raspberry Pi, to be used as NAS and mediacenter. The hard disk is connected via a **[[raspberrypi_nas_x835_sata_board|SupTronics X835 shield]]**. See the main index at **[[raspberrypi_nas]]**. The operating system is **RaspiOS** based on **Debian 11 Bullseye**. |
| + | |||
| + | There are two tools to manage SATA disks in GNU/Linux. **smartctl** is designed to interact with the **[[wp> | ||
| + | |||
| + | ===== smartctl ===== | ||
| The **smartctl** tool from the **smartmontools** package requires the **%%-d sat%%** option to access the hard disk through the USB bridge with the right protocol. | The **smartctl** tool from the **smartmontools** package requires the **%%-d sat%%** option to access the hard disk through the USB bridge with the right protocol. | ||
| Line 16: | Line 20: | ||
| # Disable DEVICESCAN, which does not work in our environment. | # Disable DEVICESCAN, which does not work in our environment. | ||
| #DEVICESCAN -d removable -n standby -m root -M exec / | #DEVICESCAN -d removable -n standby -m root -M exec / | ||
| - | |||
| - | # Send an email test to < | ||
| - | /dev/sda -d sat -m root@localhost -M test | ||
| # Use the suggedested subset of checks, instead of the ' | # Use the suggedested subset of checks, instead of the ' | ||
| + | # NOTICE: We are running smartd with option --interval=3600 instead of the | ||
| + | # 1800 default, i.e. device polling occurs every 1 our instead of 30 minutes. | ||
| + | # The number of skipped checks (option -n) must be multipled by that value | ||
| + | # to obtain the maximum time that checks will be skipped: | ||
| + | # 336 * 3600 seconds = 14 days. | ||
| /dev/sda -d sat \ | /dev/sda -d sat \ | ||
| -H \ # Check the health with the SMART RETURN STATUS command | -H \ # Check the health with the SMART RETURN STATUS command | ||
| Line 27: | Line 33: | ||
| -f \ # Check for ' | -f \ # Check for ' | ||
| -n standby,336 \ # Skip smartd checks during standby (max 336 times, add ', | -n standby,336 \ # Skip smartd checks during standby (max 336 times, add ', | ||
| - | -W 0,50,60 \ # Report | + | -W 0,50,60 \ # Temperature |
| -s S/ | -s S/ | ||
| + | -s O/ | ||
| -m root@localhost \ # Send a warning email on failures and errors | -m root@localhost \ # Send a warning email on failures and errors | ||
| -M daily \ # Repeat email warnings daily | -M daily \ # Repeat email warnings daily | ||
| Line 41: | Line 48: | ||
| Restart the **smartd.service** and verify that the **smartd** program is running with that paramter (3600 seconds, i.e. one hour, instead of 30 minutes). | Restart the **smartd.service** and verify that the **smartd** program is running with that paramter (3600 seconds, i.e. one hour, instead of 30 minutes). | ||
| + | |||
| + | At each cycle, all the **%%-s%%** options are check for a match, the first match will be executed and the remaining are ignored. | ||
| The syntax for the **%%-s%%** option (test scheduling) is as follow: | The syntax for the **%%-s%%** option (test scheduling) is as follow: | ||
| Line 56: | Line 65: | ||
| </ | </ | ||
| - | To set the **Advanced Power Management** level use the **%%-B%%** option, the maximum performance level which **permits spin-down** of the drive is 127: | + | We should use the **background test mode**, which does not interrupt normal disk activity. |
| + | |||
| + | | ||
| + | | ||
| + | * **Conveyance Test** (ATA only): a few minutes to check for damages incurred during transporting | ||
| + | * **Offline Immediate | ||
| + | |||
| + | If you want to display the log e.g. of self-test executed, run: | ||
| < | < | ||
| - | hdparm | + | smartctl |
| </ | </ | ||
| - | Regardless of the APM level, we can set the hard disk **Standby timer** (spindown) after 30 minutes of inactivity. See **man hdparm** for explanation of the number following the **%%-S%%** option (it seems that there is not way to know the timeout once you have set it): | + | The output |
| < | < | ||
| - | hdparm | + | === START OF READ SMART DATA SECTION === |
| + | SMART Self-test log structure revision number 1 | ||
| + | Num Test_Description | ||
| + | # 1 Short offline | ||
| + | # 2 Short offline | ||
| + | # 3 Short offline | ||
| + | # 4 Conveyance offline | ||
| </ | </ | ||
| - | **WARNING**: | ||
| - | Enable | + | ===== hdparm ===== |
| + | |||
| + | To set the **Advanced Power Management** level use the **%%-B%%** option. A low value means aggressive power management, an high value means better performance. The maximum performance level which **permits spin-down** of the drive is 127: | ||
| < | < | ||
| - | hdparm -M 128 /dev/sda | + | hdparm -B 127 /dev/sda |
| </ | </ | ||
| - | **Check** whether | + | Regardless of the APM level, we can set the hard disk **Standby timer** (spindown) after 30 minutes of inactivity. See **man hdparm** for explanation of the number following |
| < | < | ||
| - | smartctl | + | hdparm |
| </ | </ | ||
| - | The meaning of **standby,3** is: **do not check** the disk if it is in **SLEEP** or **STANDBY** mode (not spinning), return **exit code 3** in this case (you can choose your custom exit code). Beside the exit code, these are the output messages: | + | **WARNING**: If both **APM** and the **Standby timer** are set, then the device shall go to the Standby state when the timer expires |
| - | < | + | Enable the **most quiet acoustic management** (it is **not supported** |
| - | Device | + | |
| - | </ | + | |
| < | < | ||
| - | Device is in STANDBY mode, exit(3) | + | hdparm -M 128 /dev/sda |
| </ | </ | ||
| - | **WARNING**: | + | Debian provides the file **/ |
| - | + | ||
| - | Debian provides the file **/ | + | |
| < | < | ||
| Line 100: | Line 119: | ||
| # It is advisable to disable write cache in this case. | # It is advisable to disable write cache in this case. | ||
| # See man hdparm(8), -S and -W options. | # See man hdparm(8), -S and -W options. | ||
| + | # The granularity of the spindown_time up to 20 minutes is 5 | ||
| + | # seconds, above that threshold it is 30 minutes. | ||
| /dev/sda { | /dev/sda { | ||
| write_cache = off | write_cache = off | ||
| Line 111: | Line 132: | ||
| DEVNAME=/ | DEVNAME=/ | ||
| </ | </ | ||
| + | |||
| + | ===== Querying the disk status ===== | ||
| + | |||
| + | **Check** whether the drive is in **standby** mode, without waking it up: | ||
| + | |||
| + | < | ||
| + | smartctl -d sat --nocheck=standby, | ||
| + | </ | ||
| + | |||
| + | The meaning of **standby, | ||
| + | |||
| + | < | ||
| + | Device is in ACTIVE or IDLE mode | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | Device is in STANDBY mode, exit(3) | ||
| + | </ | ||
| + | |||
| + | **WARNING**: | ||
| **WARNING**: | **WARNING**: | ||
| Line 119: | Line 160: | ||
| * **updatedb** - Execute by the **/ | * **updatedb** - Execute by the **/ | ||
| - | * **smartctl** - Reading SMART attributes (e.g. disk temperature, | + | * **smartctl** - Reading SMART attributes (e.g. disk temperature, |
| + | |||
| + | ===== udisks2.service ===== | ||
| + | |||
| + | It seems that the **udisks2.service** may interfere with the hard disk spin-down feature. The '' | ||
| + | |||
| + | It is likely that the hdparm options set by **udev** on system start are overridden by udisks2. In a [[..: | ||
| + | |||
| + | Some useful udisks2 commands: | ||
| + | |||
| + | < | ||
| + | udisksctl info -b /dev/sda3 | ||
| + | </ | ||
| ===== Web References ===== | ===== Web References ===== | ||
| * **[[https:// | * **[[https:// | ||
| + | * **[[https:// | ||
| + | * **[[https:// | ||
| + | * **[[https:// | ||
doc/appunti/hardware/raspberrypi_nas_smart_hard_disk.1615372932.txt.gz · Last modified: by niccolo
