mariadb (MySQL) stopped flushing relay-bin log after mysqld-relay-bin.999999

We have a pretty big MariaDB master-slave setup, which is really under heavy load and suddenly one of our slaves stopped purging relay logs! And soon the free space got less and it was clear we were going to run out of space for the data partition.

Here is the problem we have only 49G left free space for our mysql datadir “/var/lib/mysql-datadir”. You can see the replication is OK and running (it’s not behind – “Seconds_Behind_Master: 0”), the

Relay_Log_File says mysqld-relay-bin.999999

but it is not true! You can see there are tones of more relay logs after “mysqld-relay-bin.999999” – in fact the current MySQL relay binlog file is “mysqld-relay-bin.1071413” (look below we included a listing of the datadir).

And “FLUSH RELAY LOGS” does not help, at all!

It just not freed any byte on the partition and no files were removed after “mysqld-relay-bin.999999” as before.
Keep on reading!

ffmpeg chroot jail from Gentoo linux (ffmpeg 4.1 with gcc 8.2)

Here we build a Gentoo ssh chroot jail. You may need this because

  • you want the bleeding edge versions of the video libraries like x264, x265, ffmpeg the latest version and so on.
  • latest version of GNU C library and the compiler GNU GCC (version 8.2) at the moment
  • use all the optimizations for compiling the ffmpeg and the libraries for you current processor. Use “-march=native”
  • you want just to be able to update your system and not to break your carefully compiled latest version ffmpeg
  • experiment with GCC compile flags
  • update and test in another directory by just copying the old chroot jail directory
  • no need of any additional software on the host (like virtualization lxc, docker, qemu, etc)
  • or you might want a 32bit version (why? really? but it is possible…)

Of course, you can use for the base any Linux system, but it is easy with Gentoo – the latest versions of almost all important libraries and a packet system, which builds everything for you after a little bit of first tuning…

So here is how to do it:
Keep on reading!

LSI MegaRAID 2108 freezes with abort command and all processes hang up in disk sleep

It happened to one of our old LSI MegaRAID 2108 controllers (AOC-USAS2LP-H8iR (smc2108) with 36 disk, 32x2T and 4x8T) to freeze and most of the processes hang up with Disk sleep. The server was up, the network was working, but no login could be successful. A hard reset was executed with the IPMI KVM. The server started up, the MegaRAID controller booted with a warning that it was shutdown unexpectedly so there could be possible loss of data and to accept it by pressing any key or “C” to boot in the WebBIOS of the controller.

To summarize it up: the LSI controller hangs up when is in the following modes:

  1. Background Initialization
  2. Check Consistency

Aborting and disabling the modes above let out controller to work till replacement. If you experience any kind of strange disk hangs or freezes you can try our solution here! Check below to see how to do it yourself.

Keep on reading!

systemd service freezes in activating (start-post) status – mysqld or other services

We’ve experienced this with the MySQL server under CentOS 7, but you can have this state with other services!
After updating our MySQL we tried to start it up, but the service got this strange state after “systemctl start” returned:

[root@mysql2 ~]# systemctl start mysqld
Job for mysqld.service failed because a timeout was exceeded. See "systemctl status mysqld.service" and "journalctl -xe" for details.

The timeout is big it’s something like 5 to 10 minutes and so it is typical (do not do it!) to type “ctrl+c” and you end up without this message and a strange state of the mysql:

[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start-post) since Fri 2018-11-09 09:00:55 UTC; 6min ago
  Process: 8333 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 8321 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 8333 (code=exited, status=0/SUCCESS);         : 8334 (mysql-systemd-s)
   CGroup: /user.slice/user-0.slice/session-2395.scope/system.slice/mysqld.service
           └─control
             ├─ 8334 /bin/bash /usr/bin/mysql-systemd-start post
             └─10152 sleep 1

Nov 09 09:00:55 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 09:00:56 mysql2.mytv.bg mysqld_safe[8333]: 181109 09:00:56 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 09:00:56 mysql2.mytv.bg mysqld_safe[8333]: 181109 09:00:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql

Meanwhile with “pstree”:

[root@mysql2 ~]# pstree
systemd─┬─agetty
        ├─crond
        ├─dbus-daemon
        ├─mysql-systemd-s───sleep
        ├─rsyslogd───2*[{rsyslogd}]
        ├─sshd─┬─sshd───bash───systemctl─┬─systemctl
        │      │                         └─systemd-tty-ask
        │      └─sshd───bash───pstree
        ├─systemd-journal
        └─systemd-logind

So as you can see no mysqld process! Apparently systemctl had tried to start MySQL server process and it failed.
So the first thing to do was to check the MySQL logs. In our case it was a obsolete option in my.cnf:

2018-11-09 09:10:57 11384 [ERROR] /usr/sbin/mysqld: unknown variable 'default-character-set=utf8'
2018-11-09 09:10:57 11384 [ERROR] Aborting

The interesting part is that

the service got “Active: activating (start-post)” and when you fix the problem you cannot “systemctl start mysqld” it just start to wait for the current timeout.

In fact this state means “I’m trying to start the service…” and it is in an endless loop to start the service and if you the service has a big start timeout like 5-10 minutes you must wait for the next iteration of the loop to start the service successfully (if you fixed the problem!). And if you want not to wait you must execute first stop to the service and then start – you’ll not wait for any timeout and you can check immediately if the service was started successfully:

[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start-post) since Fri 2018-11-09 09:20:56 UTC; 2min 50s ago
  Process: 13208 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 13196 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 13208 (code=exited, status=0/SUCCESS);         : 13209 (mysql-systemd-s)
   CGroup: /user.slice/user-0.slice/session-2395.scope/system.slice/mysqld.service
           └─control
             ├─13209 /bin/bash /usr/bin/mysql-systemd-start post
             └─14357 sleep 1

Nov 09 09:20:56 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 09:20:56 mysql2.mytv.bg mysqld_safe[13208]: 181109 09:20:56 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 09:20:56 mysql2.mytv.bg mysqld_safe[13208]: 181109 09:20:56 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql2 ~]# systemctl start mysqld
Job for mysqld.service failed because a timeout was exceeded. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-11-09 09:30:59 UTC; 2s ago
  Process: 15656 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 15643 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 15655 (mysqld_safe)
   CGroup: /user.slice/user-0.slice/session-2395.scope/system.slice/mysqld.service
           ├─15655 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─16243 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --open-files-limit=10000...

Nov 09 09:30:56 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 09:30:57 mysql2.mytv.bg mysqld_safe[15655]: 181109 09:30:57 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 09:30:57 mysql2.mytv.bg mysqld_safe[15655]: 181109 09:30:57 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 09 09:30:59 mysql2.mytv.bg systemd[1]: Started MySQL Community Server.

As you can see we even received error again that the service cannot be started and immediately after that the service status is in normal “active (running)” state! And we waited for around 10 minutes! You can see the times in the logs above.
So to summarize it up:

If you have a service in “activating (start-post)” the service cannot be started because of an error, check and fix the problem and then issue “stop and start”:

