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?
Ask Different is a question and answer site for power users of Apple hardware and software. It only takes a minute to sign up.Sign up to join this community
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
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.
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.
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.
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"):
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.
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?
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.
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
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.
iostatand 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.
It's unlikely you're going to obtain this info.
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.