* Andreas Dilger <adilger@dilger.ca> hat geschrieben:> You can see in the ext4 superblock the amount of data that has been > written to a filesystem over its lifetime: > > Note that this number isn't wholly accurate, but rather a guideline.Is is more like a completely bogus value at best: # LANG=C df -h / | grep root /dev/root 3.7T 3.6T 73G 99% / # grep [0-9] /proc/partitions 8 0 3907018584 sda # tune2fs -l /dev/sda | grep Lifetime Lifetime writes: 2503 GB 3.7 TB Disk/Partition, 3.6 TB space in use but only 2.4 TB writes. No, there are no 1.2 TB + x allocated but never written to clusters on that file system. And if /sys/fs/ext4/*/*_write_kbytes are as correct as the "Lifetime writes" value, than the correct answer to Jelle's question is: "There is no way currently to figure out the actual number of writes to a device". Regards, Bodo
On Oct 16, 2014, at 10:25 AM, Bodo Thiesen <bothie@gmx.de> wrote:> * Andreas Dilger <adilger@dilger.ca> hat geschrieben: > >> You can see in the ext4 superblock the amount of data that has been >> written to a filesystem over its lifetime: >> >> Note that this number isn't wholly accurate, but rather a guideline. > > Is is more like a completely bogus value at best: > > # LANG=C df -h / | grep root > /dev/root 3.7T 3.6T 73G 99% / > # grep [0-9] /proc/partitions > 8 0 3907018584 sda > # tune2fs -l /dev/sda | grep Lifetime > Lifetime writes: 2503 GB > > 3.7 TB Disk/Partition, 3.6 TB space in use but only 2.4 TB writes. > > No, there are no 1.2 TB + x allocated but never written to clusters on > that file system. > > And if /sys/fs/ext4/*/*_write_kbytes are as correct as the "Lifetime > writes" value, than the correct answer to Jelle's question is: "There is > no way currently to figure out the actual number of writes to a device".The "lifetime writes" value has not been around forever, so if the filesystem was originally created and populated on an older kernel (e.g. using ext3) it would not contain a record of those writes. There is also some potential loss if the filesystem isn't unmounted cleanly. It definitely _can_ be used to monitor the writes to a particular filesystem over the past 24h, which is what the original poster was asking about. Cheers, Andreas
* Andreas Dilger <adilger@dilger.ca> hat geschrieben:> The "lifetime writes" value has not been around forever, so if the > filesystem was originally created and populated on an older kernel > (e.g. using ext3) it would not contain a record of those writes.It was created as stable ext4 in the first place. So only if there was a stable ext4 release which didn't update the "lifetime writes" value this could be the case.> There is also some potential loss if the filesystem isn't unmounted > cleanly.Yea, that *might* be it - but that only supports my statement, that this value is mainly bogus.> It definitely _can_ be used to monitor the writes to a particular > filesystem over the past 24h, which is what the original poster was > asking about.Since it never get's updated unless the file system is unmounted, it can only be used for a 24 hours test by mounting the file system now, unmounting it 24 hours from now and then taking the difference. Also the value is only available in granularity of 1 GB (plus minus 512MB) - at least in my case. So, in any case, I wouldn't trust that value for any purposes at all. I did test /sys/fs/ext4/sda/lifetime_write_kbytes now, that seems to be somewhat less bogus, so *that* might actuall be usable for the 24 hours test. But I wasn't talking about that when I said, that this lifetime thing is bogus. Regards, Bodo