[root@mysql2 ~]# systemctl start mysqld
Job for mysqld.service failed because a timeout was exceeded. See "systemctl status mysqld.service" and "journalctl -xe" for details.
[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: activating (start-post) since Fri 2018-11-09 10:05:20 UTC; 2min 17s ago
  Process: 23601 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 23589 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 23601 (code=exited, status=0/SUCCESS);         : 23602 (mysql-systemd-s)
   CGroup: /user.slice/user-0.slice/session-2395.scope/system.slice/mysqld.service
           └─control
             ├─23602 /bin/bash /usr/bin/mysql-systemd-start post
             └─24646 sleep 1

Nov 09 10:05:20 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 10:05:21 mysql2.mytv.bg mysqld_safe[23601]: 181109 10:05:21 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 10:05:21 mysql2.mytv.bg mysqld_safe[23601]: 181109 10:05:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root@mysql2 ~]# systemctl stop mysqld
[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: inactive (dead) since Fri 2018-11-09 10:07:52 UTC; 4s ago
  Process: 23602 ExecStartPost=/usr/bin/mysql-systemd-start post (code=killed, signal=TERM)
  Process: 23601 ExecStart=/usr/bin/mysqld_safe --basedir=/usr (code=exited, status=0/SUCCESS)
  Process: 23589 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 23601 (code=exited, status=0/SUCCESS)

Nov 09 10:05:20 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 10:05:21 mysql2.mytv.bg mysqld_safe[23601]: 181109 10:05:21 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 10:05:21 mysql2.mytv.bg mysqld_safe[23601]: 181109 10:05:21 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 09 10:07:52 mysql2.mytv.bg systemd[1]: Stopped MySQL Community Server.
[root@mysql2 ~]# systemctl start mysqld
[root@mysql2 ~]# systemctl status mysqld
● mysqld.service - MySQL Community Server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
   Active: active (running) since Fri 2018-11-09 10:08:06 UTC; 3s ago
  Process: 24711 ExecStartPost=/usr/bin/mysql-systemd-start post (code=exited, status=0/SUCCESS)
  Process: 24698 ExecStartPre=/usr/bin/mysql-systemd-start pre (code=exited, status=0/SUCCESS)
 Main PID: 24710 (mysqld_safe)
   CGroup: /user.slice/user-0.slice/session-2395.scope/system.slice/mysqld.service
           ├─24710 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─25298 /usr/sbin/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mysqld.log --open-files-limit=10000...

Nov 09 10:08:04 mysql2.mytv.bg systemd[1]: Starting MySQL Community Server...
Nov 09 10:08:04 mysql2.mytv.bg mysqld_safe[24710]: 181109 10:08:04 mysqld_safe Logging to '/var/log/mysqld.log'.
Nov 09 10:08:04 mysql2.mytv.bg mysqld_safe[24710]: 181109 10:08:04 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Nov 09 10:08:06 mysql2.mytv.bg systemd[1]: Started MySQL Community Server.

Reset lost admin password of Grafana server (CentOS 7)

It could happen to lose your Grafana admin password and luckily there is a pretty easy way for the system administrator of the Grafana server to reset the admin password.
There is really good and simple page of how you can reset the admin password with grafana-cli in the documentation of Grafana website. Probably you can check it, too.

The problem is that most distributions like the one we use (CentOS 7) rearrange the home directory of the Grafana software and if you try to use grafana-cli you’ll end up with the error mentioned in the section below the solution we offer you here! And you really could mess it up and hurry to say this software is buggy!
First, “grafana-cli admin reset-admin-password ” needs to know where is your configuration file and Grafana home directory, because from the configuration it will extract what kind of back-end server you use like sqlite3 or MySQL (or other) and the path or login data if needed to the back-end, then it will reset the password with the given one. At the bottom of this article, there is another method of resetting the Grafana admin password without grafana-cli – manual reset in the database.
So first you should check with what command-line arguments was your instance of Grafana server started:
Keep on reading!

Upgrade self-hosted atlassian bitbucket 4.x to 5.x in CentOS 7

Here we are going to show you a real example of how we upgraded out Atlassian Bitbucket server from 4.14.4 (around April 2017 installation) with the latest version of Atlassian Bitbucket 5.14.0. We use

  1. using self-hosted instance of Bitbucket 4.14.4
  2. Linux distro – CentOS 7.
  3. MySQL server for back-end. So there is a jdbc mysql driver (which should be installed after the upgrade).
  4. NGINX is used as proxy for our main HTTPS url. So we have changed our default configuration in server (in sever.xml).
  5. Bitbucket is loaded from a URL/bitbucket – “https://dev.example.com/bitbucket/”. So we have changed our default configuration (in sever.xml).

and you’ll see there are some pitfalls you can avoid if you follow our article. The latest git program in CentOS 7 is 1.8 and is not compatible with the new Atlassian Bitbucket 5.x, so we need to solve this problem before updating the server. Check out the official upgrade page here
Keep on reading!

Delay loading all pages in the Chromium and Google Chrome browsers tabs during start up and save a lot of memory

Recently we noticed our Chromium began to behavior really strange (we noticed it from Chromium version 69). When starting the Chromium browser the system tended to lag for 4-8 seconds and it was apparently connected with the browsers’ tabs opened in the previous session.
These days many people open multiple Internet pages in the browsers’ tabs and even more use the feature of

quitting the browser and then starting it back and the browser restores the previous session – all tabs with the pages loaded before.

. And time passes and we get used to open and leave more and more tabs, so not it is normal to have more than 30 opened page tabs in your browser, but last versions of the Chromium something has changed, because when you start the browser it completely loads all the pages, we do not think this was the case before so we dig it into the problem.
We use Chromium under (Gentoo) Linux and here is the problem:

top - 16:20:09 up 16 days, 16:36, 14 users,  load average: 4.77, 0.55, 0.43
Tasks: 288 total,  10 running, 201 sleeping,   0 stopped,   0 zombie
%Cpu(s): 82.6 us, 16.2 sy,  0.0 ni,  1.2 id,  0.0 wa,  0.0 hi,  0.0 si,  0.0 st
KiB Mem :  8143960 total,  3012776 free,  3828732 used,  1302452 buff/cache
KiB Swap:  7606268 total,  6855752 free,   750516 used.  2554612 avail Mem 

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                                                                                                 
16082 myuser     20   0 3975632 371280 191940 S 106.9  4.6   0:05.86 /usr/lib64/chromium-browser/chrome --extra-plugin-dir=/usr/lib64/nsbrowser/plugins --ppapi-flash-path=+ 
16380 myuser     20   0 1779900 116276  76624 S  28.4  1.4   0:00.41 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16420 myuser     20   0 1777396 117096  85464 S  18.6  1.4   0:00.30 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16540 myuser     20   0 1850308 109576  76616 R  17.6  1.3   0:00.24 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16565 myuser     20   0 1769716 108588  81336 S  17.6  1.3   0:00.23 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16400 myuser     20   0 1775876 105220  76932 R  12.7  1.3   0:00.21 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16334 myuser     20   0 1770128 111588  83760 S  11.8  1.4   0:00.26 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
 5644 myuser      9 -11 3474604  11112   8368 S   9.8  0.1  14:50.60 /usr/bin/pulseaudio --start --log-target=syslog                                                         
16346 myuser     20   0 1772160 103924  76920 R   9.8  1.3   0:00.17 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16369 myuser     20   0 1772060 101696  74928 R   9.8  1.2   0:00.16 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16409 myuser     20   0 1783340 115752  77116 R   9.8  1.4   0:00.18 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16435 myuser     20   0 1770664 105088  81656 S   9.8  1.3   0:00.19 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16483 myuser     20   0 1772228 112008  83176 S   9.8  1.4   0:00.17 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16509 myuser     20   0 1772116 108544  81732 S   9.8  1.3   0:00.20 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16448 myuser     20   0 1771368 101300  74956 R   8.8  1.2   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16459 myuser     20   0 1692864 102668  80676 R   8.8  1.3   0:00.15 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16506 myuser     20   0 1766364  99588  78384 S   7.8  1.2   0:00.15 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16577 myuser     20   0 1767296 102268  80272 S   7.8  1.3   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
21462 myuser     20   0 2599480 493592  95284 S   7.8  6.1  17:00.39 /usr/lib64/firefox/firefox -contentproc -childID 13 -isForBrowser -prefsLen 51222 -schedulerPrefs 0001+ 
16417 myuser     20   0 1767568  99584  75992 R   5.9  1.2   0:00.12 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16530 myuser     20   0 1764332  99036  78768 S   5.9  1.2   0:00.11 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16341 myuser     20   0 1688088  96856  77776 S   4.9  1.2   0:00.09 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16395 myuser     20   0 1765648  96284  75132 S   4.9  1.2   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16464 myuser     20   0 1773864 104360  76260 S   4.9  1.3   0:00.12 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16467 myuser     20   0 1765740  96184  75520 S   4.9  1.2   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16491 myuser     20   0 1691968  96864  75744 S   3.9  1.2   0:00.14 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16496 myuser     20   0 1691964  97048  75852 S   3.9  1.2   0:00.18 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16501 myuser     20   0 1691492  92592  72604 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16578 myuser     20   0 1765432  93580  73868 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16587 myuser     20   0 1765416  93624  73856 S   3.9  1.1   0:00.10 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
28861 myuser     20   0 3503208 405676  91716 S   3.9  5.0  11:41.21 /usr/bin/firefox                                                                                        
16454 myuser     20   0 1617744  87852  70072 R   2.9  1.1   0:00.09 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
16548 myuser     20   0 1692100  97336  76440 S   2.9  1.2   0:00.13 /usr/lib64/chromium-browser/chrome --type=renderer --file-url-path-alias=/gen=/usr/lib64/chromium-brow+ 
 5430 root      20   0  510884 133980 116036 S   2.0  1.6  39:33.10 /usr/bin/X -nolisten tcp -auth /var/run/sddm/{0c17f929-befd-402b-a80b-207e92f61272} -background none -+ 
16011 myuser     20   0  140316   3192   2632 R   2.0  0.0   0:00.44 top -d1                                                                                                 
 5193 root     -51   0       0      0      0 S   1.0  0.0  97:33.55 [irq/46-iwlwifi]                                                                                        
 5601 myuser     20   0 3422104  59664  23276 S   1.0  0.7  41:55.20 /usr/bin/kwin_x11 -session 10147150e9da000152673938100000083010144_1534452204_442575

As you can see starting Chromium it just flooded the system with hungry for CPU processes, so many that even a decent machine with 4 cores will get into troubles with 9 running Chromium process for a while! The load at the first seconds goes to 5-9 (as you can see here is 4.77 from below 1 – actually 0.5 ).
Keep on reading!

Use Intel QuickSync with ffmpeg to have hardware accelerated video decoding and encoding – CentOS 7.4.1708

This howto shows how you can use ffmpeg to hardware accelerate the video decoding and encoding if you have the proper Intel processor. Some of the Intel processors have GPU unit in them, which can be used to decode and encode video streams and it is pretty fast! High end Intel CPU could encode around 20 h264 (using faster preset) video streams on a single processor mini server as SUPERMICRO system using X11SSV-M4F.
Here are the steps how to enable the hardware options and what and how to install the software to hardware encode a video stream successful under linux – CentOS 7 distro.

For the first four steps just follow the howto “Install Intel Media Studio SDK and GPU driver from Intel Media Server Studio 2018 R1 – CentOS 7 (7.4.1708)” Here we include only the headers of the steps, because they are important part of this howto.
Installing Media Server Studio your system will get validated stack of software by Intel to build application against Media SDK interface:

  • libmfx.a dispatcher – the API for your application
  • libmfxhw64.so hardware implementation
  • related libraries (including OpenCL)
  • specific versions for libva and libdrm
  • user mode driver
  • modified i915 graphics driver module
  • kernel patches

Here are the steps:

STEP 1) Enable internal graphics in your system.

