Injecting NIC driver in installer
Support system used: Fedora core 13 32 bit
PART 1
===========================================================================================================
Extracting the driver from driver cd/dvd/floppy/tape/ls120/zip/jazz
-----------------------------------------------------------------------------------------------------------
- copy vmtar from esx host and move to /bin
- donwload Serverengines 10Gb driver cd from VMware vmware-esx-drivers-net-be2net......iso
- Copy SVE-be2net-2.102.404.0-offline_bundle-281453.zip from .iso file
- You have a file called vmware-esx-drivers-net-be2net.......vib
- And what kind of a file is the .vib file?
# file vmware-esx-drivers-net-be2net.......vib
# vmware-esx-drivers-net-be2net.......vib Debian binary package (format 2.0) hahahaha great!
- Extract the files from the debian container
# ar vx file vmware-esx-drivers-net-be2net.......vib
x - debian-binary
x - control.tar.gz
x - data.tar.gz
x - short.rpm
x - descriptor.xml
x - sig.pkcs7
- Untar the data file holding the driver
# tar zxvf data.tar.gz
./
./usr/
./usr/lib/
./usr/lib/vmware/
./usr/lib/vmware/vmkmod/
./usr/lib/vmware/vmkmod/be2net.o
./etc/
./etc/vmware/
./etc/vmware/pciid/
./etc/vmware/pciid/be2net.xml
./etc/vmware/init/
./etc/vmware/init/manifests/
./etc/vmware/init/manifests/vmware-be2net.mf
Driver = .o
pciinf = .xml
some crap of how to use this drive = .mf (yes ofcourse we will obey.... NOT)
Extracting sys.vgz ESXi installer ramdrive
-----------------------------------------------------------------------------------------------------------
- copy sys.vgz into a new directory
- Rename sys.vgz to sys.gz so vmtar gzip understands
# MV sys.vgz to sys.gz
- gunzip sys.gz
# gunzip sys.gz
- Convert the sys to notmal tar format
# vmtar -x sys -o sys.tar
- Untar sys.tar
# tar xvf sys.tar
- You end up with the unpacked system tree of the ESXi installer
Moving the driver(s) into place
-----------------------------------------------------------------------------------------------------------
- Copy files into place
# cp <path/to/prepaired/driver>.o <usr/lib/vmware/vmkmod/driver.o
-also for .xml and .mf file
- Voila your done ;-)
Compressing the newly build sys.vgz structure
-----------------------------------------------------------------------------------------------------------
- tar cvf sys.tar *
- convert normal .tar to vmtar format
# vmtar -c sys.tar -o sys
- gzip the newly build sys file
# gzip sys
- Rename .gz to .vgz
# mv sys.gz sys.vgz
- Copy sys.vgz into the original tree and you're done
the installer now boots (if correctly executed) with the new driver!
PART 2
===========================================================================================================
Now the system is able to install itself via PXE or some other prefound method the issue of a missing (NIC) driver at boot time will be the same.
Therefore we need a manageble way to inject a driver package into the installation tree so it can be used the 1st time at boot.
I here you say "but there was a bug in the installer when patching in %firstboot"
Yes there WAS, we fixed it. Or better said we used the bug to enable us doing nice things ;-)
Inserting driver package in the imagedd.bz2 file
-----------------------------------------------------------------------------------------------------------
- copy imagedd.bz2 & imagedd.md5 to a newly create directory
- bunzip 2 the imagedd file
#bunzip2 imagedd.bz2
- setup the loop0 device for mounting loopback images (no this is not the same as "mount -o loop")
#losetup -f
#losetup /dev/loop0 imagedd
- Check if partitions in loopback mounted imagedd are visible
# fdisk -l /dev/loop0
Device Boot Start End Blocks Id System
/dev/loop0p1 5 900 917504 5 Extended
/dev/loop0p4 * 1 4 4080 4 FAT16 <32M
/dev/loop0p5 5 254 255984 6 FAT16
/dev/loop0p6 255 504 255984 6 FAT16
/dev/loop0p7 505 614 112624 fc VMware VMKCORE
/dev/loop0p8 615 900 292848 6 FAT16
Partition table entries are not in disk order
Yess working stuff!!
- Prepare loop0 device and create (special) device files
# kpartx -av /dev/loop0
loop0p1 : 0 2 /dev/loop0 8192
loop0p4 : 0 8160 /dev/loop0 32
loop0p5 : 0 511968 /dev/loop0 8224
loop0p6 : 0 511968 /dev/loop0 520224
loop0p7 : 0 225248 /dev/loop0 1032224
loop0p8 : 0 585696 /dev/loop0 1257504
- Check if device files are created in /dev/mapper (vliegen mapper??)
# ls -alF /dev/mapper
drwxr-xr-x. 2 root root 220 Oct 8 17:58 ./
drwxr-xr-x. 17 root root 3700 Oct 8 17:58 ../
crw-rw----. 1 root root 10, 62 Oct 3 15:39 control
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p1 -> ../dm-2
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p4 -> ../dm-3
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p5 -> ../dm-4
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p6 -> ../dm-5
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p7 -> ../dm-6
lrwxrwxrwx. 1 root root 7 Oct 8 17:58 loop0p8 -> ../dm-7
lrwxrwxrwx. 1 root root 7 Oct 3 15:39 vg_vitfedora01-lv_root -> ../dm-0
lrwxrwxrwx. 1 root root 7 Oct 3 15:39 vg_vitfedora01-lv_swap -> ../dm-1
- Mount a "partition / (very, very special) device mapper file" onto a mountpoint of choise
# mount -t vfat /dev/mapper/loop0p8 /mnt/hd
# ls -al /mnt/hd
total 36
drwxr-xr-x. 3 root root 16384 Jan 1 1970 .
drwxr-xr-x. 6 root root 4096 Oct 8 15:09 ..
drwxr-xr-x. 4 root root 16384 May 18 17:16 packages
Nice.... be nice to mice ;-)
- Copy downloaded driver package to the target partition
# mkdir /mnt/hd/packages/4.1.0/drivers
# cp ../../.......<driverpackage>.zip /mnt/hd/packages/4.1.0/drivers/nicdriver.zip
- Unmount the imagedd file
# umount /mnt/<mountpoint>
- Remove special device files
# kpartx -dv /dev/loop0
- Disable the loop0 device
# losetup -d /dev/loop0
- bzip2 the imagedd
# bzip2 imagedd
- Create new MD5 HASH
# md5sum imagedd.bz2
d7a3d405bea3204a7f42e4c9e428e510 imagedd.bz2
- Replace the HASH inside the imagedd.md5 yes the filename is different.... dont touch it.
- Voila and you're done. Now you will be able to correctly install the targetted driver during the %fistboot.
PART 3
===========================================================================================================
The code below needs to be in the 1st %firstboot scripts.
It installs the driver follwoing a correct path regestering the driver in the ESXi patch database while maintaining %fistboot.
After the 1st reboot the system thinks its being booted for the 1st time and will roll out any scripts created.
____________________________________________________________________________________
%firstboot --unsupported --interpreter=busybox --level=900
# Install modified nicdriver for 10Gb Emulex Serverengines NIC
/bin/vim-cmd hostsvc/maintenance_mode_enter >>/productLocker/DRIVERS/nicdriver.log 2>$1
sleep 60
/sbin/esxupdate --loglevel=DEBUG --bundle=/productLocker/DRIVERS/nicdriver.zip update >>/productLocker/DRIVERS/nicdriver.log 2>$1
sleep 60
# Move the 999.firstboot_remove script so it is disabled
rm -f /etc/vmware/init/init.d/999.firstboot_remove
# Delete 900.firstboot_001 so nicdriver is not installed twice
rm -f /etc/vmware/init/init.d/900.firstboot_001
# Modify onetime.tgz to remove installation of nicdriver and maintain firstboot scripts at net reboot
mkdir /tmp/onetime
cd /tmp/onetime
cp /vmfs/volumes/Hypervisor1/onetime.tgz .
tar zxvf onetime.tgz
rm -f /tmp/onetime/etc/vmware/init/init.d/900.firstboot_001
tar zcvf onetime.tgz *
cp onetime.tgz /vmfs/volumes/Hypervisor2/
cp /vmfs/volumes/Hypervisor2/* /vmfs/volumes/Hypervisor1/
reboot
____________________________________________________________________________________
So and now its time for beer!! see y'all @ VMworld in Copenhagen ;-)