Archive

Posts Tagged ‘pxeboot’

VMware VMXNET driver support when using PXEBOOT and Kickstart

July 10th, 2009 Dave Rose 1 comment


I know VMware would probably ask why I don’t just clone a reference image when creating additional VM’s, but I find that I like to be able to create a system from scratch and apply my cfengine against it.  Also, contrary to what VMware would like, not every server I bring up is virtual, and I’d like to use the same mechanism for creating physical systems as I do for virtual systems.

My main issue was, that when I used PXEBOOT and Kickstart, I could not get Linux to recognize the vmxnet 2 or vmxnet 3 NIC.  What I ended up having to do, was to install a E1000 NIC first, go through the PXEBOOT and Kickstart method, install the VMware Tools, and  then shut the VM down, remove the E1000 NIC, boot the VM back up, re-configure IP settings, run vmware-config-tools.pl and finally reboot. Talk about a PIA. I thought, wouldn’t it be nice for me to be able to use the vmxnet 2 or vmxnet 3  NIC right from the start. It took some time and a bit of Googling, but I was able to piece together a recipe for doing  just that. It may not be perfect, but it works for me. If you can see some room for improvement, please comment.

The operating system I am currently using is CentOS 5.2

Prerequisites:

A VM with the vmxnet 2 or vmxnet 3 NIC installed and VMware tools configured. You will need this so that you can grab the kernel drivers. This blog assumes you already know or have a working PXEBOOT and Kickstart installation set up.

Ok, lets begin…first you will need to grab the initrd.img from the PXEBOOT directory, originally i got it from the images/pxeboot directory on the CentOS 5.2 DVD


mkdir /tmp/work
cd /tmp/work
cp /mnt/dvd/images/pxeboot/initrd.img .
mkdir initrd

Now we need to unpack the initial ramdisk, on a 2.6 kernel version it is a gzipped cpio archive.


cd initrd
zcat ../initrd.img | cpio -id

This will essentially explode the contents of the initrd.img disk so that we can modify things.

Once you have things exploded, you will need to gather some information for use later, so on your reference VM system perform the following

lspci

lspci output

Now that we know what number we are looking for, we actually need some hex numbers, which you can get by typing:

lscpci -n

lspci -n output

We now need to explode the modules cpio archive from within the initrd subdirectory


mkdir /tmp/work/modules
cd /tmp/work/modules
zcat ../initrd/modules/modules.cgz  | cpio -id

In my case the PXEBOOT initrd.img modules.cgz contains x86_64  2.6.18-92.el5 modules.

We want to now copy in the modules from your reference VM system, in my case the modules were located in /lib/modules/2.6.18-92.1.22.el5/misc. These would be here if you have the VMware Tools installed on your reference VM and you have run vmware-config-tools.pl script.


cd /tmp/work/modules/2.6.18-92.el5/x86_64
cp /lib/modules/2.6.18-92.1.22.el5/misc/vmxnet*.ko .
chmod 744 vmxnet*

I recently learned that modules ending in .o are from 2.4 kernels and the .ko are those from a 2.6 kernel. Since CentOS 5.2 is 2.6 based, I grabbed the vmxnet.ko and vmxnet3.ko modules.

Time to pack the modules back up again


cd /tmp/work/modules
find . | cpio -o -H crc | gzip -9 > /tmp/work/initrd/modules/modules.cgz

This will essentially create a new cpio archive and replace the modules.cgz from the original initrd.img. Notice in this case the cpio format type is crc.

Now we need to modify a few more files to get this to work


cd /tmp/work/initrd/modules
vi pci.ids

You will have to search for VMware, and as you will notice there is a 15ad number which came from the above 2 you were supposed to remember.

Now you can put the folowing line in

07b0  VMware Adapter

vmxnet_initrd_3

Now you want to add the following to the file module-info


vmxnet
      eth
      "VMware vmxnet ethernet driver"

vmxnet3
      eth
      "VMware vmxnet3 ethernet driver"

Next you will need to get the vmxnet entries for the modules.alias file, on my reference VM system, it was in /lib/modules/2.6.18-92.1.22.el5/modules.alias


cd /lib/modules/2.6.18-92.1.22.el5
grep vmxnet modules.alias  >> /tmp/work/initrd/modules/modules.alias

The contents we are looking for was as follows:


alias pci:v000015ADd00000720sv*sd*bc*sc*i* vmxnet
alias pci:v00001022d00002000sv*sd*bc*sc*i* vmxnet
alias pci:v000015ADd000007B0sv*sd*bc*sc*i* vmxnet3

Ok, now its time to package the initrd.img back up


cd /tmp/work/initrd
find . | cpio -o -H newc | gzip -9 > /tmp/work/initrd.img.vmxnet

Notice in this case the cpio format type is newc.

Now copy that new initrd into your pxeboot environment:


cp /tmp/work/initrd.img.vmxnet /tftpboot/centos/centos5.2/x86_64

Be aware that this just allows the install of the OS via PXEBOOT and Kickstart to happen with a vmxnet NIC, but you will also need to have the VMware Tools installed for the VM as well. Prior to ESXi 4, the VMware Tools came in an RPM format, but apparently VMware had many issues with it and now have gone with the tar.gz install method. Personally the RPM always worked for me. I did find it on their VMware Tools CD image for Linux Guest OSes iso, and in my Kickstart configuration I have a custom YUM repo that I have put the RPM into. So during my Kickstart, the VMwareTools-4.0.0-164009.i386.rpm is installed, and I modified the rc.local to make sure to run the vmware-config-tools.pl script


if [ ! -e /etc/vmware-config.ok ]; then
  /usr/bin/vmware-config-tools.pl --default
  /bin/touch /etc/vmware-config.ok
  /sbin/reboot
fi

At the end of all this, I am able to create a 64bit CentOS 5.2 VM with a vmxnet 3 NIC and have it installed using PXEBOOT and Kickstart and come up with VMware Tools installed and active.