We have an article on the topic – Enable internal graphics in SUPERMICRO servers

STEP 2) Install the right CentOS 7 – 7.4.1708

We have an article on the topic – Howto do a netinstall of CentOS 7 (7.4.1708) – minimal server installation

STEP 3) Download Intel Media Server Studio 2018 R1

We have an article on the topic – Download, what is in the package Intel Media Server Studio 2018 R1 and which Linux distro it supports

STEP 4) Install Intel Media Studio SDK from Intel Media Server Studio 2018 R1

“Install Intel Media Studio SDK and GPU driver from Intel Media Server Studio 2018 R1 – CentOS 7 (7.4.1708)”

STEP 5) Tune pkgconfig libmfx (Intel library, installed with the Media Server Studio)

Create a file:

/usr/lib64/pkgconfig/libmfx.pc

with the following content:

prefix=/opt/intel/mediasdk
exec_prefix=${prefix}
libdir=${prefix}/lib/lin_x64
includedir=${prefix}/include
 
Name: libmfx
Description: Intel Media SDK
Version: 16.8
Libs: -L${libdir} -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm
Cflags: -I${includedir} -I/usr/include/libdrm

STEP 6) Move the Media SDK include files in a mfx sub-directory

This is required because ffmpeg expect these files to be in a sub-directory

[root@srv ~]# mkdir /opt/intel/mediasdk/include/mfx
[root@srv ~]# cp /opt/intel/mediasdk/include/*.h /opt/intel/mediasdk/include/mfx/

STEP 7) Install yasm – a dependency for the ffmpeg software.

[root@srv ~]# wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz
[root@srv ~]# tar xzf yasm-1.3.0.tar.gz
[root@srv ~]# cd yasm-1.3.0
[root@srv yasm-1.3.0]# export CFLAGS="-O2 -march=native -msse3 -fomit-frame-pointer -pipe"
[root@srv yasm-1.3.0]# export CXXFLAGS="${CFLAGS}"
[root@srv yasm-1.3.0]# export CHOST="x86_64-pc-linux-gnu"
[root@srv yasm-1.3.0]# export LDFLAGS="-Wl,-O1"
[root@srv yasm-1.3.0]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
....
....
....
[root@srv yasm-1.3.0]# make -j8
gcc -std=gnu99  -I.  \
  -c -o genperf.o `test -f tools/genperf/genperf.c || echo './'`tools/genperf/genperf.c
gcc -std=gnu99  -I.  \
  -c -o gp-perfect.o `test -f tools/genperf/perfect.c || echo './'`tools/genperf/perfect.c
gcc -std=gnu99  -I.  \
  -c -o gp-phash.o `test -f libyasm/phash.c || echo './'`libyasm/phash.c
gcc -std=gnu99  -I.  \
  -c -o gp-xmalloc.o `test -f libyasm/xmalloc.c || echo './'`libyasm/xmalloc.c
gcc -std=gnu99  -I.  \
  -c -o gp-xstrdup.o `test -f libyasm/xstrdup.c || echo './'`libyasm/xstrdup.c
gcc -std=gnu99  -I.  \
  -c -o re2c-main.o `test -f tools/re2c/main.c || echo './'`tools/re2c/main.c
gcc -std=gnu99  -I.  \
  -c -o re2c-code.o `test -f tools/re2c/code.c || echo './'`tools/re2c/code.c
