# Why doesn't this violate the 2nd law of thermodynamics?

Consider an ideal gas in a cylindrical container in a gravitational field, with a piston on top pushing down by gravity. The piston has some locking mechanism that locks it in place if it is displaced upwards enough that the temperature of the gas is some $1>>\epsilon>0$. If we wait long enough, enough particles will line up due to their random motion and push the piston upwards. We can make the piston arbitrarily thin and arbitrarily heavy. Eventually it will lock in some final top position and some arbitrarily small portion of kinetic energy is left in the gas. Since we can make the volume change arbitrarily small, while momentum phase space goes to zero, the entropy must have decreased in this process, but that can't happen, so what is wrong with this reasoning?

• What do you mean by "the temperature of the gas is some $1>>\epsilon>0$"? – Karlo Jul 7 '16 at 6:18