We have studied thermodynamics of the Mg-B system with the modeling technique CALPHAD using a computerized optimization procedure. Temperature-composition, pressure-composition, and pressure-temperature phase diagrams under different conditions are obtained. The results provide helpful insights into appropriate processing conditions for thin films of the superconducting phase, MgB 2 , including the identification of the pressure/temperature region for adsorption-controlled growth. Due to the high volatility of Mg, MgB 2 is thermodynamically stable only under fairly high Mg overpressures for likely growth temperatures. This constraint places severe temperature constraints on deposition techniques employing high vacuum conditions.