109

How do I view my Disk Activity on Ubuntu? For example, How can I monitor what is being written and read from disk as well as the percentage of disk usage?

I am looking for an application similar to the Resource Monitor in Windows.

1

6 Answers 6

101

You can use iotop. To install, open a terminal and execute the following command:

sudo apt-get install iotop

To use iotop, open a terminal and type the following command:

sudo iotop

iotop features real-time display of all disk activity and also displays the command responsible for the activity and the user behind the command just like Resource Monitor.

Click here for more information.

enter image description here

Also similar to resource monitor is htop in it's ability to identify and kill processes:

sudo apt-get install htop

and to run htop in monitor mode:

htop

or, for more features and permissions to fully debug and kill individual processes etc.:

sudo htop

enter image description here

7
  • 10
    you were asking for disk activity, not disk usage. This is the perfect answer to your question.
    – xorinzor
    Sep 13, 2018 at 17:18
  • Can you make iotop not list a certain process like peek which is recording iotop's output into a .gif via ffmpg? Sep 19, 2019 at 0:15
  • 1
    @user25 For disk use, you will need to use a different command: df -h -t ext4 This prints in human readable format (-h) and assumes that you are using ext4 format (-t ext4).
    – mchid
    Sep 19, 2019 at 1:09
  • @WinEunuuchs2Unix sudo iotop $(echo $(ps -A | grep -v ffmpeg | grep -v peek | awk '{print $1}') | sed 's/ / -p /g;s/PID//g')
    – mchid
    Sep 19, 2019 at 1:25
  • 1
    @mchid +1 for replying to comment, but I ended up using -p ProcessID of the suspect. Sep 19, 2019 at 2:29
96

You can use htop.

sudo apt install htop

Then open htop and configure it: F2 -> Columns -> Set IO_RATE (or IO_RATE_READ/IO_RATE_WRITE) -> F10

And you will see something like this:

screenshot

4
  • 10
    This should be the answer to the question!
    – Socrates
    Apr 27, 2018 at 12:02
  • 3
    super. this is correct answer.
    – James M
    Jun 28, 2018 at 10:29
  • 1
    Your screen shot shows DISK R/W, but I don't see that in htop. What's the difference between DISK R/W and IO_RATE, IO_RATE_READ/IO_RATE_WRITE? Nov 7, 2018 at 1:06
  • 3
    DISK R/W appears when you choose IO_RATE column in setup . IO_RATE is a total I/O (read and write) in bytes per second.
    – RedEyed
    Nov 7, 2018 at 17:54
37

You can try nmon

sudo apt-get install nmon

Try:

nmon

Output Like below:

enter image description here

Press d = Disk | Press c = CPU Info |Press r = RAM info | Press q = to exit
1
  • one top to rule them all! this is fantastic, thanks for sharing. haven't seen it before Dec 25, 2021 at 5:26
14

You can use dstat program. To install it, simply execute the command in a terminal

sudo apt-get install dstat

Using the dstat command, you will get a complete real time CPU/Network/Disk-Activity monitoring view like this

mas@mas-laptop:~ > dstat 
You did not select any stats, using -cdngy by default.
----total-cpu-usage---- -dsk/total- -net/total- ---paging-- ---system--
usr sys idl wai hiq siq| read  writ| recv  send|  in   out | int   csw 
 15   5  76   4   0   0| 181k  177k|   0     0 |   0    61B|1651  3609 
  5   0  95   0   0   0|   0     0 | 162B 1064B|   0     0 | 500   994 
 15   4  77   4   0   0|   0   292k| 302B   52B|   0     0 | 687  1919 
  6   1  92   1   0   0|   0     0 |   0     0 |   0     0 | 496  1089 
  5   1  94   1   0   1|   0     0 |   0     0 |   0     0 | 422   919
  6   1  93   1   0   0|   0     0 |   0     0 |   0     0 | 517  1181 
  9   2  89   1   0   1|   0     0 |   0     0 |   0     0 | 494  1066

To only get the usage info for disk for load indicator upto most recent 15 mintues, use dstat --disk --fs --load command. A sample output is given below

$ dstat --disk --fs

-dsk/total- --filesystem- ---load-avg---
 read  writ|files  inodes| 1m   5m  15m 
 895k  186k|13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0     0 |13728    100k|0.63 0.73 0.84
   0    12k|13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84
   0     0 |13728    100k|0.66 0.74 0.84^C

dstat --help has these info:

Usage: dstat [-afv] [options..] [delay [count]]
Versatile tool for generating system resource statistics

Dstat options:
  -c, --cpu              enable cpu stats
     -C 0,3,total           include cpu0, cpu3 and total
  -d, --disk             enable disk stats
     -D total,hda           include hda and total
  -g, --page             enable page stats
  -i, --int              enable interrupt stats
     -I 5,eth2              include int5 and interrupt used by eth2
  -l, --load             enable load stats
  -m, --mem              enable memory stats
  -n, --net              enable network stats
     -N eth1,total          include eth1 and total
  -p, --proc             enable process stats
  -r, --io               enable io stats (I/O requests completed)
  -s, --swap             enable swap stats
     -S swap1,total         include swap1 and total
  -t, --time             enable time/date output
  -T, --epoch            enable time counter (seconds since epoch)
  -y, --sys              enable system stats

  --aio                  enable aio stats
  --fs, --filesystem     enable fs stats
  --ipc                  enable ipc stats
  --lock                 enable lock stats
  --raw                  enable raw stats
  --socket               enable socket stats
  --tcp                  enable tcp stats
  --udp                  enable udp stats
  --unix                 enable unix stats
  --vm                   enable vm stats

  --plugin-name          enable plugins by plugin name (see manual)
  --list                 list all available plugins

  -a, --all              equals -cdngy (default)
  -f, --full             automatically expand -C, -D, -I, -N and -S lists
  -v, --vmstat           equals -pmgdsc -D total

  --float                force float values on screen
  --integer              force integer values on screen

  --bw, --blackonwhite   change colors for white background terminal
  --nocolor              disable colors (implies --noupdate)
  --noheaders            disable repetitive headers
  --noupdate             disable intermediate updates
  --output file          write CSV output to file

delay is the delay in seconds between each update (default: 1)
count is the number of updates to display before exiting (default: unlimited)

For more information about this tool, look visit below links:

1) Dstat home page

2) DiskPerformance Community Documentation Page

3

Install htop first sudo apt install htop

As answered above by RedEyed if you want to see read write in bytes/sec for individual processes go to setup (F2) --> Columns --> Available Columns --> Select IO_RATE (as shown in the image below)

enter image description here

But if you want an overall disk IO read write to be shown like this :

enter image description here

Go to setup (F2)--> Meters --> Available Meters -->Disk IO and enter add and select where do you want it to be Left/Right Column and you're done.

enter image description here

3

You could try Stacer

sudo apt install stacer

It looks like a good option if you want/need a graphical interface. It has many other features. Screenshot

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .