Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Usually, I just do a sudo /sbin/shutdown now when in my VM and wait for it to logout into the bash shell. Then after that I just go to Power > Power Off. Is this the right way to shutdown my CentOS VM?

share|improve this question
2  
If you see the message on the screen saying something like system has halted, then yes. –  user3463 Jan 16 '11 at 0:33
    
Wait... you go to Power > Power Off in the shell? –  Hello71 Feb 12 '11 at 21:55
    
No, after issuing the shutdown command via the shell, I wait for the system to halt, and then in the VM player GUI go to Power > Power Off –  stevebot Feb 12 '11 at 22:09

2 Answers 2

up vote 4 down vote accepted

Presuming VMware: if you have the vmware-tools installed in your VM, you should be able to issue the shutdown -h now command and it will power-off the VM for you. This works for me with C4 and C5 VMs, on Server-1 and -2, Workstation 6.x, and ESX/ESXi.

share|improve this answer
    
thanks! I haven't tried that before. –  stevebot Jan 16 '11 at 3:52
    
If you are impatient, you can force a few disk flushes and hit the deck: sync;sync;sync;halt –  Linker3000 Feb 12 '11 at 22:07
    
shutdown -h now works on many virtualisation platforms, not just vmware. Also in vmware you don't even need vmware-tools installed for the command (run on the guest) to power off the VM if the OS is recent and not too minimal like some router Linux distros. Usually hypervisors emulate a motherboard with ACPI features so shutdown requires ACPI enabled in the guest. I've noticed that if you do a minimal CentOS install, it does not enable this for you. –  BeowulfNode42 Apr 22 at 13:02
    
With CentOS you can ensure the ACPI daemon is installed with yum install acpid Then ensure the daemon starts at boot with chkconfig acpid on and start the service now with service acpid start –  BeowulfNode42 Apr 22 at 13:18

You're close; the proper command is:

sudo /sbin/shutdown **-h** now
  1. Assuming that the sudo package is installed; otherwise, use su or similar.
  2. Without the asterisks, of course.

This will shutdown then halt the computer.

share|improve this answer
    
ah, thanks that does help –  stevebot Jan 16 '11 at 3:51
    
unixhelp.ed.ac.uk/CGI/man-cgi?shutdown+8 shutdown manual page... also look at the -r method to restart your computer. These are basic linux commands and really have nothing 'special' to do with a VM –  g19fanatic Jan 16 '11 at 4:20
    
Yes, I can confirm this works on CentOS 5.6 (Final) running as a VM on Win7 with VirtualBox. –  crmpicco Apr 4 at 17:01

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.