Using vim-cmd to remedy a bsod

Here’s a great tutorial for vim-cmd if you haven’t had experience with it before by my friend, Steve Jinwww.doublecloud.org/2013/11/vmware-esxi-vim-cmd-command-a-quick-tutorial/

This is a real-world situation I got myself into when I tried connecting to my client VM and found a BSOD that looked like this:

It’s pretty obvious that the reason for the crash is the USB stick that’s plugged in from the usbuhci.sys line in the blue screen. Since I tunnel into my client VM via SSH and VNC, the easiest way for me to shutdown my VM and remedy this issue is through vim-cmd. This only works if you have SSH allowed onto your ESXi host or if you are connecting to the host with the VMware CLI or vMA or whatever they’re calling it these days. I have the former.

The first thing I do after logging into the ESXi host as root is run:

vim-cmd vmsvc/getallvms

I need to know which one of my VMs is the one to manage. I get this:

Vmid Name File Guest OS Version Annotation
1 windows7 [BIG_DISK] windows7/windows7.vmx windows7_64Guest vmx-07
3 thimble [BIG_DISK] thimble/thimble.vmx ubuntu64Guest vmx-08
4 chunli [Datastore 2] chunli2/chunli2.vmx ubuntu64Guest vmx-08
5 zangief [Datastore 2] zangief2/zangief2.vmx ubuntu64Guest vmx-11

With this information, I know that it’s VM 1, so I power it off by running:

vim-cmd vmsvc/power.off 1

Thinking the USB issue might be a fluke, I try to power the VM back on to see if it will boot.

vim-cmd vmsvc/power.on 1

I see that it starts booting, but as the resolution changes on the VM, my VNC viewer freezes. Since I normally don’t know exactly when it freezes, I didn’t know when I got the BSOD again.

Until I decided to at look at the vmware.log file. This is what I saw there:

2017-10-18T22:27:05.519Z| svga| I125: SVGA disabling SVGA
2017-10-18T22:27:05.545Z| svga| W115: WinBSOD: (20) 'Technical information: '
2017-10-18T22:27:05.545Z| svga| W115:
2017-10-18T22:27:05.546Z| svga| W115: WinBSOD: (22) '*** STOP: 0x000000D1 (0xFFFFF88000BF2000,0x0000000000000002,0x0000000000000001,0'
2017-10-18T22:27:05.546Z| svga| W115:
2017-10-18T22:27:05.546Z| svga| W115: WinBSOD: (23) 'xFFFFF88004206E49) '
2017-10-18T22:27:05.546Z| svga| W115:
2017-10-18T22:27:05.557Z| svga| W115: WinBSOD: (26) '*** usbuhci.sys - Address FFFFF88004206E49 base at FFFFF88004200000, DateStamp'
2017-10-18T22:27:05.557Z| svga| W115:
2017-10-18T22:27:05.557Z| svga| W115: WinBSOD: (27) ' 57b37a29 '
2017-10-18T22:27:05.557Z| svga| W115:
2017-10-18T22:27:05.557Z| svga| W115: WinBSOD: (30) 'Collecting data for crash dump ... '
2017-10-18T22:27:05.557Z| svga| W115:
2017-10-18T22:27:05.573Z| svga| W115: WinBSOD: (31) 'Initializing disk for crash dump ... '
2017-10-18T22:27:05.573Z| svga| W115:
2017-10-18T22:27:07.547Z| mks| W115: Guest operating system crash detected.

Okay, so I see that my hunch is correct. I guess it’s time I remove the USB device from the VM. So I power off the VM again and open up the vmx file and just start removing all instances of USB.

These are the lines I removed. Don’t worry about breaking anything. The hypervisor will put them back if you need them later. Back up your vmx file before doing it though just in case.

usb.pciSlotNumber = "34"
usb.present = "TRUE"
usb:1.speed = "2"
usb:1.present = "TRUE"
usb:1.deviceType = "hub"
usb:1.port = "1"
usb:1.parent = "-1"
usb.autoConnect.device0 = "path:1/1 autoclean:1"
usb:0.present = "TRUE"
usb:0.deviceType = "mouse"
usb:0.port = "0"
usb:0.parent = "-1"

