System in mechanical but not thermal equilibrium Let's say there are two systems which can interact by a moving wall but cannot exchange heat. Then the system will be in mechanical, but not necessarily in thermal equilibrium.
The maximality of entropy in mechanical equilibrium requires only the ratio p/T to be equal. So there is a possible equilibrium state where one system has double pressure and double temperature...
Where is my mistake?
 A: This is a classic conundrum and it is called the "problem of the adiabatic piston". You can find it discussed in books on thermodynamics by Landau & Lifhsitz and by Callen. Another very thorough analysis is by Gruber "Thermodynamics of systems with internal adiabatic constraints: time evolution of the adiabatic piston". (You can find Gruber's article here free http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.55.995 )
A: 
The maximality of entropy in mechanical equilibrium requires only the ratio p/T to be equal. So there is a possible equilibrium state where one system has double pressure and double temperature... Where is my mistake?

If the systems are allowed to change their volumes, they are allowed to change their internal energies as well. When the wall moves, transfer of energy from one system to another occurs in the form of work. The maximum entropy principle then implies that for equilibrium, both temperature $T$ and the ratio $P/T$ have to be the same for both systems, hence $P$ has to be the same.
