7

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?

0

3 Answers 3

5

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.

11
  • 14
    The answer is incorrect. "iostat -Id disk0" will not tell you many writes or transfers the drive has undergone in its lifetime. instead it tells you how much has been transferred since the last reboot of the computer - a completely different thing.
    – jksoegaard
    Commented Sep 16, 2018 at 21:34
  • @jksoegaard that is not correct, I just rebooted Yesterday and I did not write 50GB since.
    – Ruskes
    Commented Sep 16, 2018 at 21:48
  • 3
    You're still incorrect. If you look at the source code for iostat, you'll see that first of all the "MB" value is actually the total of both bytes read and bytes written. The number of bytes read is not important for the question here as it doesn't wear the SSD the same way. Already there, the value you find is not relevant. The next part is that in the source code you'll see that it finds the number of bytes written in the stats parts of the properties at the key called "kIOBlockStorageDriverStatisticsBytesWrittenKey". As per Apple documentation that is the number of bytes written since boot.
    – jksoegaard
    Commented Sep 16, 2018 at 22:16
  • 1
    As I couldn't write more in the previous comment: "since boot" is not entirely correct, as it really is "since the block storage driver was instantiated". In the case of your boot drive (as here), that is the same as "since boot". You can read the documentation here: developer.apple.com/documentation/iokit/…
    – jksoegaard
    Commented Sep 16, 2018 at 22:17
  • 1
    With your logic, the values rapported for my own drive is way off. Right now (soon after reboot) it tells me that I have approx. 15 GB worth of transfers. Which doesn't fit with your logic as the drive is several years old and has seen massive amounts of writes - not just 15 GB in total in its lifetime.
    – jksoegaard
    Commented Sep 16, 2018 at 22:19
19

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.

6
  • 1
    This is the real answer! A question, though: is the full original value 255 or 200?
    – Yongwei Wu
    Commented Mar 19, 2019 at 10:47
  • Look only at the normalized value, which should be a percentage between 0-100. On some drives, for example Intel, this stat is known as the Media Wearout Indicator.
    – jksoegaard
    Commented Mar 19, 2019 at 11:17
  • 1
    My drive shows the Wear_Leveling_Count as 193. So the original should be either 255 or 200, I suppose…
    – Yongwei Wu
    Commented Mar 20, 2019 at 7:27
  • Please post the entire output line, otherwise it is hard to say anything. SMART values are different from drive to drive, so if you haven't got an original Apple drive, things may be different for you.
    – jksoegaard
    Commented Mar 20, 2019 at 8:35
  • 1
    As far as I can see, this means that the drive is at 93%. I.e. the value goes from 200 at the max, to 100 at the least (you cross the estimated life time).
    – jksoegaard
    Commented Mar 20, 2019 at 11:48
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.

0

Not the answer you're looking for? Browse other questions tagged .