LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 09-15-2025, 02:43 PM   #1
exerceo
Member
 
Registered: Oct 2022
Posts: 145

Rep: Reputation: 31
Question How to see how much data was read and written since boot?


[Log in to get rid of this advertisement]
I would like to know how many GB of data were read and written by all processes since boot. Ideally I would like to see this statistic for each data storage device individually, but it would be good without this too. How can this be accomplished?

gnome-system-monitor shows this statistic on an individual process basis only.
 
Old 09-15-2025, 03:04 PM   #2
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,618
Blog Entries: 7

Rep: Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058Reputation: 2058
Not sure that you can. Unless you kept tract of it at the start.

I suppose that you could look at Lifetime writes:

Example:
Code:
tune2fs -l /dev/sda2
Then look at it again later. Subtract the difference.
 
Old 09-15-2025, 03:12 PM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS, Manjaro
Posts: 6,485

Rep: Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111Reputation: 3111
Set a process to report the total writes to storage early in the shutdown process, and then late in the reboot process, and have those log to a file. (Make sure logrotate is installed and configured to limit the growth of that log.) Now you can either go look at the log and do the math, or write a process to scan the log and do the math for you and report. That would give you the total written during shutdown and boot.

If your report program runs the same total writes detection and subtracts the logged number from the last boot you have the total written since boot.

If you get fancy you can create some neat graphs if you like.

I do not need this, but it sounds like a useful process for someone who NEEDS to know!

Last edited by wpeckham; 09-15-2025 at 03:16 PM.
 
Old 09-15-2025, 03:58 PM   #4
rnturn
Senior Member
 
Registered: Jan 2003
Location: Illinois (SW Chicago 'burbs)
Distribution: openSUSE, Raspbian, Slackware. Previous: MacOS, Red Hat, Coherent, Consensys SVR4.2, Tru64, Solaris
Posts: 2,859

Rep: Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553Reputation: 553
Quote:
Originally Posted by exerceo View Post
I would like to know how many GB of data were read and written by all processes since boot. Ideally I would like to see this statistic for each data storage device individually, but it would be good without this too. How can this be accomplished?

gnome-system-monitor shows this statistic on an individual process basis only.
See the "proc(5)" manpage and search for "diskstats" and the tip on what section of the kernel documentation to read next (probably /usr/src/linux/Documentation/admin-guide/iostats.rst). You might need to install the kernel sources package to see those files. Unfortunately, I see nothing that indicates the amount (MB, GB, whatever) of data that has been transferred to/from each device -- only the number of reads and writes (along with a bunch of timing data). If you're looking for some sort of performance indicator, reads and writes might help you locate overloaded disks (containing "hot" files).

Hope this helps a bit...

Cheers.
 
Old 09-15-2025, 05:25 PM   #5
viel
Member
 
Registered: Jul 2021
Location: Arcadia
Distribution: LFS, (Slackware-15.0 backup)
Posts: 299

Rep: Reputation: Disabled
Code:
[root@arcadia migration]# iostat
Linux 5.15.188 (arcadia.lo)     09/16/2025      _x86_64_        (8 CPU)

avg-cpu:  %user   %nice %system %iowait  %steal   %idle
           7.55    1.33    4.39    0.06    0.00   86.67

Device             tps    kB_read/s    kB_wrtn/s    kB_dscd/s    kB_read    kB_wrtn    kB_dscd
dm-0              0.38         4.28        23.84         0.00    2602255   14508612          0
sda               0.00         0.05         0.00         0.00      30118          0          0
sdb               0.50         6.29        31.09         0.00    3830503   18917864          0
sdc               0.00         0.06         0.00         0.00      33920          0          0


[root@arcadia migration]#
Maybe that helps.
 
Old 09-16-2025, 01:35 AM   #6
GazL
LQ Veteran
 
Registered: May 2008
Posts: 7,245

Rep: Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417Reputation: 5417
Using --pretty and -dmN makes it look a little nicer. Especially so if, like me, you use device-mapper:
Code:
$ iostat --pretty -dmN
Linux 6.16.6-local (crux) 	09/16/25 	_x86_64_	(4 CPU)

      tps    MB_read/s    MB_wrtn/s    MB_dscd/s    MB_read    MB_wrtn    MB_dscd Device
     0.83         0.00         0.01         0.00        745       2130          0 lukssda4
     0.00         0.00         0.00         0.00          1          0          0 sysvg-lvswap0
     0.00         0.00         0.00         0.00          1          0          0 sysvg-lvslack150
     0.77         0.00         0.01         0.00        742       2130          0 sysvg-lvcrux38
     0.22         0.00         0.00         0.00        134        206          0 lukssda5
     0.02         0.00         0.00         0.00         17          0          0 datavg-lvslackware
     0.17         0.00         0.00         0.00        100        206          0 datavg-lvlocal
     0.01         0.00         0.00         0.00         10          0          0 datavg-lvlibrary
     0.00         0.00         0.00         0.00          4          0          0 datavg-lvwork
     0.00         0.00         0.00         0.00          1          0          0 datavg-lvmirrors
     0.53         0.01         0.01         0.00        889       2337          0 sda

Last edited by GazL; 09-16-2025 at 01:46 AM.
 
Old 09-16-2025, 05:51 AM   #7
mjolnir
Member
 
Registered: Apr 2003
Posts: 951

Rep: Reputation: 138Reputation: 138
Caveat - untested.
Code:
cat /proc/diskstats | awk '$6 > 0 || $10 > 0 {printf "%s - Read: %.2f GB, Written: %.2f GB\n", $3, $6 * 512 / 1073741824, $10 * 512 / 1073741824}'
 
Old 09-16-2025, 07:03 AM   #8
syg00
LQ Veteran
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 21,479

Rep: Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221Reputation: 4221
Conceptually ok, but what about 4k sector devices ?. And/or a mix of both.

The monitoring tools like iostat manage this for you - as the OP would have found out with a basic search. However they tend to be interval driven rather than a single period since boot, so the above would be also my preferred route.
 
Old 09-16-2025, 10:06 AM   #9
viel
Member
 
Registered: Jul 2021
Location: Arcadia
Distribution: LFS, (Slackware-15.0 backup)
Posts: 299

Rep: Reputation: Disabled
Well the two data seems come from the same font /sys/block/{disk}/stat

FWIW
https://www.kernel.org/doc/html/latest/block/stat.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: 'This was bigger than GNOME and bigger than just this case.' GNOME Foundation exec director talks patent trolls and much, much more LXer Syndicated Linux News 0 10-24-2020 04:21 AM
[SOLVED] does the /boot partition get written to much slayme40 Linux - General 3 09-14-2016 10:38 AM
[SOLVED] How to read data in kernel that was written to metadata structure during mkfs of FS yashgovin19 Linux - Newbie 2 06-25-2015 11:38 AM
LXer: Linux And Unix Internet User And Site Security - How Much Is Too Much? LXer Syndicated Linux News 0 12-04-2008 01:10 PM
I feel much better since......... munsterling LinuxQuestions.org Member Intro 3 03-24-2006 10:47 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 06:30 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration