Archive for the ‘Documentation’ Category

More ESXi 4.1 Tech Mode commands

Today, I found myself in the awkward position of having to figure out how to bring my newly upgraded ( ESXi 4.1 to 4.1 Update 1 ) host out of Maintenance Mode using Tech Mode commands, because I did not realize that I had to upgrade the vSphere client. It was even worse, because I thought I could download the new client from the ESXi server itself (http://esxi-hostnam). Instead, the ESXi host just provides a link to the VMware site. Ooopps. My LAN DNS servers are running on the same physical host, due to lack of funding. So, this little adventure forced me to discover a few more commands to manage an ESXi host from the Tech mode command line.

First off is a command that will tell you more information than you possibly ever want to know about your ESXi host. This command will spew out hundreds of lines of information about the host.

vim-cmd hostsvc/hostsummary

I highly recommend using grep to find the information you need. For instance, I used the following command to determine whether the host was in Maintenance Mode:

vim-cmd hostsvc/hostsummary | grep -i main
inMaintenanceMode = false,

To put the host into Maintenance Mode:

vim-cmd hostsvc/maintenance_mode_enter

To take the host out of Maintenance Mode:

vim-cmd hostsvc/maintenance_mode_exit

I have written about this command before, but it seems appropriate to list it here. To display all guests:

vim-cmd vmsvc/getallvms

You can also use the following command to get a “summary” of a guest:

# vim-cmd vmsvc/get.summary 160

Again, I recommend using grep, because you get a lot of output.

# vim-cmd vmsvc/get.summary 160 | grep -i name
guestFullName = ,
hostName = ,
name = “White2”,
vmPathName = “[1TBVolume] White2/White2.vmx”,
guestFullName = “Microsoft Windows Vista (32-bit)”,

Or:

# vim-cmd vmsvc/get.summary 272 | grep -i state
runtimeState = (vim.vm.DeviceRuntimeInfo.VirtualEthernetCardRuntimeState) {
connectionState = “connected”,
powerState = “poweredOff”,
faultToleranceState = “notConfigured”,
recordReplayState = “inactive”,

getallvms will display the Vmids of all the guests. You will need these to power on your guests from Tech Mode. The following command will display whether a guest is power on or not:

# vim-cmd vmsvc/power.getstate 160
Retrieved runtime info
Powered off

Finally, to power on a guest using the Vmid from getallvms command:

# vim-cmd vmsvc/power.on 272
Powering on VM:

Furthermore, here is how you can add a new configuration from Tech Mode:

vim-cmd solo/registervm pathtovmxconfigurationfile

To remove a configuration:

vim-cmd vmsvc/unregister Vmid

To check the version:

vmware -v

Update to ESXi 4.1 U1 from ESXi 4.1.

Download software from VMware (The zip update file.).

Put update zip file on ESX server. I created an update directory in my datastore1 directory. I use scp from the ESXi host with Tech Support Mode enabled.

Put the host in Maintenance Mode via the vSphere Client (right mouse click on the host).

esxupdate –bundle zipfile update

Reboot

Update your vSphere client, if needed by browsing to your ESXi server name (http://esxi-host).

Take out of maintenance mode via vSphere Client.

Boot guests.

Repairing disk errors in CentOS.

I started getting the following errors every night when the /var partition backed up on one of my CentOS 5 servers.

DUMP: read error from /dev/sda5: Input/output error: [block 4125240, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [block 4125252, ext2blk 0]: count=515656
DUMP: read error from /dev/sda5: Input/output error: [sector 4125240, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125252, ext2blk 0]: count=515656
DUMP: read error from /dev/sda5: Input/output error: [sector 4125241, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125253, ext2blk 0]: count=515656
DUMP: read error from /dev/sda5: Input/output error: [sector 4125242, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125254, ext2blk 0]: count=515656
DUMP: read error from /dev/sda5: Input/output error: [sector 4125243, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125255, ext2blk 0]: count=515656
DUMP: read error from /dev/sda5: Input/output error: [sector 4125244, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125245, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125246, ext2blk 0]: count=515655
DUMP: read error from /dev/sda5: Input/output error: [sector 4125247, ext2blk 0]: count=515655

Also, I found the following kinds of message in the messages file:

May 7 02:34:37 white1 kernel: ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
May 7 02:34:37 white1 kernel: ata1.00: BMDMA stat 0x24
May 7 02:34:37 white1 kernel: ata1.00: cmd c8/00:50:ea:9f:03/00:00:00:00:00/e3 tag 0 dma 40960 in
May 7 02:34:37 white1 kernel: res 51/40:00:08:a0:03/00:00:00:00:00/03 Emask 0x9 (media error)
May 7 02:34:37 white1 kernel: ata1.00: status: { DRDY ERR }
May 7 02:34:37 white1 kernel: ata1.00: error: { UNC }
May 7 02:34:37 white1 kernel: ata1.00: configured for UDMA/133
May 7 02:34:37 white1 kernel: ata1: EH complete
May 7 02:34:40 white1 kernel: ata1.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
May 7 02:34:40 white1 kernel: ata1.00: BMDMA stat 0x24
May 7 02:34:40 white1 kernel: ata1.00: cmd c8/00:50:ea:9f:03/00:00:00:00:00/e3 tag 0 dma 40960 in
May 7 02:34:40 white1 kernel: res 51/40:00:08:a0:03/00:00:00:00:00/03 Emask 0x9 (media error)
May 7 02:34:40 white1 kernel: ata1.00: status: { DRDY ERR }

From single user mode with /var dismounted, I ran the following:

# e2fsck -c /dev/sda5

I wish I had kept the output, but I know I accepted the defaults ( “Y” ) for all the prompts or which their were a couple. After it completed, I ran dump that completed without error. We will see how it goes from here. According to the man page, any bad blocks found using this command are added to the bad block inode so that they are used by any files or directories.

CentOS/RHEL/Fedora/Ubuntu: scan for SCSI hardware changes.

To scan all SCSI buses for hardware changes enter the following:

echo “- – -” >/sys/class/scsi_host/host0/scan # “dash space dash space dash space”

I did this on CentOS 5 to discover a new disk I added, but did not want to reboot the server.

Note: You might have to use one of the other host directories. In Ubuntu, I had to use host2 before the drive would show up.

To capture DHCP vendor-class-identifier in linux.

On a linux DHCP server, you can add the following linke to dhcpd.conf file to display the vendor-class-identifier of DHCP clients:

set vendor-string = option vendor-class-identifier;

I added this towards the top of my configuration in both version 3 and version 4 DHCP server installations. I did notice that not all clients report the information back. For instance, some Wyse clients. You find the information in the dhcpd.leases database file on the server.

MSA1000 Brocade SAN Switch commands

I have fumbled around long enough trying to remember these commands at various points in my career, so I decided to write down a few of the commands needed to create a SAN zone and enable a config.

alicreate “aliasname “, “WWID

zonecreate “zonename”, “aliasname; aliasname; etc”

cfgcreate “configname“, “zonename1; zonename2; etc“)

cfgsave “cfgname

cfgenable “cfgname

Commands to show information configured above:

alishow
zoneshow
cfgshow
switchshow

Windows 2003/2008 shutdown command

Because I never remember the syntax for 2003 and later:

Reboot:
shutdown /r /c “comment” /t time

Shutdown:
shutdown /s /c “comment” /t time

Add a /m computername to reboot/shutdown a remote server.

MacOS flush DNS cache

While we are on the subject of flushing DNS cache, here is how you do it in MacOS.

dscacheutil -flushcache

Windows flush DNS cache

I have run into this issue a few times, and decided that I needed to document this since I keep forgetting the procedure. I have had a situation where I have checked and double check my DNS modifications and no matter what I do the changes do not seem to have taken effect on some Windows clients. Well, it turns, as it usually does, that it just takes a simple command to resolve the name properly:

ipconfig /flushdns

I know this works on Windows 7, Windows 2003, and Windows 2008.

Another useful option if registerdns. If you change the IP address of a server and need it to update in your Windows DNS use:

ipconfig /registerdns

If pinging from a Windows client, you may need to flush your client DNS cache to recognize the address change.

Enabling Network Access Permission via command line.

I needed an easy way to “Allow access” under “Network Access Permission” in the “Dial-in” tab of the “Active Directory Users and Computers” console for several users in a Windows 2003/2008 ADS environment.

At first, I approached this task from a scripting angle. I developed a VBscript that would worked in my test environments, but not in production. I am still not sure why, but I have not had to time to look into it further. I suspect it has to do with some policy restrictions or permissions. I know the script was working, because I could see that the “msNAPllowDialin” ADS attribute was being modified. However, when I opened up “Active Directory Users and Computers,” the change was not reflected. Also, I was still not able to use our VPN that requires the attribute be enabled.

Being short on time, I looked for a powershell command, or some other command line solution. It was then that I rediscovered the netsh command. I had used this command in the past, but did not document anything about it. I want to get something posted on it, because it is a tremendously powerful command and one that every seasoned Windows administrator should know about. In my case, this command helped solve my issue quickly. I used the following command syntax to choose “Allow access” on the “Network Access Permission” radio button:

netsh RAS set user name=username dialin=PERMIT

The netsh command has many options. Among them, I found that looked pretty interesting (netsh dump). It creates a script of your current settings. There is another option, netsh exec, that you can use to execute a netsh script like the the “netsh dump” creates. These could be incredible useful. There are several other options. You can find help and syntax for all the options by entering a “?” when you need more information. For example, “netsh ?” or “netsh set ?”, etc. You can add to question mark to any level to find more information. Very useful command. I wish I had written down what I used it for before.

Return top

INFORMATION