....
....
....
[root@srv yasm-1.3.0]# make install
make  install-recursive
make[1]: Entering directory `/root/yasm-1.3.0'
....
....
....
[root@srv yasm-1.3.0]#
[root@srv yasm-1.3.0]# ldconfig
[root@srv yasm-1.3.0]# cd ../
[root@srv ~]#

STEP 8) Download ffmpeg version 2.8.X and compile it

it is important to use this branch 2.8.X because we’ve tested with the others 3.2.X, 3.3.X, 3.4.X and there were errors and we unable to use the the GPU unit to accelerate our video decoding and encoding. Here is the different ffmpeg release https://ffmpeg.org/download.html#releases or you can use the github to download https://github.com/FFmpeg/FFmpeg/releases

[root@srv ~]# wget https://www.ffmpeg.org/releases/ffmpeg-2.8.14.tar.bz2
[root@srv ~]# tar xjf ffmpeg-2.8.14.tar.bz2
[root@srv ~]# cd ffmpeg-2.8.14
[root@srv ffmpeg-2.8.14]# export CFLAGS="-O2 -march=native -msse3 -fomit-frame-pointer -pipe"
[root@srv ffmpeg-2.8.14]# export CXXFLAGS="${CFLAGS}"
[root@srv ffmpeg-2.8.14]# export CHOST="x86_64-pc-linux-gnu"
[root@srv ffmpeg-2.8.14]# export LDFLAGS="-Wl,-O1"
[root@srv ffmpeg-2.8.14]# ./configure --enable-libmfx --prefix=/usr/local/ffmpeg-qsv
install prefix            /usr/local/ffmpeg-qsv
source path               .
C compiler                gcc
C library                 glibc
ARCH                      x86 (generic)
big-endian                no
runtime cpu detection     yes
yasm                      yes
MMX enabled               yes
MMXEXT enabled            yes
3DNow! enabled            yes
3DNow! extended enabled   yes
SSE enabled               yes
SSSE3 enabled             yes
AVX enabled               yes
XOP enabled               yes
FMA3 enabled              yes
FMA4 enabled              yes
i686 features enabled     yes
CMOV is fast              yes
EBX available             yes
EBP available             yes
debug symbols             yes
strip symbols             yes
optimize for size         no
optimizations             yes
static                    yes
shared                    no
postprocessing support    no
new filter support        yes
network support           yes
threading support         pthreads
safe bitstream reader     yes
SDL support               no
opencl enabled            no
texi2html enabled         no
perl enabled              yes
pod2man enabled           yes
makeinfo enabled          no
makeinfo supports HTML    no

Enabled programs:
ffmpeg                  ffprobe                 ffserver

External libraries:
iconv                   lzma                    zlib
libmfx

Enabled decoders:
aac                     ayuv                    frwu
aac_fixed               bethsoftvid             g2m
aac_latm                bfi                     g723_1
aasc                    bink                    g729
ac3                     binkaudio_dct           gif
ac3_fixed               binkaudio_rdft          gsm
adpcm_4xm               bintext                 gsm_ms
adpcm_adx               bmp                     h261
adpcm_afc               bmv_audio               h263
adpcm_ct                bmv_video               h263i
adpcm_dtk               brender_pix             h263p
adpcm_ea                c93                     h264
adpcm_ea_maxis_xa       cavs                    h264_qsv
adpcm_ea_r1             ccaption                hap
adpcm_ea_r2             cdgraphics              hevc
adpcm_ea_r3             cdxl                    hevc_qsv
adpcm_ea_xas            cinepak                 hnm4_video
adpcm_g722              cljr                    hq_hqa
adpcm_g726              cllc                    hqx
adpcm_g726le            comfortnoise            huffyuv
adpcm_ima_amv           cook                    iac
adpcm_ima_apc           cpia                    idcin
adpcm_ima_dk3           cscd                    idf
adpcm_ima_dk4           cyuv                    iff_byterun1
adpcm_ima_ea_eacs       dca                     iff_ilbm
adpcm_ima_ea_sead       dds                     imc
adpcm_ima_iss           dfa                     indeo2
adpcm_ima_oki           dirac                   indeo3
adpcm_ima_qt            dnxhd                   indeo4
adpcm_ima_rad           dpx                     indeo5
adpcm_ima_smjpeg        dsd_lsbf                interplay_dpcm
adpcm_ima_wav           dsd_lsbf_planar         interplay_video
adpcm_ima_ws            dsd_msbf                jacosub
adpcm_ms                dsd_msbf_planar         jpeg2000
adpcm_sbpro_2           dsicinaudio             jpegls
adpcm_sbpro_3           dsicinvideo             jv
adpcm_sbpro_4           dss_sp                  kgv1
adpcm_swf               dvbsub                  kmvc
adpcm_thp               dvdsub                  lagarith
adpcm_thp_le            dvvideo                 loco
adpcm_vima              dxa                     mace3
adpcm_xa                dxtory                  mace6
adpcm_yamaha            eac3                    mdec
aic                     eacmv                   metasound
alac                    eamad                   microdvd
alias_pix               eatgq                   mimic
als                     eatgv                   mjpeg
amrnb                   eatqi                   mjpegb
amrwb                   eightbps                mlp
amv                     eightsvx_exp            mmvideo
anm                     eightsvx_fib            motionpixels
ansi                    escape124               movtext
ape                     escape130               mp1
apng                    evrc                    mp1float
ass                     exr                     mp2
asv1                    ffv1                    mp2float
asv2                    ffvhuff                 mp3
atrac1                  ffwavesynth             mp3adu
atrac3                  fic                     mp3adufloat
atrac3p                 flac                    mp3float
aura                    flashsv                 mp3on4
aura2                   flashsv2                mp3on4float
avrn                    flic                    mpc7
avrp                    flv                     mpc8
avs                     fourxm                  mpeg1video
avui                    fraps                   mpeg2_qsv
mpeg2video              prores                  tscc2
mpeg4                   prores_lgpl             tta
mpegvideo               ptx                     twinvq
mpl2                    qcelp                   txd
msa1                    qdm2                    ulti
msmpeg4v1               qdraw                   utvideo
msmpeg4v2               qpeg                    v210
msmpeg4v3               qtrle                   v210x
msrle                   r10k                    v308
mss1                    r210                    v408
mss2                    ra_144                  v410
msvideo1                ra_288                  vb
mszh                    ralf                    vble
mts2                    rawvideo                vc1
mvc1                    realtext                vc1_qsv
mvc2                    rl2                     vc1image
mxpeg                   roq                     vcr1
nellymoser              roq_dpcm                vima
nuv                     rpza                    vmdaudio
on2avc                  rv10                    vmdvideo
opus                    rv20                    vmnc
paf_audio               rv30                    vorbis
paf_video               rv40                    vp3
pam                     s302m                   vp5
pbm                     sami                    vp6
pcm_alaw                sanm                    vp6a
pcm_bluray              sgi                     vp6f
pcm_dvd                 sgirle                  vp7
pcm_f32be               shorten                 vp8
pcm_f32le               sipr                    vp9
pcm_f64be               smackaud                vplayer
pcm_f64le               smacker                 vqa
pcm_lxf                 smc                     wavpack
pcm_mulaw               smvjpeg                 webp
pcm_s16be               snow                    webvtt
pcm_s16be_planar        sol_dpcm                wmalossless
pcm_s16le               sonic                   wmapro
pcm_s16le_planar        sp5x                    wmav1
pcm_s24be               srt                     wmav2
pcm_s24daud             ssa                     wmavoice
pcm_s24le               stl                     wmv1
pcm_s24le_planar        subrip                  wmv2
pcm_s32be               subviewer               wmv3
pcm_s32le               subviewer1              wmv3image
pcm_s32le_planar        sunrast                 wnv1
pcm_s8                  svq1                    ws_snd1
pcm_s8_planar           svq3                    xan_dpcm
pcm_u16be               tak                     xan_wc3
pcm_u16le               targa                   xan_wc4
pcm_u24be               targa_y216              xbin
pcm_u24le               tdsc                    xbm
pcm_u32be               text                    xface
pcm_u32le               theora                  xl
pcm_u8                  thp                     xsub
pcm_zork                tiertexseqvideo         xwd
pcx                     tiff                    y41p
pgm                     tmv                     yop
pgmyuv                  truehd                  yuv4
pgssub                  truemotion1             zero12v
pictor                  truemotion2             zerocodec
pjs                     truespeech              zlib
png                     tscc                    zmbv
ppm

Enabled encoders:
a64multi                huffyuv                 png
a64multi5               jpeg2000                ppm
aac                     jpegls                  prores
ac3                     ljpeg                   prores_aw
ac3_fixed               mjpeg                   prores_ks
adpcm_adx               movtext                 qtrle
adpcm_g722              mp2                     r10k
adpcm_g726              mp2fixed                r210
adpcm_ima_qt            mpeg1video              ra_144
adpcm_ima_wav           mpeg2_qsv               rawvideo
adpcm_ms                mpeg2video              roq
adpcm_swf               mpeg4                   roq_dpcm
adpcm_yamaha            msmpeg4v2               rv10
alac                    msmpeg4v3               rv20
alias_pix               msvideo1                s302m
amv                     nellymoser              sgi
apng                    pam                     snow
ass                     pbm                     sonic
asv1                    pcm_alaw                sonic_ls
asv2                    pcm_f32be               srt
avrp                    pcm_f32le               ssa
avui                    pcm_f64be               subrip
ayuv                    pcm_f64le               sunrast
bmp                     pcm_mulaw               svq1
cinepak                 pcm_s16be               targa
cljr                    pcm_s16be_planar        tiff
comfortnoise            pcm_s16le               tta
dca                     pcm_s16le_planar        utvideo
dnxhd                   pcm_s24be               v210
dpx                     pcm_s24daud             v308
dvbsub                  pcm_s24le               v408
dvdsub                  pcm_s24le_planar        v410
dvvideo                 pcm_s32be               vorbis
eac3                    pcm_s32le               wavpack
ffv1                    pcm_s32le_planar        webvtt
ffvhuff                 pcm_s8                  wmav1
flac                    pcm_s8_planar           wmav2
flashsv                 pcm_u16be               wmv1
flashsv2                pcm_u16le               wmv2
flv                     pcm_u24be               xbm
g723_1                  pcm_u24le               xface
gif                     pcm_u32be               xsub
h261                    pcm_u32le               xwd
h263                    pcm_u8                  y41p
h263p                   pcx                     yuv4
h264_qsv                pgm                     zlib
hevc_qsv                pgmyuv                  zmbv

Enabled hwaccels:
h263_vaapi              hevc_vaapi              vc1_qsv
h264_qsv                mpeg2_qsv               vc1_vaapi
h264_vaapi              mpeg2_vaapi             wmv3_vaapi
hevc_qsv                mpeg4_vaapi

Enabled parsers:
aac                     dvdsub                  mpegvideo
aac_latm                flac                    opus
ac3                     g729                    png
adx                     gsm                     pnm
bmp                     h261                    rv30
cavsvideo               h263                    rv40
cook                    h264                    tak
dca                     hevc                    vc1
dirac                   mjpeg                   vorbis
dnxhd                   mlp                     vp3
dpx                     mpeg4video              vp8
dvbsub                  mpegaudio               vp9
dvd_nav

Enabled demuxers:
aa                      g723_1                  mpjpeg
aac                     g729                    mpl2
ac3                     gif                     mpsub
act                     gsm                     msnwc_tcp
adf                     gxf                     mtv
adp                     h261                    mv
adx                     h263                    mvi
aea                     h264                    mxf
afc                     hevc                    mxg
aiff                    hls                     nc
amr                     hnm                     nistsphere
anm                     ico                     nsv
apc                     idcin                   nut
ape                     idf                     nuv
apng                    iff                     ogg
aqtitle                 ilbc                    oma
asf                     image2                  paf
asf_o                   image2_alias_pix        pcm_alaw
ass                     image2_brender_pix      pcm_f32be
ast                     image2pipe              pcm_f32le
au                      image_bmp_pipe          pcm_f64be
avi                     image_dds_pipe          pcm_f64le
avr                     image_dpx_pipe          pcm_mulaw
avs                     image_exr_pipe          pcm_s16be
bethsoftvid             image_j2k_pipe          pcm_s16le
bfi                     image_jpeg_pipe         pcm_s24be
bfstm                   image_jpegls_pipe       pcm_s24le
bink                    image_pictor_pipe       pcm_s32be
bintext                 image_png_pipe          pcm_s32le
bit                     image_qdraw_pipe        pcm_s8
bmv                     image_sgi_pipe          pcm_u16be
boa                     image_sunrast_pipe      pcm_u16le
brstm                   image_tiff_pipe         pcm_u24be
c93                     image_webp_pipe         pcm_u24le
caf                     ingenient               pcm_u32be
cavsvideo               ipmovie                 pcm_u32le
cdg                     ircam                   pcm_u8
cdxl                    iss                     pjs
cine                    iv8                     pmp
concat                  ivf                     pva
data                    jacosub                 pvf
daud                    jv                      qcp
dfa                     latm                    r3d
dirac                   live_flv                rawvideo
dnxhd                   lmlm4                   realtext
dsf                     loas                    redspark
dsicin                  lrc                     rl2
dss                     lvf                     rm
dts                     lxf                     roq
dtshd                   m4v                     rpl
dv                      matroska                rsd
dvbsub                  mgsts                   rso
dxa                     microdvd                rtp
ea                      mjpeg                   rtsp
ea_cdata                mlp                     sami
eac3                    mlv                     sap
epaf                    mm                      sbg
ffm                     mmf                     sdp
ffmetadata              mov                     sdr2
filmstrip               mp3                     segafilm
flac                    mpc                     shorten
flic                    mpc8                    siff
flv                     mpegps                  sln
fourxm                  mpegts                  smacker
frm                     mpegtsraw               smjpeg
g722                    mpegvideo               smush
sol                     tmv                     wav
sox                     truehd                  wc3
spdif                   tta                     webm_dash_manifest
srt                     tty                     webvtt
stl                     txd                     wsaud
str                     vc1                     wsvqa
subviewer               vc1t                    wtv
subviewer1              vivo                    wv
sup                     vmd                     xa
swf                     vobsub                  xbin
tak                     voc                     xmv
tedcaptions             vplayer                 xwma
thp                     vqf                     yop
tiertexseq              w64                     yuv4mpegpipe

Enabled muxers:
a64                     ipod                    pcm_s32be
ac3                     ircam                   pcm_s32le
adts                    ismv                    pcm_s8
adx                     ivf                     pcm_u16be
aiff                    jacosub                 pcm_u16le
amr                     latm                    pcm_u24be
apng                    lrc                     pcm_u24le
asf                     m4v                     pcm_u32be
asf_stream              matroska                pcm_u32le
ass                     matroska_audio          pcm_u8
ast                     md5                     psp
au                      microdvd                rawvideo
avi                     mjpeg                   rm
avm2                    mkvtimestamp_v2         roq
bit                     mlp                     rso
caf                     mmf                     rtp
cavsvideo               mov                     rtp_mpegts
crc                     mp2                     rtsp
dash                    mp3                     sap
data                    mp4                     segment
daud                    mpeg1system             singlejpeg
dirac                   mpeg1vcd                smjpeg
dnxhd                   mpeg1video              smoothstreaming
dts                     mpeg2dvd                sox
dv                      mpeg2svcd               spdif
eac3                    mpeg2video              spx
f4v                     mpeg2vob                srt
ffm                     mpegts                  stream_segment
ffmetadata              mpjpeg                  swf
filmstrip               mxf                     tee
flac                    mxf_d10                 tg2
flv                     mxf_opatom              tgp
framecrc                null                    truehd
framemd5                nut                     uncodedframecrc
g722                    oga                     vc1
g723_1                  ogg                     vc1t
gif                     oma                     voc
gxf                     opus                    w64
h261                    pcm_alaw                wav
h263                    pcm_f32be               webm
h264                    pcm_f32le               webm_chunk
hds                     pcm_f64be               webm_dash_manifest
hevc                    pcm_f64le               webp
hls                     pcm_mulaw               webvtt
ico                     pcm_s16be               wtv
ilbc                    pcm_s16le               wv
image2                  pcm_s24be               yuv4mpegpipe
image2pipe              pcm_s24le

Enabled protocols:
async                   hls                     rtmpt
cache                   http                    rtp
concat                  httpproxy               srtp
crypto                  icecast                 subfile
data                    md5                     tcp
ffrtmphttp              mmsh                    udp
file                    mmst                    udplite
ftp                     pipe                    unix
gopher                  rtmp

Enabled filters:
acrossfade              dctdnoiz                paletteuse
adelay                  deband                  pan
adrawgraph              decimate                perms
aecho                   deflate                 pixdesctest
aeval                   dejudder                psnr
aevalsrc                deshake                 qp
afade                   detelecine              random
aformat                 dilation                removegrain
ainterleave             drawbox                 removelogo
allpass                 drawgraph               replaygain
allrgb                  drawgrid                reverse
allyuv                  dynaudnorm              rgbtestsrc
alphaextract            earwax                  rotate
alphamerge              edgedetect              scale
amerge                  elbg                    scale2ref
amix                    equalizer               select
amovie                  erosion                 sendcmd
anull                   extractplanes           separatefields
anullsink               fade                    setdar
anullsrc                fftfilt                 setfield
apad                    field                   setpts
aperms                  fieldmatch              setsar
aphasemeter             fieldorder              settb
aphaser                 flanger                 showcqt
aresample               format                  showfreqs
areverse                fps                     showinfo
aselect                 framepack               showpalette
asendcmd                framerate               showspectrum
asetnsamples            framestep               showvolume
asetpts                 gradfun                 showwaves
asetrate                haldclut                showwavespic
asettb                  haldclutsrc             shuffleplanes
ashowinfo               hflip                   sidechaincompress
asplit                  highpass                signalstats
astats                  histogram               silencedetect
astreamsync             hqx                     silenceremove
atadenoise              hstack                  sine
atempo                  hue                     smptebars
atrim                   idet                    smptehdbars
avectorscope            il                      split
bandpass                inflate                 ssim
bandreject              interleave              swapuv
bass                    join                    tblend
bbox                    lenscorrection          telecine
biquad                  life                    testsrc
blackdetect             lowpass                 thumbnail
blend                   lut                     tile
cellauto                lut3d                   transpose
channelmap              lutrgb                  treble
channelsplit            lutyuv                  trim
chorus                  mandelbrot              unsharp
codecview               mergeplanes             vectorscope
color                   movie                   vflip
colorbalance            negate                  vignette
colorchannelmixer       noformat                volume
colorkey                noise                   volumedetect
colorlevels             null                    vstack
compand                 nullsink                w3fdif
concat                  nullsrc                 waveform
copy                    overlay                 xbr
crop                    pad                     yadif
curves                  palettegen              zoompan
dcshift

Enabled bsfs:
aac_adtstoasc           imx_dump_header         mpeg4_unpack_bframes
chomp                   mjpeg2jpeg              noise
dump_extradata          mjpega_dump_header      remove_extradata
h264_mp4toannexb        mov2textsub             text2movsub
hevc_mp4toannexb        mp3_header_decompress

Enabled indevs:
dv1394                  lavfi                   v4l2
fbdev                   oss

Enabled outdevs:
fbdev                   oss                     v4l2

License: LGPL version 2.1 or later
Creating config.mak, config.h, and doc/config.texi...
[root@conv11 ffmpeg-2.8.14]# make -j 8
CC      libavdevice/oss.o
CC      libavdevice/alldevices.o
CC      libavdevice/avdevice.o
CC      libavdevice/lavfi.o
CC      libavdevice/dv1394.o
....
....
....
LD      ffmpeg_g
LD      ffprobe_g
LD      ffserver_g
CP      ffserver
STRIP   ffserver
CP      ffprobe
CP      ffmpeg
STRIP   ffprobe
STRIP   ffmpeg
[root@conv11 ffmpeg-2.8.14]# make install
INSTALL doc/ffmpeg.1
INSTALL doc/ffprobe.1
INSTALL doc/ffserver.1
INSTALL doc/ffmpeg-all.1
....
....
....
INSTALL libavutil/tea.h
INSTALL libavutil/lzo.h
INSTALL libavutil/avconfig.h
INSTALL libavutil/ffversion.h
INSTALL libavutil/libavutil.pc
[root@conv11 ffmpeg-2.8.14]#

And now you have a ffmpeg installation build against Intel API libmfx dispatcher, which could benefit from the hardware acceleration in decoding and encoding video streams. Thus using a Intel QuickSync technology.

STEP 9) ffmpeg example – how to use the GPU hardware decoding and encoding

[root@conv11 ffmpeg-2.8.14]# cd
[root@conv11 ~]# wget http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_60fps_stereo_abl.mp4
[root@conv11 ~]# /usr/local/ffmpeg-qsv/bin/ffmpeg -vcodec h264_qsv -i bbb_sunflower_1080p_60fps_stereo_abl.mp4 -vcodec h264_qsv -b:v 600k -maxrate 1200K -s 1280x720 -aspect 16:9 -preset medium -maxrate 500K -g 50 -strict -2 -c:a aac -b:a 96k -ar 44100 -f mpegts -threads 0 output.mp4
ffmpeg version 2.8.14 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --enable-libmfx --prefix=/usr/local/ffmpeg-qsv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'bbb_sunflower_1080p_60fps_stereo_abl.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    creation_time   : 2013-12-16 18:03:30
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
    composer        : Sacha Goedegebure
  Duration: 00:10:34.53, start: 0.000000, bitrate: 6490 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), nv12, 1920x2160, 6005 kb/s, 60 fps, 60 tbr, 60k tbn, 60k tbc (default)
    Metadata:
      creation_time   : 2013-12-16 18:03:30
      handler_name    : GPAC ISO Video Handler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, s16p, 160 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16 18:03:37
      handler_name    : GPAC ISO Audio Handler
    Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16 18:03:37
      handler_name    : GPAC ISO Audio Handler
    Side data:
      audio service type: main
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
Output #0, mpegts, to 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 1
    compatible_brands: isomavc1
    composer        : Sacha Goedegebure
    title           : Big Buck Bunny, Sunflower version
    artist          : Blender Foundation 2008, Janus Bager Kristensen 2013
    comment         : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net
    genre           : Animation
    encoder         : Lavf56.40.101
    Stream #0:0(und): Video: h264 (h264_qsv), nv12, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 600 kb/s, 60 fps, 90k tbn, 60 tbc (default)
    Metadata:
      creation_time   : 2013-12-16 18:03:30
      handler_name    : GPAC ISO Video Handler
      encoder         : Lavc56.60.100 h264_qsv
    Stream #0:1(und): Audio: aac, 44100 Hz, 5.1(side), fltp, 96 kb/s (default)
    Metadata:
      creation_time   : 2013-12-16 18:03:37
      handler_name    : GPAC ISO Audio Handler
      encoder         : Lavc56.60.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (h264 (h264_qsv) -> h264 (h264_qsv))
  Stream #0:2 -> #0:1 (ac3 (native) -> aac (native))
Press [q] to stop, [?] for help
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
[h264_qsv @ 0x3587360] A decode call did not consume any dataitrate=1162.5kbits/s    
    Last message repeated 14 times
frame=38072 fps=126 q=-0.0 Lsize=   90023kB time=00:10:34.48 bitrate=1162.3kbits/s    
video:71572kB audio:7436kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 13.942102%
[root@conv11 ~]# /usr/local/ffmpeg-qsv/bin/ffmpeg -i output.mp4
ffmpeg version 2.8.14 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --enable-libmfx --prefix=/usr/local/ffmpeg-qsv
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
Input #0, mpegts, from 'output.mp4':
  Duration: 00:10:34.57, start: 1.400000, bitrate: 1162 kb/s
  Program 1 
    Metadata:
      service_name    : Big Buck Bunny, Sunflower version
      service_provider: FFmpeg
    Stream #0:0[0x100]: Video: h264 (High) ([27][0][0][0] / 0x001B), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 60 fps, 60 tbr, 90k tbn, 120 tbc
    Stream #0:1[0x101](und): Audio: aac (LC) ([15][0][0][0] / 0x000F), 44100 Hz, 5.1, fltp, 100 kb/s

You can see ffmpeg is using VA-API and /opt/intel/mediasdk/lib64/iHD_drv_video.so for video acceleration encoding.

* Live stream decoding and encoding with hardware acceleration and outputting multiple output

The input stream is from a multicast source and the output is a wowza server

/usr/local/ffmpeg-qsv/bin/ffmpeg -vcodec h264_qsv -i 'udp://239.10.10.1:5000?fifo_size=1000000&overrun_nonfatal=1' -filter_complex '[0:v]yadif=1:0:0,split=3[v1][v2][v3];[v1]scale=1280:720,framerate=50[out1];[v2]scale=960:540,framerate=25[out2];[v3]scale=640:360,framerate=25[out3]' -map '[out1]' -map '[out2]' -map '[out3]' -map 0:a -streamid 0:0x151 -streamid 1:0x150 -streamid 2:0x149 -streamid 3:0x140 -vcodec h264_qsv -preset medium -maxrate:0 1900K -bufsize:0 2400K -b:v:0 1500k -maxrate:1 1200K -bufsize:1 1000K -b:v:1 1000k -maxrate:2 900K -bufsize:2 1000K -b:v:2 600k -g 50 -strict -2 -c:a aac -b:a 96k -ar 44100 -reorder_queue_size 32 -threads 8 -fflags +igndts -copyts -f mpegts 'udp://10.10.10.10:30000?pkt_size=2632&buffer_size=20000000&fifo_size=2000000'
ffmpeg version 2.8.14 Copyright (c) 2000-2018 the FFmpeg developers
  built with gcc 4.8.5 (GCC) 20150623 (Red Hat 4.8.5-16)
  configuration: --enable-libmfx --prefix=/usr/local/ffmpeg-qsv3
  libavutil      54. 31.100 / 54. 31.100
  libavcodec     56. 60.100 / 56. 60.100
  libavformat    56. 40.101 / 56. 40.101
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 40.101 /  5. 40.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.101 /  1.  2.101
[h264_qsv @ 0x21e6960] non-existing PPS 0 referenced
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
    Last message repeated 1 times
Input #0, mpegts, from 'udp://239.10.10.33:5000?fifo_size=1000000&overrun_nonfatal=1':
  Duration: N/A, start: 1375.213422, bitrate: N/A
  Program 74 
    Metadata:
      service_name    : Test 1 HD
      service_provider: Test
    Stream #0:0[0x734]: Video: h264 (High) ([27][0][0][0] / 0x001B), nv12, 1920x1080, 25 fps, 25 tbr, 90k tbn, 90k tbc
    Stream #0:1[0x744]: Audio: mp2 ([3][0][0][0] / 0x0003), 48000 Hz, stereo, s16p, 256 kb/s
[Parsed_framerate_7 @ 0x2413620] time base:1/180000 -> 1/180000 exact:1
[Parsed_framerate_7 @ 0x2413620] fps -> fps:25/1 scene score:7.000000 interpolate start:15 end:240
[Parsed_framerate_5 @ 0x2438d20] time base:1/180000 -> 1/180000 exact:1
[Parsed_framerate_5 @ 0x2438d20] fps -> fps:25/1 scene score:7.000000 interpolate start:15 end:240
[Parsed_framerate_3 @ 0x2934640] time base:1/180000 -> 1/180000 exact:1
[Parsed_framerate_3 @ 0x2934640] fps -> fps:50/1 scene score:7.000000 interpolate start:15 end:240
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
Output #0, mpegts, to 'udp://10.10.10.10:30000?pkt_size=2632&buffer_size=20000000&fifo_size=2000000':
  Metadata:
    encoder         : Lavf56.40.101
    Stream #0:0: Video: h264 (h264_qsv), nv12, 1280x720, q=2-31, 1500 kb/s, 50 fps, 90k tbn, 50 tbc
    Metadata:
      encoder         : Lavc56.60.100 h264_qsv
    Stream #0:1: Video: h264 (h264_qsv), nv12, 960x540, q=2-31, 1000 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.60.100 h264_qsv
    Stream #0:2: Video: h264 (h264_qsv), nv12, 640x360, q=2-31, 600 kb/s, 25 fps, 90k tbn, 25 tbc
    Metadata:
      encoder         : Lavc56.60.100 h264_qsv
    Stream #0:3: Audio: aac, 44100 Hz, stereo, fltp, 96 kb/s
    Metadata:
      encoder         : Lavc56.60.100 aac
Stream mapping:
  Stream #0:0 (h264_qsv) -> yadif (graph 0)
  framerate (graph 0) -> Stream #0:0 (h264_qsv)
  framerate (graph 0) -> Stream #0:1 (h264_qsv)
  framerate (graph 0) -> Stream #0:2 (h264_qsv)
  Stream #0:1 -> #0:3 (mp2 (native) -> aac (native))
Press [q] to stop, [?] for help
libva info: VA-API version 1.0.0
libva info: va_getDriverName() returns 0
libva info: User requested driver 'iHD'
libva info: Trying to open /opt/intel/mediasdk/lib64/iHD_drv_video.so
libva info: Found init function __vaDriverInit_1_0
libva info: va_openDriver() returns 0
[h264_qsv @ 0x21ea740] A decode call did not consume any data=00:23:14.04 bitrate=  46.6kbits/s    
frame=  937 fps= 59 q=-0.0 Lq=-0.0 q=-0.0 size=    8267kB time=00:23:14.57 bitrate=  48.6kbits/s    
video:7225kB audio:228kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 10.923792%

* Troubleshooting

If you get a build error like this, you skipped the (STEP 6) Move the Media SDK include files in a mfx sub-directory. This is required because ffmpeg expect these files to be in a sub-directory. Just move the files in a sub-directory mfx as it is shown in (STEP 6)

gcc -Wl,-O1 -Wl,--as-needed -Wl,-z,noexecstack -o /tmp/ffconf.7IhNLjmP/test /tmp/ffconf.7IhNLjmP/test.o -lm -ldl -llzma -lz -pthread -pthread
use_pkg_config libmfx libmfx mfx/mfxvideo.h MFXInit
check_pkg_config libmfx libmfx mfx/mfxvideo.h MFXInit
pkg-config --exists --print-errors libmfx
check_func_headers mfx/mfxvideo.h MFXInit -I/opt/intel/mediasdk/include -I/usr/include/libdrm -L/opt/intel/mediasdk/lib/lin_x64 -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm
check_ld cc -I/opt/intel/mediasdk/include -I/usr/include/libdrm -L/opt/intel/mediasdk/lib/lin_x64 -lmfx -lva -lstdc++ -ldl -lva-drm -ldrm
check_cc -I/opt/intel/mediasdk/include -I/usr/include/libdrm -L/opt/intel/mediasdk/lib/lin_x64
BEGIN /tmp/ffconf.7IhNLjmP/test.c
    1   #include <mfx/mfxvideo.h>
    2   #include <stdint.h>
    3   long check_MFXInit(void) { return (long) MFXInit; }
    4   int main(void) { int ret = 0;
    5    ret |= ((intptr_t)check_MFXInit) & 0xFFFF;
    6   return ret; }
END /tmp/ffconf.7IhNLjmP/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -O2 -march=native -msse3 -fomit-frame-pointer -pipe -std=c11 -fomit-frame-pointer -pthread -I/opt/intel/mediasdk/include -I/usr/include/libdrm -L/opt/intel/mediasdk/lib/lin_x64 -c -o /tmp/ffconf.7IhNLjmP/test.o /tmp/ffconf.7IhNLjmP/test.c
/tmp/ffconf.7IhNLjmP/test.c:1:26: fatal error: mfx/mfxvideo.h: No such file or directory
 #include <mfx/mfxvideo.h>
                          ^
compilation terminated.
require libmfx mfx/mfxvideo.h MFXInit -llibmfx
check_lib libmfx mfx/mfxvideo.h MFXInit -llibmfx
check_func_headers mfx/mfxvideo.h MFXInit -llibmfx
check_ld cc -llibmfx
check_cc
BEGIN /tmp/ffconf.7IhNLjmP/test.c
    1   #include <mfx/mfxvideo.h>
    2   #include <stdint.h>
    3   long check_MFXInit(void) { return (long) MFXInit; }
    4   int main(void) { int ret = 0;
    5    ret |= ((intptr_t)check_MFXInit) & 0xFFFF;
    6   return ret; }
END /tmp/ffconf.7IhNLjmP/test.c
gcc -D_ISOC99_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_POSIX_C_SOURCE=200112 -D_XOPEN_SOURCE=600 -O2 -march=native -msse3 -fomit-frame-pointer -pipe -std=c11 -fomit-frame-pointer -pthread -c -o /tmp/ffconf.7IhNLjmP/test.o /tmp/ffconf.7IhNLjmP/test.c
/tmp/ffconf.7IhNLjmP/test.c:1:26: fatal error: mfx/mfxvideo.h: No such file or directory
 #include <mfx/mfxvideo.h>
                          ^
compilation terminated.
ERROR: libmfx not found

bacula – Device not in SD Device resources or no matching Media Type

If you happen to have such error in your bacula backup server:

20-Jun 00:19 bkp-srv-dir JobId 23741: No prior Full backup Job record found.
20-Jun 00:19 bkp-srv-dir JobId 23741: No prior or suitable Full backup found in catalog. Doing FULL backup.
20-Jun 00:19 bkp-srv-dir JobId 23741: Start Backup JobId 23741, Job=srv1-img.2018-06-20_00.19.09_56
20-Jun 00:19 bkp-srv-sd JobId 23741: Fatal error: Device reservation failed for JobId=23741: 
20-Jun 00:19 bkp-srv-dir JobId 23741: Fatal error: 
     Storage daemon didn't accept Device "srv1-img" because:
     3924 Device "srv1-img" not in SD Device resources or no matching Media Type.
20-Jun 00:19 bkp-srv-dir JobId 23741: Error: Bacula bkp-srv-dir 7.0.5 (28Jul14):
  Build OS:               x86_64-pc-linux-gnu ubuntu 16.04
  JobId:                  23741
  Job:                    srv1-img.2018-06-20_00.19.09_56
  Backup Level:           Full (upgraded from Incremental)
  Client:                 "srv1-img" 7.4.0 (16Jan16) x86_64-pc-linux-gnu,ubuntu,12.04
  FileSet:                "srv1-img" 2018-04-13 23:05:00
  Pool:                   "srv1-img-full" (From Job FullPool override)
  Catalog:                "DefaultCatalog" (From Client resource)
  Storage:                "srv1-img" (From Job resource)
  Scheduled time:         20-Jun-2018 00:19:06
  Start time:             20-Jun-2018 00:19:11
  End time:               20-Jun-2018 00:19:11
  Elapsed time:           0 secs
  Priority:               10
  FD Files Written:       0
  SD Files Written:       0
  FD Bytes Written:       0 (0 B)
  SD Bytes Written:       0 (0 B)
  Rate:                   0.0 KB/s
  Software Compression:   None
  VSS:                    no
  Encryption:             no
  Accurate:               no
  Volume name(s):         
  Volume Session Id:      3105
  Volume Session Time:    1521814321
  Last Volume Bytes:      0 (0 B)
  Non-fatal FD errors:    1
  SD Errors:              0
  FD termination status:  
  SD termination status:  
  Termination:            *** Backup Error ***

First thing to check is the status of Storage Devices you have with bconsole:

bkp-srv bacula # bconsole 
Connecting to Director localhost:9101
1000 OK: 1 bkp-srv-dir Version: 7.0.5 (28 July 2014)
Enter a period to cancel a command.
*status storage
Automatically selected Storage: bkp-srv
Connecting to Storage daemon bkp-srv at 78.140.166.26:9103

bkp-srv-sd Version: 7.0.5 (28 July 2014) x86_64-pc-linux-gnu ubuntu 16.04
Daemon started 20-Jun-18 00:43. Jobs: run=1, running=0.
 Heap: heap=135,168 smbytes=302,033 max_bytes=478,209 bufs=243 max_bufs=262
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name 
===================================================================
 23736  Incr          3    383.9 K  OK       19-Jun-18 14:05 srv1-dns
 23737  Incr          3    859.9 K  OK       19-Jun-18 14:05 srv2-dns
 23738  Incr        485    301.8 M  OK       19-Jun-18 14:05 srv3-dns
 23739  Incr         12    91.44 M  OK       19-Jun-18 14:05 srv4-dns
 23740  Full          1    1.358 G  OK       19-Jun-18 14:14 BackupCatalog
 23741  Full          0         0   Error    20-Jun-18 14:19 srv1-img
====

Device status:

Device "localstorage" (/mnt/storage/backups/localstorage) is not open.
==

Device "srv1-dns" (/mnt/storage/backups/srv1-dns) is not open.
==

Device "srv2-dns" (/mnt/storage/backups/srv2-dns) is not open.
==

Device "srv3-dns" (/mnt/storage/backups/srv3-dns) is not open.
==

Device "srv4-dns" (/mnt/storage/backups/srv4-dns) is not open.
==

Device "bkp-srv" (/mnt/storage/backups/bkp-srv) is not open.
==
====

Used Volume status:
====

====

As you can see there is no storage Device with name “srv1-img” as it expected from the error above.
You should check two files:

bacula-dir.conf

and

bacula-sd.conf

In file “/etc/bacula/bacula-dir.conf” you should have section like this:

Storage {
  Name = srv1-img
  Address = 10.10.10.10
  SDPort = 9103
  Password = mysecretpass
  Device = srv1-img
  Media Type = File
  Maximum Concurrent Jobs = 10
}

And in file “/etc/bacula/bacula-sd.conf”:

Device {
   Name = srv1-img
   Media Type = File
   Archive Device = /mnt/storage/backups/srv1-img
   LabelMedia = yes;
   Random Access = Yes;
   AutomaticMount = yes;
   RemovableMedia = no;
   AlwaysOpen = no;
 }

The important parts for this particular error (“3924 Device “srv1-img” not in SD Device resources or no matching Media Type.”) are highlighted:

  1. “Name” – the name of the storage
  2. “Media Type” – the type of the storage

You may also check the path of the storage – /mnt/storage/backups/srv1-img.

The two parameters must be the same! And if you verify these two configurations exist in the files and the above two parameters are the same and still get the error you MUST restart your SD (storage device) daemon, a “reload” command from the bconsole won’t work!

bkp-srv bacula # systemctl restart bacula-sd.service
bkp-srv bacula # systemctl status bacula-sd.service
* bacula-sd.service - LSB: Start Bacula Storage Daemon at boot time
   Loaded: loaded (/etc/init.d/bacula-sd; bad; vendor preset: enabled)
   Active: active (running) since Wed 2018-06-20 00:43:22 UTC; 4s ago
     Docs: man:systemd-sysv-generator(8)
  Process: 25249 ExecStop=/etc/init.d/bacula-sd stop (code=exited, status=0/SUCCESS)
  Process: 25259 ExecStart=/etc/init.d/bacula-sd start (code=exited, status=0/SUCCESS)
   CGroup: /system.slice/bacula-sd.service
           `-25269 /usr/sbin/bacula-sd -c /etc/bacula/bacula-sd.conf -u bacula -g tape

