read write file copy speed

Message
Author
Butters
Posts: 32
Joined: Wed Aug 21, 2019 2:26 am

read write file copy speed

#1 Post by Butters »

Greetings,

How can I check the speed that a disk (or disks) is either reading or writing data?

I am not asking for benchmarking tools.

If a command (any command) is performing a file copy (cp, mv, cpio, ftp, etc), then how can I see the real-time speed of the disk(s) io that are part of the operation?

I installed "iotop", but that shows the speed of specific commands. That is not quite what I am seeking, because I want the report to be based on the disk io, and not the speed of the command (a disk could have multiple commands performing io operations).

Windows 10 provides such information via Task Manager's "Performance" tab.
Is there a similar tool for Linux, whether it be GUI based or text based?

By the way, I could not find a forum category for asking a general Linux question. If my query should have been posted elsewhere, please let me know that location.


Thank you.

User avatar
timkb4cq
Developer
Posts: 3615
Joined: Wed Jul 12, 2006 4:05 pm

Re: read write file copy speed

#2 Post by timkb4cq »

There's not a great general answer for this question AFAIK.
You might try progress. It's in the debian main repo. It monitors coreutils commands

Code: Select all

cp mv dd tar cat rsync grep fgrep egrep cut sort md5sum sha1sum sha224sum sha256sum sha384sum sha512sum adb gzip gunzip bzip2 bunzip2 xz unxz lzma unlzma 7z 7za zcat bzcat lzcat split gpg
You start your command, then in another terminal (or in the same one after backgrounding your command - which you can do by appending a & to the command) use progress -m
That won't cover ftp (though sftp has it's own progress meter as does rsync).
HP Pavillion TP01, AMD Ryzen 3 5300G (quad core), Crucial 500GB SSD, Toshiba 6TB 7200rpm
Dell Inspiron 15, AMD Ryzen 7 2700u (quad core). Sabrent 500GB nvme, Seagate 1TB

Stuart_M
Posts: 696
Joined: Wed Aug 07, 2019 7:10 pm

Re: read write file copy speed

#3 Post by Stuart_M »

I use iostat to monitor the system input/output device loading. It will report the read and write speeds of any storage device and partition(s). I find it particularly useful to confirm that nothing is being written to a USB device before disconnecting it (I know unmount does essentially the same) and I use it almost daily.

Iostat is part of the sysstat package and is not installed in MX-Linux by default so you will have to install sysstat, which is in the MX-18, MX-19, and MX-21 Stable Repositories.

After sysstat is installed then run iostat. I use the command in the below code window which will give real-time statistics by updating the report every n seconds (the minimum is 1 second). I update every 2 seconds but change as desired. The command I use is:

Code: Select all

iostat -dz 2 sdb
The above command uses the following options:
  • -d = display only the device utilization report.
  • -z = omit output for devices without any activity.
  • 2 = update output every 2 seconds (the command has a minimum of 1 second).
  • sdb = device to be monitored (USB 3.0 Flash Drive in my system).
    You can also use /dev/sdb or sdb1 if you want to specify a partition.
Just make sure you are monitoring the correct device (sda, sdb, sdc, etc.). You can use lsblk to see what device is being used. I have only one partition on sdb so I would get the same output using sdb or sdb1.

The first line of output is the activity total since the device was used in the current session. If there is no device activity afterwards then the only output will be the column headers with an empty line below it. The headers will continue to scroll up until the command is stopped (Ctrl+C). If there is activity in at least one column, then the column(s) that does NOT have activity will be displayed in dark-blue as a zero value (a lighter blue is used for the active value).

For example, the below image shows the output of iostat -dz 2 sdb when I copied a 107.2 MB file to a USB 3.0 Flash Drive to sdb (/dev/sdb). (I used an image vice the code window to show this since the image shows the different text colors.)
iostat_output.png
The first line shows the total activity since the Flash Drive was connected to a USB 3.0 port. The two lines after that is empty because there is no activity to the USB Flash Drive.

