Console commands to hibernate and standby on CentOS

It’s great that Linux nowadays supports all the power management features available on computers. But it’s odd that beside the buttons to trigger standby/hibernate – which are only available in a graphical interface – there are no simple console commands to put the computer to sleep or into hibernation.

Standby and hibernation are very useful on (personal) servers in case of long power failures (of course, while using an UPS). This way the server can put itself to sleep – while retaining all running stuff (especially running virtual machines, which take ages to boot and close) ready to be restored when the power returns.

So the two (not so simple) console commands are:

Hibernate
echo disk >/sys/power/state

Standby/Suspend to memory (S3 or S1, depending on BIOS settings)
echo mem >/sys/power/state

The best way to prepare you system for future usage of these commands is to create two script files, namely standby and hibernate (with the appropriate content) and chmod them 755.

3 Comments

Leave a Reply