I would like to install Ubuntu on SSD (I know that i Have to set TRIM, noatime, etc..) But I would like to know if I can check how many GB was written in last day / week / month.
Because I would like to measure how many GB is written every day on SSD if folders /var and /tmp were on SSD. If there would be less than 10GB writes per day I think it is cool and it will not damage SSD much.
And no I don't want to use ramdisk :)
As it often happens, I jumped ahead to reinvent the wheel that already exists in
smartmontools
package. This package provides whole lot of diagnostic tools for hard-drives and SSDs (or in more technical terms, SCSI devices). In particular,smartctl
command is what we're looking for:What you see above is list of attributes for my SSD. Of particular interest is attribute 241 (Host_Writes_GiB) and 242 (Host_Reads_GiB). These values are in GiB (which is a classical unit of measure in computer science in powers of 1024 bytes, in this case 1024^3, instead of SI units of powers of 10).
On the low level, as far as I understand, this utility parses actual
lifetime_write_kbytes
file in/sys/fs
folder. Particularly, in my example:Of course, this is a command-line utility. If you don't have it installed (check via
apt-cache policy smartmontools
) then install it viasudo apt-get install smartmontools
. There is Gnome Disks Utility as GUI alternative and it comes with Ubuntu.There are couple caveats however:
/proc/diskstats
file.There's also a bit of a problem: the resulting information shown is total history of reads/writes. Thus, you cannot extract reads/writes within last x number of days. At least it's not possible with
smartctl
or none of the tools I found thus far. However, what you can do, is schedule a dailycron
task that will read/sys/fs/ext4/sda1/lifetime_write_kbytes
and append the data with time stamp to a file. Later on, you can subtract differences to see how much was written in each day. For instance, contents of such command would be: