متقدم
البحث فيأدلة «كيف»
طريقة البحث
  • اكتب المهمة بكلماتك (find port، open firewall، disk full) أو الصق رسالة الخطأ بين علامتي تنصيص.
  • اختر «الإجابة السريعة» لترى الأوامر فقط، أو مجالًا لتبقى في مجال واحد.
  • "كلمتان" تجد العبارة بالضبط.
  • الكلمات العادية تجد الأسماء والنصوص والأمثلة.
  • ↑ ↓ للتنقل · Enter للفتح · Esc للإغلاق · / للبحث
جرّب:

كيف 107System · Storage

How to check the health of a disk

Disks warn before they die: reallocated sectors, read errors, an SSD that is almost worn out. SMART data shows this, and the kernel log shows I/O errors. This how-to reads the health of SATA/SAS and NVMe disks with smartctl, knows the few values that really matter, checks a software RAID, and turns on monitoring so you get a mail before the failure.

  • 5 الدروس
  • 7 الأوامر

هذا الجزء لم يُترجم بعد. أنت ترى النص الإنجليزي.

$ مستخدم عادي# بصلاحية root (أو مع sudo)

107.1

The quick answer

dnf -y install smartmontools
smartctl -H /dev/sda
SMART overall-health self-assessment test result: PASSED
smartctl -a /dev/sda | grep -Ei 'Reallocated_Sector|Current_Pending|Offline_Uncorrectable|Power_On_Hours'
smartctl -a /dev/nvme0
dmesg -T | grep -Ei 'I/O error|medium error|reset' | tail

On Ubuntu: apt-get install -y smartmontools.

107.2

Step by step

  1. List the disks:
lsblk -d -o NAME,MODEL,SIZE,ROTA,TRAN
smartctl --scan

ROTA 1 = spinning disk (HDD), 0 = SSD/NVMe.

  1. The overall verdict (-H) — PASSED is not a guarantee; FAILED means replace now.
  2. The values that matter:
Attribute (HDD/SATA SSD)Bad sign
Reallocated_Sector_CtGrowing above 0 — the disk is replacing bad sectors.
Current_Pending_Sector> 0 — sectors that could not be read.
Offline_Uncorrectable> 0 — data could not be read back.
UDMA_CRC_Error_CountGrowing — often the cable, not the disk.
NVMe fieldBad sign
Critical WarningNot 0x00.
Percentage UsedNear 100 % — the SSD is worn out.
Media and Data Integrity Errors> 0.
  1. Run a self-test (the disk keeps working meanwhile):
smartctl -t short /dev/sda
smartctl -l selftest /dev/sda

short takes ~2 minutes; long can take hours.

  1. Software RAID (mdadm) — is an array degraded?
cat /proc/mdstat
md0 : active raid1 sdb1[1] sda1[0]
      976630464 blocks super 1.2 [2/2] [UU]
mdadm --detail /dev/md0

[UU] = both disks fine; [U_] = one disk missing — replace it now.

  1. Monitor automatically — smartd checks the disks and mails on problems:
/etc/smartmontools/smartd.conf
DEVICESCAN -a -o on -S on -s (S/../.././02|L/../../6/03) -m ops@example.com
systemctl enable --now smartd

(On Ubuntu the file is /etc/smartd.conf.) In Prometheus use smartctl_exporter.

  1. VMs and cloud disks have no SMART (virtual disks) — there the provider watches the hardware; you watch I/O errors and latency.

107.3

Check that it worked

Every disk shows PASSED, the bad attributes are 0 (or not growing), RAID arrays show all U, and smartd is active with a working mail address (test with -M test in the config once).

107.4

Common problems

ProblemCauseFix
Unable to detect device typeBehind a RAID controller.smartctl -d megaraid,0 /dev/sda (or the controller's own tool).
SMART support is: UnavailableVirtual disk (VM) or a USB bridge.Check on the host/provider; for USB try -d sat.
PASSED, but many I/O errors in dmesgSMART does not see everything (cable, controller).Trust the kernel log; check cables; replace the disk if errors continue.
UDMA_CRC_Error_Count growsBad SATA cable or connector.Replace the cable first.
RAID shows [U_]One disk failed or was removed.mdadm --detail; replace the disk and add it back (mdadm --add).
NVMe Percentage Used 95 %SSD worn out by writes.Plan the replacement; check what writes so much.

الأوامر في هذا الدرس

107.5

Go further

1Which SMART values show a disk is starting to fail?

Growing Reallocated_Sector_Ct, and Current_Pending_Sector or Offline_Uncorrectable above 0.

2/proc/mdstat shows [U_]. What does it mean?

The RAID array is degraded — one disk is missing or failed.

كل الأوامر في هذا الفصل