This page looks best with JavaScript enabled

Find out which Jail a process belongs to in FreeBSD

 ·  🎃 kr0m

Using Jails as a virtualization system allows us to make more efficient use of system resources, but it can also cause problems if a process in one of the Jails consumes resources uncontrollably. In these cases, we must determine which Jail the conflicting process belongs to, either to debug the cause of the problem or to restart it.

The command itself is very simple, we just need to add the jid option to a traditional ps auwx, below we see its operation on a system with Jails using CBSD and using Iocage .


  • CBSD:

We check the available Jails:

bagheera # ~> cbsd jls

JNAME  JID  IP4_ADDR       HOST_HOSTNAME          PATH                    STATUS
jail1  17   192.168.69.X   jail1.alfaexploit.com  /usr/jails/jails/jail1  On        

As an example, we will identify the Cron process of the Jail with jid: 17 and of the parent server:

bagheera # ~> ps -o jid -auwx|grep cron

 17 root       51357   0.0  0.0    11348   2632  -  INsJ 12:51      0:00.00 /usr/sbin/cron -s
  0 root       94054   0.0  0.0    11392   2780  -  Is   07:00      0:00.04 /usr/sbin/cron -s

  • IOCAGE:

We check the available Jails:

MightyMax # ~> iocage list

+-----+----------+-------+--------------+--------------+  
| JID |   NAME   | STATE |   RELEASE    |     IP4      |  
+=====+==========+=======+==============+==============+  
| 1   | DrWho    | up    | 12.1-RELEASE | 192.168.69.X |  
+-----+----------+-------+--------------+--------------+  
| 5   | Mistery  | up    | 12.1-RELEASE | 192.168.69.X |  
+-----+----------+-------+--------------+--------------+  
| 4   | Potras   | up    | 12.1-RELEASE | 192.168.69.X |  
+-----+----------+-------+--------------+--------------+  
| 7   | rTorrent | up    | 12.1-RELEASE | 192.168.69.X |  
+-----+----------+-------+--------------+--------------+

We identify the Cron process of the Jails and the parent server:

MightyMax # ~> ps -o jid -auwx|grep cron

  4 root     31389   0.0  0.0   11352    740  -  SsJ  31Aug20      0:18.83 /usr/sbin/cron -J 15 -s  
  5 root     47216   0.0  0.0   11352    924  -  SsJ   9Sep20      0:30.68 /usr/sbin/cron -J 15 -s  
  0 root     59237   0.0  0.0   11404   1368  -  Ss   31Aug20      0:18.43 /usr/sbin/cron -s  
  7 root     75964   0.0  0.0   11248   1664  -  SsJ  Mon12        0:01.27 /usr/sbin/cron -J 15 -s  
  1 root     89066   0.0  0.0   11352    964  -  SsJ  31Aug20      0:19.11 /usr/sbin/cron -J 15 -s

NOTE: jid 0 indicates that the process belongs to the parent machine and not to a Jail.

If you liked the article, you can treat me to a RedBull here