Jun 20 00:43:22 bkp-srv systemd[1]: Starting LSB: Start Bacula Storage Daemon at boot time...
Jun 20 00:43:22 bkp-srv bacula-sd[25259]:  * Starting Bacula Storage daemon... bacula-sd
Jun 20 00:43:22 bkp-srv bacula-sd[25259]:    ...done.
Jun 20 00:43:22 bkp-srv systemd[1]: Started LSB: Start Bacula Storage Daemon at boot time.

And verify it restarted successfully.

Then you the storage device named “srv1-img” should appear in bconsole status storage command:
First thing to check is the status of Storage Devices you have with bconsole:

bkp-srv bacula # bconsole 
Connecting to Director localhost:9101
1000 OK: 1 bkp-srv-dir Version: 7.0.5 (28 July 2014)
Enter a period to cancel a command.
*status storage
Automatically selected Storage: bkp-srv
Connecting to Storage daemon bkp-srv at 78.140.166.26:9103

bkp-srv-sd Version: 7.0.5 (28 July 2014) x86_64-pc-linux-gnu ubuntu 16.04
Daemon started 20-Jun-18 00:43. Jobs: run=1, running=0.
 Heap: heap=135,168 smbytes=302,033 max_bytes=478,209 bufs=243 max_bufs=262
 Sizes: boffset_t=8 size_t=8 int32_t=4 int64_t=8 mode=0,0

