Removing non-present devices from Windows 2008

I had a W2K8 vm where I was adding / removing NICs like they were going out of fashion. As a result by the end of it I had a mess of non-present devices.

So how do you fix that mess?

I found (or more accurately was advised) that I can start a command prompt and

SET DEVMGR_SHOW_NONPRESENT_DEVICES=1
devmgmt.msc

Click on the ‘view’ / ‘Show Hidden devices’

Hey presto, there the were.

Then it’s just a case of right-click on the devices you no longer want and select uninstall.

End result is nice and neat.

vCenter Server on your AD Domain Controller?

Ok, so it’s not the most clever thing you can do, but in a lab situation you may not simply have the machines or licences to go around.

vmware tends to agree – the vCenter server itself wont normally install on a system where AD is running.

This product can only be installed on the following 64-bit operating systems:
Windows XP SP2 or above
Windows 2003
Windows 2008

The secret is to get vCenter to use different ports for its ADAM instance.

As I prefer scripting to clickity-click you can put in a default vCenter server build (with different LDAP ports) using

start-process -wait -filepath z:\vpx\VMware-vcserver.exe -argumentlist '/q /s /w /L1033 /v" /qr DB_SERVER_TYPE=Bundled FORMAT_DB=1 VCS_ADAM_LDAP_PORT=3899 VCS_ADAM_SSL_PORT=6369"'

You should install vCenter Server before promoting to AD. Once it’s done you can run dcpromo.exe to set up the AD.

Note: You wont be able to re-install the vCenter server though so the usefulness to you may vary. That’s right, this is not a recommended production deployment 😉

If you know what everything above is doing – great. If you don’t, then assume it will eat your children.

Automated VCenter install (lab)

I’m trying to keep my home lab pretty automated. One of the things i’m always (well occasionally 🙂 )trying out is new vCenter installs. In order to speed things up I have the following little powershell script to remove the vCenter Server application and the vCenter Client prior to automatically re-installing them.

This script below uses defaults for the install. It’s possible to completely script the install which is useful if you have a corporate standard configuration. All the details can be found here.

Anyway, here is the script – i’ve called it the totally imaginative name of resetvc.ps1 – don’t run it in your production environment unless you know what you’re doing

(get-wmiobject -computername . -class Win32_Product -Filter "NAME='VMware vCenter Server'" ).Uninstall()
(get-wmiobject -computername . -class Win32_Product -Filter "NAME='VMware vSphere Client 4.1'" ).Uninstall()
start-process -wait -filepath z:\vpx\VMware-vcserver.exe -argumentlist '/q /s /w /L1033 /v" /qr DB_SERVER_TYPE=Bundled FORMAT_DB=1"'
start-process -wait -filepath z:\vpx\VMware-viclient.exe -argumentlist '/q /s /w /L1033 /v" /qr INSTALL_VIUPDATE=1"'

Notes: First 2 lines uninstall the vCenter Server and the vSphere Client – just ignore the error messages if this is the first time you’ve installed the vCenter Server etc. The third line installs the vcenter server from the iso which for me is my z:. Lucky last, the vSphere Client is installed – including in this case the Host Update utility.

vmdk to kvm (qemu)

I finally decided to migrate the last of my vmware-server systems to KVM.

The process is pretty simple and this is what I did.

  1. As my vmdk file was split into many 2Gb chunks I had to firstly convert that into a monolithic file.  This is easily achieved with the vmware-vdiskmanager utility supplied with vmware-server (or at least the version 1.0.x of vmware-server I was running 🙂 )

    vmware-vdiskmanager -r winxp.vmdk -t 2 winxp-full.vmdk

    The -t 2 is the important part taking all the 2Gb chunks *referenced* by the vmdk file and creating an equivalen single pre-allocated vmdk file.

  2. Once you have that file then it’s a simple qemu-img command to convert it to something that KVM is happy with.  In my case I wanted QCOW2 format.

    qemu-img convert winxp-full-flat.vmdk -O qcow2 winxp.img

    You will notice that I said -full.flat.vmdk – this is the pre-allocated file referred to by the new winxp-full.vmdk file.

  3. That’s it 🙂

augeas and appending lines to /etc/fstab

Ok, now that’s a specific title 🙂

The reason i’m writing this is because I googled for what appeared to be an eternity and could only find people re-hashing other peoples blog posts that really didn’t help at all.  ps. re-blogging is not the same as re-tweeting and is best avoided.

In this case I wanted to use augeas to append an entry to /etc/fstab.

