I'm written in the past about how it isn't possible to hibernate a Linux laptop (in my case, openSUSE 10.2) when VMware Server is running. I decided it was time to try again and see what can be done, since laptops are a lot more convenient if you can hibernate them rather than doing a full power-down and power-up every time.
One thing that has changed is that VMware Server now seems to do a better job of properly shutting down your virtual machine before it shuts down, rather than just performing a hard power-off. Either that, or it's simply that I have it better set up now. Anyway, each virtual machine can be set to shut down or (hard) power-off when VMware Server is shut down, and you should definitely choose the "shut down" option, for the sake of your file system. That said, I prefer to manually shut down or hibernate my virtual machines, and that's probably the best option (although you could do some automation using the "vmrun" command if you want).
The last time I tried to find a way to automate the shutting down of VMware Server when I hibernate my laptop, I couldn't find how to do it. Back then, I was looking for somewhere in the GNOME GUI to add a hook to a pre-hibernation script. It turns out that in openSUSE 10.2, the place to look is the "pm-utils" package (other varieties of Linux may use similar but different packages). With "pm-utils", you can add a hook hibernate/thaw script in the "/etc/pm/hooks" directory. What follows is the script that I added; the scripts are called in alphabetical order; there are already scripts starting with "00" and "01", so my script is called "02vmware.local":
#!/bin/bash # [ABC] local power management script for VMware Server. # VMware can't be hibernated, it needs to be stopped and restarted. RETVAL=0 case "$1" in hibernate|suspend) /etc/init.d/vmware stop ;; thaw|resume) /etc/init.d/vmware start ;; *) ;; esac exit $RETVAL
You can see that it just calls the standard VMware Server start/stop command from "/etc/init.d". The events that the script can receive are
- hibernate - suspend to disk;
- suspend - suspend to RAM;
- resume - resume from RAM;
- thaw - restore from disk.
This works, with a couple of caveats. My touchpad is disabled when my HP Pavilion dv2000 (dv2058ea) laptop resumes, but fortunately there is an enable/disable button just above the touchpad, so I can just press that. Also, the wireless network doesn't always resume correctly, which means having to run
sudo /etc/init.d/network restart
which isn't such a problem. This is what works for me, anyway.