How many writes do I have on my 250GB SSD hard drive on my Macbook Pro High Sierra [duplicate]

I would like to know how many writes I have on my Mac's SSD hard drive?

I would also like to know if there is a terminal command I can run to find out this information and how many writes I have left so I can check the status of it?


Solution 1:

There is a Terminal command for that

iostat -Id disk0

the output is

You will see three values listed:

KB/t = kilobytes per transfer
xfrs = number of transfers
MB = number of megabytes transferred

Here is an example of my MBA 2017

disk0

KB/t   xfrs     MB 

29.12 1886081 53627.02

The value listed under MB is the total number of megabytes that you have written to your drive from when it was first installed to now. So I have written 53 GB.

To the second part of your Question "How many Writes do I have left"

There is no program to tell you the life expectancy :)

Consider, you have 250GB SSD, and you totally erase it and then write again 250GB you can do that about 2,000 times. That is 5.0e14 worth of Data transferred. (let me help you, that is 500TB)

Also you do not always "write" to the same cell (more than 50% of them are just in read mode), so that is why it is important to keep your SDD below 80% capacity.

source

In any case, it is not so much important to know exactly the current and the future life time. Eventually it will fail. Just Keep Backup.

Solution 2:

You cannot in general track how many writes exactly have been performed on the drive. You would have had to keep track of that statistics yourself somehow.

Similarly you cannot in general say how many writes are left, as there's no "guarantee" that a drive will fail at a certain point. Nor is there a guarantee that a drive won't fail up until a certain point.

The best way to get an approximation of what you want is to look at the SMART attributes on the drive. You can do that with the program "smartctl" from "smartmontools". If you have homebrew installed, you can install smartmontools with this command:

brew install smartmontools

Then afterwards run it like this:

smartctl -a disk0

(replace disk0 with the actual physical disk you want to examine - you can find the device names in Disk Utility)

In the output from smartctl, you'll want to look at the so called "Wear Leveling Count". The raw value at the right tells you how many erase/program cycles each block on the SSD in average has undergone. The erase/program cycles are what wears out the drive eventually.

In addition, the number in the column "value" will tell you in basically how large a part that number of erase/program cycles is compared to the expected number of cycles that you drive can sustain. Basically this number starts at 100% for a new drive, and counts down to 0% where you would expect the drive to start failing. As mentioned before, drives can and will fail before that point - and they might not fail at that point. However, it is one of the better indicators you have of drive health.

Solution 3:

Smart Attributes for Total Writes

Technically speaking, there are SMART attributes defined for read/write values, but there's no guarantee that the drive manufacturer is going to use them. They are as follows (defined as "words" - i.e. "Word 241"):

  • 241 - Total LBAs Written
  • 242 - Total LBAs Read
  • 243 - Total LBAs Written Expanded
  • 244 - Total LBAs Read Expanded
  • 249 - NAND Writes (1GiB)

An LBA is a Logical Block Address which is a 48 bit address to a specified data block. Data blocks vary in size depending on the OS; macOS HSF+ uses a 16KB block. In other words, on macOS formatted with HFS+ it uses 16KB to hold a 1KB file and 32KB to hold any file greater than 16KB but less than 32KB.

Can you access this data?

It depends. (Again) Technically speaking, you can send an ATA command to the drive to read the data identified by the relevant "words". However, it's unlikely you're going to get this info. Why?

  • The drive must support it
  • macOS doesn't allow you to get it.

Pulling the attributes for a (random) Seagate Drive from the smartmontools website, you can see that the relevant words aren't defined.

Secondly, even if the data existed and you were to write your own application to send custom AT commands, macOS wouldn't allow you to do so.

By design, OS X does not allow applications to send SCSI or ATA commands to storage devices unless the application developer also provides an in-kernel device driver that supports the commands. The SCSI Architecture Model family allows only one logical unit driver to control a device at a time and provides in-kernel logical unit drivers for storage devices (as listed in SCSI Architecture Model Family Device Support). Similarly, the ATA family does not allow applications to send ATA commands directly to ATA or SATA (Serial ATA) devices.

How do we know this is the case?

Using DiskDrill on my internal SSD, this is the limit of attributes that are provided by the OS.

SSD SMART Attributes

Practicality of Total Write Operations

It's not practical to gather this type of info. Taking a extreme-case-scenario - a data center running high availability, mission critical SQL (Oracle, MySQL, MSSQL) servers - our concern is not how much data is written, it's how fast and how reliable the drives are. What we look for is

  • are the IOPS high enough?
  • what's the read/write errors low?
  • is the warranty coverage still in effect?

In other words, if the drive has high enough performance and there are no (low threshold) of errors and still under warranty, the drive is in service. The moment it begins to fail, we swap it out. Additionally, once the warranty coverage is up, it gets replaced no matter if it has life left (there's a budget component as well).

Bottom line, total number of write operations to a drive is not a critical metric to track.

iostat and other OS tools

The problem with this is that it gives you statistics for the current operating system:

iostat (input/output statistics) is a computer system monitor tool used to collect and show operating system storage input and output statistics.

In other words, reinstall macOS on a 3 year old, well used SSD and your stats go back to zero. It's kind of rolling back the odometer on a car - even though it reports 50K miles/kilometers driven, the engine and transmission still have 150K on it.

TL;DR

It's unlikely you're going to obtain this info.

  1. The drive must support the SMART attribute
  2. Your OS must allow you to obtain the attribute. On macOS, this information, by design, is simply unavailable
  3. It's not a practical metric to monitor

Finally, when it comes to drives, whether spinning or solid state, assume they are going to fail. This is why a sensible backup strategy is much, much more critical than monitoring total writes.