1

I am looking for a program that can display the total number of reads and writes a given disk has had during its lifetime in a Linux shell.

E.g., on Microsoft Windows, I use CrystalDiskInfo:

enter image description here

Any license and price is fine.

1 Answer 1

4

You can use smartctl.

smartctl (Self-Monitoring, Analysis and Reporting Technology) is a command line utility or a tool in UNIX like operating system that perform SMART tasks such as printing the SMART self-test and error logs, enabling and disabling SMART automatic testing, and initiating device self-tests.

To install:

sudo apt-get install smartmontools

(smartctl is part of smartmontools)

To run:

sudo  smartctl -l devstat -a -d ata /dev/sda

where /dev/sda is your disk.

Example of output (truncated):

SMART Attributes Data Structure revision number: 1
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME          FLAG     VALUE WORST THRESH TYPE      UPDATED  WHEN_FAILED RAW_VALUE
  5 Reallocated_Sector_Ct   0x0033   100   100   010    Pre-fail  Always       -       0
  9 Power_On_Hours          0x0032   099   099   000    Old_age   Always       -       504
 12 Power_Cycle_Count       0x0032   099   099   000    Old_age   Always       -       11
177 Wear_Leveling_Count     0x0013   099   099   000    Pre-fail  Always       -       17
179 Used_Rsvd_Blk_Cnt_Tot   0x0013   100   100   010    Pre-fail  Always       -       0
181 Program_Fail_Cnt_Total  0x0032   100   100   010    Old_age   Always       -       0
182 Erase_Fail_Count_Total  0x0032   100   100   010    Old_age   Always       -       0
183 Runtime_Bad_Block       0x0013   100   100   010    Pre-fail  Always       -       0
187 Reported_Uncorrect      0x0032   100   100   000    Old_age   Always       -       0
190 Airflow_Temperature_Cel 0x0032   074   072   000    Old_age   Always       -       26
195 Hardware_ECC_Recovered  0x001a   200   200   000    Old_age   Always       -       0
199 UDMA_CRC_Error_Count    0x003e   100   100   000    Old_age   Always       -       0
235 Unknown_Attribute       0x0012   099   099   000    Old_age   Always       -       2
241 Total_LBAs_Written      0x0032   099   099   000    Old_age   Always       -       9127069901
  • 241: Total LBAs Written The total number of 512-byte sectors written during the entire lifetime of the device.
  • 242: Total LBAs Read The total number of 512-byte sectors read during the entire lifetime of the device.

With awk to select only the number of interest, e.g. to display how many terabytes were written:

sudo  smartctl -l devstat -a -d ata /dev/sda | grep Total_LBAs_Written | awk '{print $(NF)/10^12*512}'

You can use lsblk to list all your disks:

username@server:~$ lsblk
NAME                         MAJ:MIN RM   SIZE RO TYPE  MOUNTPOINT
sda                            8:0    0   1.9T  0 disk
├─sda1                         8:1    0   1.9T  0 part
│ ├─vg_system-swap (dm-0)    252:0    0     4G  0 lvm   [SWAP]
│ ├─vg_system-openafs (dm-1) 252:1    0     3G  0 lvm   /var/cache/openafs
│ └─vg_system-root (dm-2)    252:2    0   1.9T  0 lvm   /
└─sda2                         8:2    0     1M  0 part
sdb                            8:16   0   5.5T  0 disk
└─sdb1                         8:17   0   5.5T  0 part
  └─md0                        9:0    0  10.9T  0 raid0 /crimea
sdc                            8:32   0   5.5T  0 disk
└─sdc1                         8:33   0   5.5T  0 part
  └─md0                        9:0    0  10.9T  0 raid0 /crimea
3
  • 1
    As your example in the question is using a GUI, you might wish to add that there's a GUI for smartctl as well: e.g. GSmartControl. The corresponding screenshot would be this one, more can be found here :)
    – Izzy
    Jul 26, 2016 at 6:53
  • @Izzy this guy has a nice amount of hard drives :) Jul 26, 2016 at 16:38
  • Yeah – but I don't want to have the one from the screenshot #D
    – Izzy
    Jul 26, 2016 at 16:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.