This script checks the health status of hard drives connected to your system using the smartctl
utility from the smartmontools
package.
smartmontools
package installed on your system for thesmartctl
command.util-linux
package installed on your system for thelsblk
command.
Consult your package manager to install these on your system. For example, on Debian-based systems:
sudo apt-get update
sudo apt-get install smartmontools util-linux
Run the following with root privileges command to download the script
sudo wget -O /usr/bin/drivestatus https://raw.githubusercontent.com/Mikesco3/drivestatus.sh/main/drivestatus.sh && sudo chmod +x /usr/bin/drivestatus
- Clone this repository:
git clone https://github.com/Mikesco3/drivestatus.sh.git
cd drivestatus
- Make the script executable:
chmod +x drivestatus.sh
- (Optional) Copy it to the system path
cp drivestatus.sh /usr/bin/drivestatus
Run the script using the following command:
drivestatus
The script will check the health status of all drives and print their status and details.
The script performs the following steps:
- Iterates over all possible drive letters from a to z.
- Checks if the drive exists.
- If the drive exists, it checks the health status using the smartctl command.
- Prints the drive status:
- GOOD: If the status is PASSED or SMART Health Status: OK.
- REPLACE: If the status is FAILED.
- UNKNOWN STATUS: If the status is neither PASSED nor FAILED.
-------------------------------------------
Drive Health:
/dev/sda : GOOD
/dev/sdb : GOOD
/dev/nvme0n1 : GOOD
-------------------------------------------
Drive Details:
NAME MODEL SERIAL TYPE SIZE SUBSYSTEMS
sda ACME 000000000001 disk 10.9T block:scsi:usb:pci
sdb HGST 5999AA disk 10.9T block:scsi:usb:pci
nvme0n1 Samsung AABBCC00112233 disk 1.8T block:nvme:pci
-------------------------------------------
- @itssimplycomputing1814 on Youtube
- smartmontools - For providing the smartctl utility.