Running Jobs:
No Jobs running.
====

Jobs waiting to reserve a drive:
====

Terminated Jobs:
 JobId  Level    Files      Bytes   Status   Finished        Name 
===================================================================
 23736  Incr          3    383.9 K  OK       19-Jun-18 14:05 srv1-dns
 23737  Incr          3    859.9 K  OK       19-Jun-18 14:05 srv2-dns
 23738  Incr        485    301.8 M  OK       19-Jun-18 14:05 srv3-dns
 23739  Incr         12    91.44 M  OK       19-Jun-18 14:05 srv4-dns
 23740  Full          1    1.358 G  OK       19-Jun-18 14:14 BackupCatalog
 23741  Full          0         0   Error    20-Jun-18 14:19 srv1-img
====

Device status:

Device "localstorage" (/mnt/storage/backups/localstorage) is not open.
==

Device "srv1-dns" (/mnt/storage/backups/srv1-dns) is not open.
==

Device "srv2-dns" (/mnt/storage/backups/srv2-dns) is not open.
==

Device "srv3-dns" (/mnt/storage/backups/srv3-dns) is not open.
==

Device "srv4-dns" (/mnt/storage/backups/srv4-dns) is not open.
==

Device "bkp-srv" (/mnt/storage/backups/bkp-srv) is not open.
==