After you’ve saved your changes, you’ll need to reload the changes so that ESXi will reread the .vmx file to remove the USB device. You can do this by running this command:

vim-cmd vmsvc/reload 1

Now you’re ready to power on the VM.

vim-cmd vmsvc/power.on 1

The VM powers up and I’m back in business. I just had to figure out the USB issue later. Turned out that I just needed to reconnect the device and reformat it. I haven’t seen the issue come up again.

 

What’s USB device VID_07aa&PID_0011 ? Any Windows XP driver available?

This happens to be my old ass USB wireless lan adapter – only 11Mbps. Good enough for an old system and just to get online though it doesn’t have a whole lot of range. The reason I’m posting is because I did a search and couldn’t find the driver very quickly. It’s available at www.driverguide.com, but I’m so tired of having to click through their ads to get to my final driver download. The driver is available for downloading here.

How to get USB devices to work in Linux or the ESX console

Here is how I’ve gotten a couple of cdroms / usb memory sticks / hard drives to work.

1) modprobe usb-ohci
Or
modprobe usb-uhci
(one of them should work, one may fail)

2) modprobe usb-storage

3) tail /var/log/messages
Or
dmesg
and you should see something like this:
Feb 8 14:50:56 supp15 kernel: Initializing USB Mass Storage driver…
Feb 8 14:50:56 supp15 kernel: usb.c: registered new driver usb-storage
Feb 8 14:50:56 supp15 kernel: scsi1 : SCSI emulation for USB Mass Storage devices
Feb 8 14:50:56 supp15 kernel: Vendor: SanDisk Model: Cruzer Mini Rev: 0.4
Feb 8 14:50:56 supp15 kernel: Type: Direct-Access ANSI SCSI revision: 02
Feb 8 14:50:56 supp15 kernel: VMWARE SCSI Id: Supported VPD pages for sdb : 0x1f 0x0
Feb 8 14:50:56 supp15 kernel: VMWARE SCSI Id: Could not get disk id for sdb
Feb 8 14:50:56 supp15 kernel: :VMWARE: Unique Device attached as scsi disk sdb at scsi1, channel 0, id 0, lun 0
Feb 8 14:50:56 supp15 kernel: Attached scsi removable disk sdb at scsi1, channel 0, id 0, lun 0
Feb 8 14:50:56 supp15 kernel: scsi_register_host starting finish
Feb 8 14:50:56 supp15 kernel: SCSI device sdb: 2001888 512-byte hdwr sectors (976 MB)
Feb 8 14:50:56 supp15 kernel: sdb: Write Protect is off
Feb 8 14:50:56 supp15 kernel: sdb: sdb1 Feb 8 14:50:56 supp15 kernel: scsi_register_host done with finish
Feb 8 14:50:56 supp15 kernel: USB Mass Storage support registered.

4) Now that we know that it’s sdb1,
Create the mountpoint directory:
mkdir /mnt/usb
Mount the device:
mount /dev/sdb1 /mnt/usb

That’s it. Your files should be in /mnt/usb. To check, just run ls /mnt/usb

In a case that you don’t have /dev/sdb1 there, which is what happened to me once with a Dell CDrom, I had to mknod the device.
After plugging the usb cdrom into the machine, /var/log/messages showed:

date hostname kernel: sr0: scsi3-mmc drive: 10x/10x cd/rw …..

Unfortunately, if you type: “mount /dev/sr0 /mnt/mountpoint”, it will say:
“mount: special device /dev/sr0 does not exist” and that doesn’t do us any good. So what I did after that was:
cd /dev
mknod sr0 b 11 0

With that, /dev/sr0 existed and hence I was able to run:
mount /dev/sr0 /mnt/mountpoint

or, I could run:
ln -s /dev/sr0 /dev/cdrom
and run:
mount /dev/cdrom /mnt/mountpoint

That’s it!