| 1 | == How to check a disk's health == |
| 2 | |
| 3 | ==== SATA Disks ==== |
| 4 | |
| 5 | To check a SATA Disk (either HDD or SSD) we can use the `smartctl` utility: |
| 6 | |
| 7 | * Install with: `apt install smartmontools` |
| 8 | * `smartctl -a /dev/sdX` to see all the information about the disk |
| 9 | * `smartctl -t <short|long> /dev/sdX` to run a short or long test |
| 10 | * `smartctl -X /dev/sdX` to abort a test |
| 11 | |
| 12 | ==== NVMe disks ==== |
| 13 | |
| 14 | `smartctl` can work for NVMe disks but cannot run any tests like above. |
| 15 | |
| 16 | We can use the `nvme` utility to see information about nvme disks. |
| 17 | |
| 18 | * Install with: `apt install nvme-cli` |
| 19 | * `nvme list` shows the nvme disks on the machine |
| 20 | * `nvme smart-log /dev/nvmeXnX` shows the SMART information about the disk. |
| 21 | |
| 22 | More info on the `nvme` utility: [https://nvmexpress.org/open-source-nvme-management-utility-nvme-command-line-interface-nvme-cli/ here] |
| 23 | |
| 24 | ==== Check disk r/w speed ==== |
| 25 | |
| 26 | Read speed: `hdparm -tT /dev/sdX` (or `nvmeXnX`) |
| 27 | Write speed: `dd if=/dev/zero of=test bs=1G count=1 oflag=direct` (`test` must be on the disk) |
| 28 | |
| 29 | ==== badblocks ==== |
| 30 | |
| 31 | We can check for bad blocks through (works with NVMe and SATA): |
| 32 | `badblocks -v -o output_file /dev/sdX` |