The maximum entropy principle states that at equilibrium entropy is maximized. However I found this principle paradoxical because in pure thermodynamics entropy is defined only for equilibrium states. How is it possible?
Edit: Some answers below suggest that entropy can be defined also for state out of equilibrium. This remove the contradiction, the equilibrium is just the state of maximum entropy.
However i'm not convinced that this is the the answer i was looking for. Consider, for example, the free expansion of a gas. Will the gas occupy the entire available volume? of course yes but let's prove it using the maximum entropy principle: because the energy is constant $dU=TdS-PdV=0$ from which $dS/dV=P/T>0$. Then the maximum entropy is reached when the volume is maximized.
Why is this different from defining entropy for a system out of equilibrium? Because when we write $dU=TdS-PdV$ we are writing differences between equilibrium states. $dS=S(V+dV,U)-S(V,U)$ is the difference between the entropy if the system is in equilibrium at volume $V+dV$ and the entropy if the system is in equilibrium at volume $V$. If we would define the entropy $S'$ for the system out of the equilibrium, then $dS'\neq dS$.
Attempt of an answer: I think that when a parameter (for example volume) can freely change we have to consider the system in equilibrium for every possible value of the parameter and then choose as the true physical equilibrium the value of the parameter in which entropy is maximized