# Limit/cap resources on jails



## Martin Garcia (Oct 29, 2018)

Hello, Im getting into jails
I want to move away some KVM vms, and transform it into jails.  My goal is to optimize (even more with jails) all resources, specially storage.
Currently Im running 2 vms with FreeBSD, vm1 has PHP7.1 and MariaDB and vm2 has PHP5.6 with MySQL. (vm1 should have more vCPUs but PHP5.6 uses more storage.

How can I limit resources for the jails, like qty of vCPUs, RAM and storage?
About storage Ive read that I can use md. But would not be efficient, since it would not increase or decrease info.

Thanks in advance for the information


----------



## Phishfry (Oct 30, 2018)

Essentially jails are sandboxes. They have no dedicated CPU or memory.
You can restrict the resources used by a jail.
https://www.freebsd.org/doc/handbook/security-resourcelimits.html


----------



## Phishfry (Oct 30, 2018)

With a jail you basically unpack base.tgz to a defined storage area. It does not boot. It uses the jail 'filesystem' as a dummy structure.

You might want to checkout bhyve(8).
https://www.freebsd.org/doc/handbook/virtualization-host-bhyve.html

Jails can run the applications you specified without problem if that is the route you prefer.


----------



## Phishfry (Oct 31, 2018)

It took me a day to refind this one:
https://wiki.freebsd.org/SummerOfCode2012/CPULimits

https://wiki.freebsd.org/Hierarchical_Resource_Limits


----------

