RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

tune2fs Last write time 5 month in the past, any change to refresh values?

Mon Jul 15, 2019 10:07 pm

We have a RP 3B+ (card was in a RPi 1 before for > 1 year, and since a few month it is in RPI 3B+)
The 3B+ runs 24/7

Code: Select all

uptime -s
2019-05-21 23:16:42
Output at the time of writing this post:

Code: Select all

sudo tune2fs -l /dev/mmcblk0p2
tune2fs 1.43.4 (31-Jan-2017)
Filesystem volume name:   rootfs
Last mounted on:          /
Filesystem UUID:          72bfc10d-73ec-4d9e-a54a-1cc507ee7ed2
Filesystem magic number:  0xEF53
Filesystem revision #:    1 (dynamic)
Filesystem features:      has_journal ext_attr resize_inode dir_index filetype needs_recovery extent flex_bg sparse_super large_file dir_nlink extra_isize
Filesystem flags:         signed_directory_hash
Default mount options:    user_xattr acl
Filesystem state:         clean
Errors behavior:          Continue
Filesystem OS type:       Linux
Inode count:              474240
Block count:              1958144
Reserved block count:     81420
Free blocks:              900249
Free inodes:              254963
First block:              0
Block size:               4096
Fragment size:            4096
Reserved GDT blocks:      107
Blocks per group:         32768
Fragments per group:      32768
Inodes per group:         7904
Inode blocks per group:   494
Flex block group size:    16
Filesystem created:       Wed Nov 29 03:35:09 2017
Last mount time:          Tue May 21 23:16:38 2019
Last write time:          Sat Feb 23 08:17:02 2019
Mount count:              25
Maximum mount count:      -1
Last checked:             Thu Nov  3 18:16:45 2016
Check interval:           0 (<none>)
Lifetime writes:          308 GB
Reserved blocks uid:      0 (user root)
Reserved blocks gid:      0 (group root)
First inode:              11
Inode size:               256
Required extra isize:     32
Desired extra isize:      32
Journal inode:            8
First orphan inode:       967
Default directory hash:   half_md4
Directory Hash Seed:      ff6a5011-c642-4ab4-9ab8-19bd9ac5ff95
Journal backup:           inode blocks
Last write time: Sat Feb 23 08:17:02 2019
What is wrong here? There are a lot of writes, just consider all the logfiles.

Is there any command to update these values to the current stats? It should be also a lot more tham 308 GB written by now.
This high value is tue to the fstrim / command I'll to every day. After each reboot fstrim trims the whole card so a lot of GB written is shown.
e.g.

Code: Select all

iostat
Linux 4.19.42-v7+ (raspberrypi)         16.07.2019      _armv7l_        (4 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           0,91    0,30    1,38    1,41    0,00   96,00

Device:            tps    kB_read/s    kB_wrtn/s    kB_read    kB_wrtn
mmcblk0           0,92        41,51        55,53  197363111  264034720
264034720 is 251 GB!
Iostat shows values since last boot.

trejan
Posts: 1202
Joined: Tue Jul 02, 2019 2:28 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Mon Jul 15, 2019 10:16 pm

Last write time is the last time the superblock was written. It doesn't monitor writes to the actual files.

RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Tue Jul 16, 2019 8:34 am

Thanks for clearyfying.
However the problem with the lifetimewrites count still exists.
As you remember, yesterday the counter was 308 GB.
Now I've wrote 2 GB to disk

Code: Select all

dd if=/dev/urandom of=test bs=1M count=2048 status=progress

Code: Select all

sudo tune2fs -l /dev/mmcblk0p2 | grep writes
Lifetime writes:          308 GB
sudo iostat
Linux 4.19.42-v7+ (raspberrypi) 16.07.2019 _armv7l_ (4 CPU)

avg-cpu: %user %nice %system %iowait %steal %idle
0,91 0,30 1,38 1,41 0,00 96,00

Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
mmcblk0 0,92 42,45 55,91 203444979 267948872
267948872 = 255 GB, yesterday 251 GB, so these values seem valid

trejan
Posts: 1202
Joined: Tue Jul 02, 2019 2:28 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Tue Jul 16, 2019 4:42 pm

RDPUser wrote:
Tue Jul 16, 2019 8:34 am
However the problem with the lifetimewrites count still exists.
The lifetime write value in the superblock gets updated when you unmount so reboot and look at it again.

RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Wed Jul 17, 2019 5:49 am

Unmounting rootfs is probably not a good idea :)
Is there a way to update it without unmouting? In case of a poweroutage writtenbyte count would be lost.

User avatar
rpdom
Posts: 16313
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Wed Jul 17, 2019 7:13 am

trejan said to unmount it by rebooting. Not unmount it while it is running.

RDPUser
Posts: 147
Joined: Tue Jan 30, 2018 12:18 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Fri Jul 19, 2019 8:05 am

rpdom wrote:
Wed Jul 17, 2019 7:13 am
trejan said to unmount it by rebooting. Not unmount it while it is running.
Yeah I know. And as I said, sometimes poweroutages happen and thus the writecount is lost. Thats why I asked for a possibility to update without rebooting.

trejan
Posts: 1202
Joined: Tue Jul 02, 2019 2:28 pm

Re: tune2fs Last write time 5 month in the past, any change to refresh values?

Fri Jul 19, 2019 1:55 pm

Only way I know of cleanly updating the superblock without unmounting is to remount RO then remount RW again. This won't work for / though. You can use magic sysreq to force RO for all filesystems but you shouldn't use it unless something dire is happening.

What are you doing with the lifetime write value anyway? If it is important that the value is accurate then you'll have to arrange for your RPi to be on a UPS or something similar so it can always shutdown properly.

Return to “Advanced users”