KVM with iPXE in RHEL 6

A while ago I discovered the amazing iPXE project. It is a complete PXE implementation with lots of nifty features, based on the gPXE project. Redhat ships the gPXE firmware for qemu and KVM, and you might want to use iPXE instead as the iPXE project currently seems to be more active. The major features (copied from ipxe.org):

  • boot from a web server via HTTP
  • boot from an iSCSI SAN
  • boot from a Fibre Channel SAN via FCoE
  • boot from an AoE SAN
  • boot from a wireless network
  • boot from a wide-area network
  • boot from an Infiniband network
  • control the boot process with a script

First, download the source code:

espen@luft:~$ mkdir ~/git
espen@luft:~$ cd ~/git
espen@luft:~/git$ git clone git://git.ipxe.org/ipxe.git
Cloning into ipxe...
remote: Counting objects: 33376, done.
remote: Compressing objects: 100% (9193/9193), done.
remote: Total 33376 (delta 24642), reused 30782 (delta 22666)
Receiving objects: 100% (33376/33376), 8.02 MiB | 1.94 MiB/s, done.
Resolving deltas: 100% (24642/24642), done.
espen@luft:~/git$ cd ipxe/
espen@luft:~/git/ipxe$

Then change the general configuration file (src/config/general.h) to suit your needs. Use the #define and #undef to activate and deactivate various features such as VLAN support, DHCP support, etc. Below is a small part of the header file for you to see.

[...]
#define IWMGMT_CMD   /* Wireless interface management commands */
#define FCMGMT_CMD   /* Fibre Channel management commands */
#define ROUTE_CMD    /* Routing table management commands */
#define IMAGE_CMD    /* Image management commands */
#define DHCP_CMD     /* DHCP management commands */
#define SANBOOT_CMD  /* SAN boot commands */
#define LOGIN_CMD    /* Login command */
#undef  TIME_CMD     /* Time commands */
#undef  DIGEST_CMD   /* Image crypto digest commands */
#undef  LOTEST_CMD   /* Loopback testing commands */
#undef  VLAN_CMD     /* VLAN commands */
#undef  PXE_CMD      /* PXE commands */
#undef  REBOOT_CMD   /* Reboot command */
[...]

Now it’s time compile the firmware.

espen@luft:~/git/ipxe$ cd src/
espen@luft:~/git/ipxe/src$ make bin/virtio-net.rom
  [DEPS] arch/i386/drivers/net/undirom.c
  [DEPS] arch/i386/drivers/net/undipreload.c
  [DEPS] arch/i386/drivers/net/undionly.c
  [DEPS] arch/i386/drivers/net/undinet.c
[...]
  [BIN] bin/virtio-net.rom.bin
  [ZINFO] bin/virtio-net.rom.zinfo
  [ZBIN] bin/virtio-net.rom.zbin
  [FINISH] bin/virtio-net.rom
[...]
espen@luft:~/git/ipxe/src$

The firmware compiled successfully, and it is ready to use. Log onto the RHEL 6 node, and verify that you have installed the package gpxe-roms-qemu (qemu-kvm currently depends on gpxe-roms-qemu). The directory /usr/share/gpxe/ contains the gPXE boot roms from this package.

To use your custom iPXE boot firmware instead, you can build a new rpm package that contains the new rom – or you can simply replace /usr/share/gpxe/virtio-net.rom [gPXE] with your ~/git/ipxe/src/bin/virtio-net.rom [iPXE]. As least you will have iPXE boot firmware until the qemu-roms-qemu package is updated ;)

Make sure that your virtual machines are using the virtio network device driver, and you are all set:

[...]
<interface type='bridge'>
  [...]
  <model type='virtio'/>
</interface>
[...]

Your virtual machines will now be booted using the iPXE boot firmware. Have a look at the iPXE scripting documentation for more inspiration!

Posted in sysadm | Leave a comment

Workaround of the day: PXE as primary boot dev on a dl360 g7

The problem: How to set PXE as the preferred boot device on a default HP dl360 g7 from Linux?

The key words here are “from Linux”. No iLO tricks are allowed. Of course, the simple answer should be: “use ipmitool!”. However, ipmitool (I’m currently using ipmitool-1.8.11-6.el6.x86_64 in Scientific Linux 6) doesn’t quite seem to do the trick here. The following have been tried without success:

[root@localhost ~]# ipmitool chassis bootdev pxe
Set Boot Device to pxe
[root@localhost ~]# reboot
[root@localhost ~]# ipmitool chassis bootparam set bootflag force_pxe
Set Boot Device to force_pxe
[root@localhost ~]# reboot
[root@localhost ~]# ipmitool chassis bootdev pxe clear-cmos=yes
Set Boot Device to pxe
[root@localhost ~]# reboot

It is nice to know that the dl360 g7 will PXE boot if it is unable to boot from the local hard drive. This behaviour can be used as a (not-so-pretty-ok-I-admit-it-is-very-very-VERY-ugly-but-it-works-for-me type of) workaround:

[root@localhost ~]# modprobe ipmi_si
[root@localhost ~]# modprobe ipmi_devintf
[root@localhost ~]# alias reinstall="/bin/dd if=/dev/zero \
of=/dev/sda bs=512 count=1 2>/dev/null ; sync ; \
ipmitool chassis bootparam set bootflag force_pxe \
>/dev/null ; reboot"
[root@localhost ~]# reinstall

(The alias is called reinstall because booting from PXE will, in this setup, reinstall the node.)

Good luck!

Posted in sysadm | Leave a comment

munincollector-ng

Munincollector-ng is a perl script that collects graphs from multiple munin installations to display them in one page. A scenario where this is helpful is when you have (too) many munin clients on (too) many munin masters, and you want to look through some of the graphs – i.e. the Disk usage in percent (aka df) plugin – without spending/wasting too much time browsing through the less important graphs.

It consists of one perl script and one configuration file. It is being executed regularly by cron. At each run, it iterates through the configuration file; downloads the graphs to a local directory and generates an html file:

Below is some example configuration that will gather the week and month graphs from the df plugin from four separate munin masters (three without authentication and one with authentication). The graphs will be downloaded to /var/www/munincollector-ng/:

# General configuration
graph.plugin df
graph.type week month
graph.log /var/log/munincollector-ng.log
graph.dir /var/www/munincollector-ng

# Configuration per munin master you want to collect graphs from.
# The format is: <id>.<option> <value>

# Three munin installations with no authentication
uio.url http://munin.ping.uio.no
foo.url http://foo.com/munin/
bar.url http://bar.com/munin/

# One munin master that requires authentication
baz.url http://baz.com/munin/
baz.realm Munin
baz.username user1
baz.password pass1
baz.netloc baz.com:80

An example cron job that will execute the script once per day (make sure user have write permissions in /var/www/munincollector-ng/):

8 8 * * * user /usr/local/bin/munincollector-ng -c /etc/munincollector-ng/example.conf

The script is available from github.

PS: Put the logo.png and style.css from your /etc/munin/templates/ directory into /var/www/munincollector-ng/ to make it look a bit nicer.

Posted in sysadm | 2 Comments