Device "srv1-img" (/mnt/storage/backups/srv1-img) is not open.
==
====

Used Volume status:
====

====

Extras – rerun the job and verify the backup was executed.

bkp-srv bacula # bconsole 
Connecting to Director localhost:9101
1000 OK: 1 bkp-srv-dir Version: 7.0.5 (28 July 2014)
Enter a period to cancel a command.
*run
Automatically selected Catalog: DefaultCatalog
Using Catalog "DefaultCatalog"
A job name must be specified.
The defined Job resources are:
     1: BackupCatalog
     2: srv1-dns
     3: srv2-dns
     4: srv3-dns
     5: srv4-dns
     6: srv1-img
Select Job resource (1-33): 6
Run Backup job
JobName:  srv1-img
Level:    Incremental
Client:   srv1-img
FileSet:  srv1-img
Pool:     Default (From Job resource)
Storage:  srv1-img (From Job resource)
When:     2018-06-20 00:43:59
Priority: 10
OK to run? (yes/mod/no): yes
Job queued. JobId=23742
You have messages.
*messages 
20-Jun 00:44 bkp-srv-dir JobId 23742: No prior Full backup Job record found.
20-Jun 00:44 bkp-srv-dir JobId 23742: No prior or suitable Full backup found in catalog. Doing FULL backup.
20-Jun 00:44 bkp-srv-dir JobId 23742: Start Backup JobId 23742, Job=srv1-img.2018-06-20_00.44.01_00
20-Jun 00:44 bkp-srv-dir JobId 23742: Created new Volume="srv1-img-full0394", Pool="srv1-img-full", MediaType="File" in catalog.
20-Jun 00:44 bkp-srv-dir JobId 23742: Using Device "srv1-img" to write.
20-Jun 00:44 bkp-srv-sd JobId 23742: Labeled new Volume "srv1-img-full0394" on file device "srv1-img" (/mnt/storage/backups/srv1-img).
20-Jun 00:44 bkp-srv-sd JobId 23742: Wrote label to prelabeled Volume "srv1-img-full0394" on file device "srv1-img" (/mnt/storage/backups/srv1-img)
*messages
20-Jun 00:44 bkp-srv-dir JobId 23742: Volume used once. Marking Volume "srv1-img-full0394" as Used.
*messages
You have no messages.

