How to install Blktrace on Ubuntu 17.04

How to install Blktrace on Ubuntu 17.04

The Blktrace is a block layer IO tracing mechanism which provides detailed information of user request operations. It generates the traces of I/O traffic on block devices. It also has major components like Kernel patch, blktrace and blkparse. It gives the ouptut in human-readable format. This tutorial explains the installation procedure of Blktrace on Ubuntu 17.04.

Installation procedure

To start the installation procedure, add the repo by executing the following command.

root@linuxhelp1:~# add-apt-repository ppa:eugenesan/ppa
This repository contains collection of customized, updated, ported and backported
packages for two last LTS releases and latest pre-LTS release.
Packages for older releases relocated to ppa:eugenesan/archive or deleted.
+-------------------------------------------------------------------------------------+
| Disclaimer:
+-------------------------------------------------------------------------------------+
* Packages in this a nd related PPAs are for personal use only.
  They developed specifically for several custom environments and may not work for you.
* Usage of packages in this PPA, in some forms, might contradict licenses of software
  packaged in this and related PPAs. End users and administrator are responsible for
  runtime licensing and possible legal consequences.
* Some packages provided with their dependencies while some might require additional
  Ubuntu repositories and external PPAs. Below is the list of
.
.
.
Press [ENTER] to continue or ctrl-c to cancel adding it
gpg: keybox ' /tmp/tmp58gcy2yp/pubring.gpg'  created
gpg: /tmp/tmp58gcy2yp/trustdb.gpg: trustdb created
gpg: key E61380B28313A596: public key " Launchpad synergy+"  imported
gpg: Total number processed: 1
gpg:imported: 1
OK

The repositories are added to the target system. Update the repositories by running the apt-get update command.

root@linuxhelp1:~# apt-get update
Get:1 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty InRelease [15.4 kB]
Hit:2 http://in.archive.ubuntu.com/ubuntu zesty InRelease
Hit:3 http://security.ubuntu.com/ubuntu zesty-security InRelease
Hit:4 http://in.archive.ubuntu.com/ubuntu zesty-updates InRelease
Hit:5 http://in.archive.ubuntu.com/ubuntu zesty-backports InRelease
Get:6 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main amd64 Packages [1,100 B]
Get:7 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main i386 Packages [1,108 B]
Get:8 http://ppa.launchpad.net/eugenesan/ppa/ubuntu zesty/main Translation-en [1,288 B]
Fetched 18.9 kB in 1s (12.3 kB/s)
Reading package lists... Done

The target system is updated with the required repositories. Now install the blktrace package in the terminal and press y to continue with the installation procedure.

root@linuxhelp1:~# apt-get install blktrace -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
ffmpeg i965-va-driver libaacs0 libaio1 libass5 libav-tools libavcodec57 libavdevice57 libavfilter6 libavformat57 libavresample3
libavutil55 libbdplus0 libbluray2 libbs2b0 libchromaprint1 libcrystalhd3 libdc1394-22 libebur128-1 libflite1 libgme0 libgsm1
libmp3lame0 libmpg123-0 libopenal-data libopenal1 libopencv-core2.4v5 libopencv-imgproc2.4v5 libopenjp2-7 libopenmpt0
libpostproc54 librsvg2-bin librubberband2v5 libsdl1.2debian libsdl2-2.0-0 libshine3 libsndio6.1 libsoxr0 libssh-gcrypt-4
libswresample2 libswscale4 libtbb2 libtheora-bin libtwolame0 libva-drm1 libva-x11-1 libva1 libvdpau1 libx264-148 libx265-110
libxvidcore4 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers va-driver-all vdpau-driver-all
Suggested packages:
gnuplot-x11 ffmpeg-doc libbluray-bdj firmware-crystalhd libportaudio2 sndiod libfglrx-amdxvba1 libvdpau-va-gl1
nvidia-vdpau-driver nvidia-legacy-340xx-vdpau-driver
The following NEW packages will be installed:
blktrace ffmpeg i965-va-driver libaacs0 libaio1 libass5 libav-tools libavcodec57 libavdevice57 libavfilter6 libavformat57
libavresample3 libavutil55 libbdplus0 libbluray2 libbs2b0 libchromaprint1 libcrystalhd3 libdc1394-22 libebur128-1 libflite1
libgme0 libgsm1 libmp3lame0 libmpg123-0 libopenal-data libopenal1 libopencv-core2.4v5 libopencv-imgproc2.4v5 libopenjp2-7
libopenmpt0 libpostproc54 librsvg2-bin librubberband2v5 libsdl1.2debian libsdl2-2.0-0 libshine3 libsndio6.1 libsoxr0
libssh-gcrypt-4 libswresample2 libswscale4 libtbb2 libtheora-bin libtwolame0 libva-drm1 libva-x11-1 libva1 libvdpau1 libx264-148
libx265-110 libxvidcore4 libzvbi-common libzvbi0 mesa-va-drivers mesa-vdpau-drivers va-driver-all vdpau-driver-all
0 upgraded, 58 newly installed, 0 to remove and 42 not upgraded.
Need to get 31.4 MB of archives.
After this operation, 115 MB of additional disk space will be used.
Get:1 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 libgsm1 amd64 1.0.13-4 [27.1 kB]
Get:2 http://in.archive.ubuntu.com/ubuntu zesty/main amd64 libaio1 amd64 0.3.110-3 [6,382 B]
Get:3 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 blktrace amd64 1.1.0-2 [719 kB]
Get:4 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 libva-drm1 amd64 1.7.3-2 [8,508 B]
Get:5 http://in.archive.ubuntu.com/ubuntu zesty/universe amd64 libva1 amd64 1.7.3-2 [45.5 kB]
.
.
.
Setting up libchromaprint1:amd64 (1.4.2-1) ...
Setting up libavformat57:amd64 (7:3.2.4-1build2) ...
Setting up libavfilter6:amd64 (7:3.2.4-1build2) ...
Setting up libavdevice57:amd64 (7:3.2.4-1build2) ...
Setting up ffmpeg (7:3.2.4-1build2) ...
Setting up libav-tools (7:3.2.4-1build2) ...
Processing triggers for libc-bin (2.24-9ubuntu2) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (232-21ubuntu2) ...