The forth line shows the write speed is 29257 kB/s and a total of 58514 kB was written during that 2-second period.

The 5th line shows the write speed is 23139 kB/s and a total of 46277 kB was written during that 2-second period.

The output was terminated with Ctrl+C (^C) as shown on the last output line.

Note the dark-blue outputs in some columns in the image. The reason is because there IS activity in that 2-second period but there is no activity in the columns that have dark-blue values, which will be zero.

You are interested in the read and write speeds so look at the "kB_read/s" and "kB_wrtn/s" columns.

You might find using the -m option (iostat -dzm 2 sdb) is easier to read. That will output in megabytes per second. Alternatively, you can use the -h (human readable) option which will automatically use kB or MB based on the size of the value, but then the "Device" column will not appear, which may or may not be important.

In case anyone is wondering, the first column, tps, is "transfers per second".

I have only touched the surface on the capabilities of this command. Perhaps you will find this command useful to determine the read/write speeds of a device.
You do not have the required permissions to view the files attached to this post.

Stuart_M
Posts: 696
Joined: Wed Aug 07, 2019 7:10 pm

Re: read write file copy speed

#4 Post by Stuart_M »

Another way to check the speed that a disk is reading or writing is by adding the "Disk Performance Monitor" to the Panel. This is a quick and easy way to see whenever read and/or write activity takes place on a specified device by just glancing at this add-on on the Panel. The read and write data transfer speeds are displayed only when the mouse pointer is hovered over the bar graph of this monitor.

To monitor several devices
  • one at a time: change the device to be monitored in Preferences
  • simultaneously: add another instance of the "Disk Performance Monitor" on the Panel for the other device.
In order to see both read and write activity separately, ensure "Combine Read/Write data" is disabled in the Preferences as shown in the below image:
Disk_Performance_Monitor_Preferences.png


The below image shows the Disk Performance Monitor output while monitoring /dev/sda and data is being written (copy/paste) from and to it (the source and destination files are on the same device). Note that the Tool-Tip displaying the transfer speed in this image only happens when the mouse pointer is hovered over the bar graph. (The read/write bar graph colors in the below image are reversed from what is shown in the above Preferences image.)
Disk_Performance_Monitor.png
You do not have the required permissions to view the files attached to this post.

User avatar
wdscharff
Posts: 1125
Joined: Mon Feb 24, 2020 1:07 am

Re: read write file copy speed

#5 Post by wdscharff »

I am only interested in the real speed in connection with what I am doing.
So a good timepiece for me is the primitive copy with the file manager of my choice, namely my complete /home. This covers everything in terms of file size and the side effects of the disk cache hardly matter. In the 300,000 files / 350GB, everything is also represented in terms of size. With a few thousand files between 100-1000 bytes in size, the data rate of SSDs also collapses, not quite as violently as with HDDs, but visibly.
But in the meantime I'm out of the testing phase for disks.

Translated with www.DeepL.com/Translator (free version)
my working horse Desktop AMD Ryzen 9 3900x, 32GB Ram // SSD ... enough
mx-fluxbox, what else?

In nature there are neither rewards nor punishments.
There are consequences.


my wallpaper gallery

User avatar
entropyfoe
Posts: 621
Joined: Thu Apr 19, 2007 11:42 am

Re: read write file copy speed

#6 Post by entropyfoe »

wdscharff,

I read you don't want benchmarking tools.

But it sounds like the command

Code: Select all

hdparm

hdparm -t /dev/<DEVICE>

$ sudo hdparm -t /dev/nvme0n1
with appropriate device names and options will give you the actual reading and writing speeds.

Is that what you really want?
MX 23.6 on Asus PRIME B650
AMD Ryzen 9700X (16 threads @ 3.8 GHz)
64 Gig DDR4 6400 (Crucial)
Nvidia GeForce GT 710
Samsung 970 NVMe nvme0n1 P1-3=MX-23.5, P4=testing
Samsung 980 NVMe =2TB Data, plus 4TB WD =backups
on-board ethernet & sound

Post Reply

Return to “General”