sysbench – FATAL: Too large position discovered in request

Here is a quick fix, which could take you a long time solving it even with Internet, because not so much information on the topic!
Let’s you want to run sysbench to check the IO of an SSD or NVME or your old hard drive? You run something like:

sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench --test=fileio --file-total-size=4G --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup

Total of 4G files split in 128000 files and each file should be 32K seems OK at first, but you got:

FATAL: Too large position discovered in request

And the solution is simple enough:

file-total-size = file-num * file-block-size

And put the file-total-size in the units you used for file-block-size to be sure there are no rounding!
To put in simple words:

the size of file data should evenly divide by the number of files

So the above will transform to:

ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
ssysbench --test=fileio --file-total-size=4096000K --file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 --max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup

Here are the computes:

–file-total-size=4096000K = –file-num=128000 * –file-block-size=32K

Simple equation could save you a lot of time!

* Good run – no errors!

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

128000 files, 32Kb each, 4000Mb total
Creating files for the test...
srv@local:/disks/1/test# echo 3 > /proc/sys/vm/drop_caches
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 100

Extra file open flags: 16384
128000 files, 32Kb each
3.9062Gb total file size
Block size 32Kb
Number of random requests for random IO: 0
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Threads started!
Time limit exceeded, exiting...
(last message repeated 99 times)
Done.

Operations performed:  4605591 Read, 0 Write, 0 Other = 4605591 Total
Read 140.55Gb  Written 0b  Total transferred 140.55Gb  (479.74Mb/sec)
15351.63 Requests/sec executed

Test execution summary:
    total time:                          300.0067s
    total number of events:              4605591
    total time taken by event execution: 29893.5378
    per-request statistics:
         min:                                  0.07ms
         avg:                                  6.49ms
         max:                                 40.43ms
         approx.  95 percentile:               7.06ms

Threads fairness:
    events (avg/stddev):           46055.9100/51.84
    execution time (avg/stddev):   298.9354/0.00


sysbench 0.4.12:  multi-threaded system evaluation benchmark

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096000K \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
Removing test files...

* Bad run – with the error: FATAL: Too large position discovered in request

srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd prepare
sysbench 0.4.12:  multi-threaded system evaluation benchmark

128000 files, 32Kb each, 4096M total
Creating files for the test...
srv@local:/disks/1/test# echo 3 > /proc/sys/vm/drop_caches
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd run
sysbench 0.4.12:  multi-threaded system evaluation benchmark

Running the test with following options:
Number of threads: 100

Extra file open flags: 16384
128000 files, 32.768Kb each
3.9999Gb total file size
Block size 32Kb
Number of random requests for random IO: 200000
Read/Write ratio for combined random IO test: 1.50
Periodic FSYNC enabled, calling fsync() each 100 requests.
Calling fsync() at the end of test, Enabled.
Using synchronous I/O mode
Doing random read test
Threads started!
FATAL: Too large position discovered in request!
(last message repeated 30 times)
FATAL: Failed to read file! file: 80714 pos: 2 errno = 22 ()
FATAL: Too large position discovered in request!
(last message repeated 67 times)
Done.

Operations performed:  1 Read, 0 Write, 0 Other = 1 Total
Read 32Kb  Written 0b  Total transferred 32Kb  (114.71Kb/sec)
    3.58 Requests/sec executed

Test execution summary:
    total time:                          0.2790s
    total number of events:              1
    total time taken by event execution: 0.0038
    per-request statistics:
         min:                                  3.79ms
         avg:                                  3.79ms
         max:                                  3.79ms
         approx.  95 percentile:         10000000.00ms

Threads fairness:
    events (avg/stddev):           0.0100/0.10
    execution time (avg/stddev):   0.0000/0.00
srv@local:/disks/1/test# sysbench --test=fileio --file-total-size=4096M \
--file-block-size=32K --file-num=128000 --num-threads=100 --max-requests=0 \
--max-time=300 --file-extra-flags=direct --file-test-mode=rndrd cleanup
Removing test files...