[root@cobbler manifests]# augtool
augtool> print /files/etc/fstab
/files/etc/fstab
/files/etc/fstab/1
/files/etc/fstab/1/spec = “LABEL=/”
/files/etc/fstab/1/file = “/”
/files/etc/fstab/1/vfstype = “ext3”
/files/etc/fstab/1/opt = “defaults”
/files/etc/fstab/1/dump = “1”
/files/etc/fstab/1/passno = “1”
/files/etc/fstab/2
/files/etc/fstab/2/spec = “LABEL=/boot”
.
.
.
/files/etc/fstab/7
/files/etc/fstab/7/spec = “LABEL=SWAP-vda3”
/files/etc/fstab/7/file = “swap”
/files/etc/fstab/7/vfstype = “swap”
/files/etc/fstab/7/opt = “defaults”
/files/etc/fstab/7/dump = “0”
/files/etc/fstab/7/passno = “0”
Now I wanted to add a NFS entry and since /etc/fstab has line numbers (from an augeas perspective) rather than arrays you have to use a little hack to add the entry.
If you specify a line number that exists then you will replace that entry, however if you specify a line number that doesn’t exist then the line is appended.  So how can you be sure the line number doesn’t exist ?  – well there’s the hack – just put a 0 in front of it and it will never exist 🙂
augtool> set /files/etc/fstab/01/spec “192.168.1.2:/srv/vs”
augtool> set /files/etc/fstab/01/file “/srv/vs”
augtool> set /files/etc/fstab/01/vfstype “nfs”
augtool> set /files/etc/fstab/01/opt[1] “soft”
augtool> set /files/etc/fstab/01/opt[2] “intr”
augtool> set /files/etc/fstab/01/opt[3] “rsize=8192”
augtool> set /files/etc/fstab/01/opt[4] “wsize=8192”
augtool> set /files/etc/fstab/01/opt[5] “nosuid”
augtool> set /files/etc/fstab/01/dump “0”
augtool> set /files/etc/fstab/01/passno “0”
augtool> save
Saved 1 file(s)
[root@cobbler manifests]# cat /etc/fstab
LABEL=/                 /                       ext3    defaults        1 1
.
.
.
192.168.1.2:/srv/vs /srv/vs nfs soft,intr,rsize=8192,wsize=8192,nosuid 0 0
So there you go.   Why the hell was I doing this?   Well it was part of a puppet deployment so it was actually part of a puppet class that looks like…
augeas{ “vs mount” :
context => “/files/etc/fstab”,
changes => [
“set 01/spec 192.168.1.2:/srv/vs”,
“set 01/file /srv/vs”,
“set 01/vfstype nfs”,
“set 01/opt[1] soft”,
“set 01/opt[2] intr”,
“set 01/opt[3] rsize=8192”,
“set 01/opt[4] wsize=8192”,
“set 01/opt[5] nosuid”,
“set 01/dump 0”,
“set 01/passno 0”,
],
onlyif => “match *[spec=’192.168.1.2:/srv/vs’] size == 0”,
}
I’m an augeas newbie but given how much I had to search to come even close to the above item may mean this post is of use to someone else.  If it’s already common knowledge then no harm done 🙂

Ethernet over power

Got myself a pair of the netcomm 200Mbps Homeplug AV ethernet over power adapters to reach into a hard to reach (wireless wise) part of my house.

Plugged them in, turned them on, configured linux to bring the interface up – works!

Technology is fantastic when it works – and this works fine. Throughput-wise I got 23 Megabytes / sec which is 184 Megabits / sec which is close to the rated throughput of the device.   Sure , I might have gotten lucky, but I deserve it 🙂

Apollo 11 and nutcases

40 years ago this month people landed on the moon.   It was real, it was not done in hollywood, it was not a hoax – so get over it.

Evidence was requested by the conspiracy theory nutcases, well here it is, images of some of the apollo landing sites on the moon complete with the tracks left by the astronauts as they deployed some science experiments.

369228main_ap14labeled_540

Of course, the above image was likely also faked as part of an ongoing conspiracy.  At this point I will just sigh and hope that you nuts all just slowly fade away or perhaps you can put your efforts into developing technology and programmes to get yourself to the moon to see it first hand, hopefully without a space suit.

Of course none of this post should concern you as clearly I am simply part of the conspiracy and the fact that you have read this means I have circumvented your aluminium foil hat protection and I am now reading and controlling your every thought.   All your base are belong to us!