Here’s an interesting Linux tidbit that not many ESX admins realize.
reboot is not the same as init 6
In Linux, the init 6 command gracefully reboots the system running all the K* shutdown scripts first, before rebooting. The reboot command does a very quick reboot. It doesn’t execute any kill scripts, but just unmounts filesystems and restarts the system. The reboot command is more forceful.
So, should I use reboot or init 6? – neither! My advice is to use the shutdown command. shutdown will do a similar job to init 6, but it has more options and a better default action. Along with kicking off an init 6, the shutdown command will also notify all logged in users (logged in at a tty), notify all processes the system is going down and by default will pause for a set time before rebooting (giving you the chance to cancel the reboot if you realize that you made a mistake). Jolly civil.
How does this advice apply to VMware ESX servers you ask? Well I’m not a VMware kernel developer so to be honest I’m not the best person to ask (if you do know murky details, then please let us know in the comments). However I will say this; I will always use shutdown -r first and foremost. It’s just a better habit to get into.
Is there a difference on an ESX server? Yes, but as I said I’m entirely sure how it affects the VMkernel processes. The reason I definitely know – a couple of times I’ve had to use the reboot command to force an unresponsive ESX shutdown -r.
P.S. This also applies to init 0 / halt (i.e. use shutdown -h instead).
Update: Following Andrew’s comments below I’ve done a bit more digging. He’s correct that the default action of the reboot command has now changed to call the shutdown command. This upstream change (presumably because its a safer default action as I explained above) is now reflected in a lot of the current distributions, including the Service Console that comes with ESX 4.0. So if you want to force a reboot you have run reboot -f.
Here’s the section on ESX4 man page explaining the change:
Under older sysvinit releases , reboot and halt should never be called directly. From release 2.74 on halt and reboot invoke shutdown(8) if the system is not in runlevel 0 or 6. This means that if halt or reboot cannot find out the current runlevel (for example, when /var/run/utmp hasn’t been initial ized correctly) shutdown will be called, which might not be what you want. Use the -f flag if you want to do a hard halt or reboot.
Does it change my advice? No.
Firstly, ESX 3.x still uses the old style reboot command and doesn’t link to shutdown (as Greg points out the comments, this change was actually made much earlier on) . Secondly, if your anything like me you are logging into a mix of unix/linux style command lines on servers, SANs, etc; you don’t want to guess what their version of reboot does. Thirdly, I’d still argue that
shutdown -r +1 “*** reboot for RAM upgrade by Forbes ***”
is still a better habit to get into.
- It allows other users to finish what they are doing or ask you to postpone things.
- It let’s you cancel the shutdown if you’ve made a boob (remember that sinking feeling in your stomach the last time you realized you’d just shutdown the wrong server).
- It writes a message explaining why, so you can track the reboots.
Lastly, if you’ve read this far and survived or re-visited for the update, here is an extra tip for you. Try this at the command line:
last -x|grep -e shutdown -e reboot
- @nickmarshall9 I'll be at SFO this year, bit I'm running low on time to put things together. : 2 days ago
- @gurusimran Would like to but I need to think about what I'd submit as a design. : 2 days ago
- @coolsport00 @timantz @virtualizecr Thanks guys! (Shane, your study notes were great - vBeer coming your way at VMworld 2013) : 2 days ago
- Whoohooo! Just got my VCAP5-DCA score - 441. Very happy as I'm not so hands-on these days. Step 3 complete, onto step 4. : 2 days ago
- @theGuate Yes, that's no longer the case & is an error. When we realized we told the publishers to remove from reprints & add to errata. Thx : 2 days ago
- #KneeKnacker training run this morning http://t.co/EcDcACDohP : 1 week ago
- Off to sit my VCAP5-DCA. Fingers & toes crossed. : 2 weeks ago
- View 5.2 tip: Win 7 Optimization Guide advises setting Win Firewall service to disabled. This breaks Blast service (HTML5 access). : 3 weeks ago
- Check out this handy online IOPS calculator, very nicely done: wmarow.com/strcalc/strcal… : 3 weeks ago
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 vReference card – vCenter section
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 vReference card – VM section
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 vReference card – availability section
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 vReference card – networking section
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 Card
- VMware Certified Professional on vSphere 5 (VCP5) Study Guide | The Virtualization Guy on vSphere 5 vReference card – resources section
- My VCP5 upgrade experience on vSphere 5 Card
- Paul Kelly on VCAP5-DCD: small but important change to the exam format
- Cheat Sheet: vSphere 5 Reference Card on vSphere 5 Card
- Chris. on vSphere 5 Card