The application is installed successfully. To use and open the application and also to know more about the options used in blktrace, run the following command and execute it.

root@linuxhelp1:~# blktrace
Usage: blktrace
-d < dev> | --dev=< dev> 
[ -r < debugfs path> | --relay=< debugfs path>  ]
[ -o < file> | --output=< file> ]
[ -D < dir> | --output-dir=< dir> 
[ -w < time> | --stopwatch=< time> ]
[ -a < action field> | --act-mask=< action field> ]
[ -A < action mask> | --set-mask=< action mask> ]
[ -b < size> | --buffer-size]
[ -n < number> | --num-sub-buffers=< number> ]
[ -l| --listen]
[ -h < hostname> | --host=< hostname> ]
[ -p < port number> | --port=< port number> ]
[ -s| --no-sendfile]
[ -I < devs file> | --input-devs=< devs file> ]
[ -v < version> | --version]
[ -V < version> | --version]
-d Use specified device. May also be given last after options
-r Path to mounted debugfs, defaults to /sys/kernel/debug
-o File(s) to send output to
-D Directory to prepend to output file names
-w Stop after defined time, in seconds
-a Only trace specified actions. See documentation
-A Give trace mask as a single value. See documentation
-b Sub buffer size in KiB (default 512)
-n Number of sub buffers (default 4)
-l Run in network listen mode (blktrace server)
-h Run in network client mode, connecting to the given host
-p Network port to use (default 8462)
-s Make the network client NOT use sendfile() to transfer data
-I Add devices found in < devs file> 
-v Print program version info
-V Print program version info

To remove the blktrace package along with its repositories, execute the following command and press y to continue with the uninstallation process.

root@linuxhelp1:~# apt-get remove blktrace -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
libaio1 libav-tools libsdl1.2debian libtheora-bin
Use ' apt autoremove'  to remove them.
The following packages will be REMOVED:
blktrace
0 upgraded, 0 newly installed, 1 to remove and 42 not upgraded.
After this operation, 1,044 kB disk space will be freed.
(Reading database ... 169290 files and directories currently installed.)
Removing blktrace (1.1.0-2) ...
Processing triggers for man-db (2.7.6.1-2) ...

Wasn' t that an easy installation procedure? The blktrace is used to extract event traces from kernal and also analyzes the IO to a drive, while running any command.

FAQ
Q
How to get the official documentation for the Blktrace?
A
For getting the official documentation of the Blktrace, use the following link as given below "https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=2ahUKEwiz8f_Fpf7dAhUPeysKHQifBUEQFjABegQICBAC&url=http%3A%2F%2Fwww.fis.unipr.it%2Fdoc%2Fblktrace-1.0.1%2Fblktrace.pdf&usg=AOvVaw0TsxxPWT-CymKCaMAecfqa"
Q
How do I know the entire detail and options to be available for Blktrace?
A
For getting the information and options to be available for the Blktrcae, use the following command as given below "blktrace --help" (or) "man blktrace"
Q
How to discern a partition's traces in Blktrace?
A
That's a block layer tool - it doesn't know or care about partitions. If you're paddling around in blktrace, I suspect you're expected to know what I/O is what.
Although it's been a while sin
Q
How to resolve the problem of Blktrace pid doesn't match real process ID?
A
For Blktrace pid doesn't match real process ID,
"$ sudo blktrace -d /dev/sda -o -| blkparse -i -"
Q
How to check version of the Blktrace?
A
For check the version of Bliktrace, use the following command as given below,
"# blktrace -V "