A simple init script for openvswitch at CentOS 6

I’ve written a simple init script for openvswitch which uses ovs-ctl script.  I’ve saved it as /etc/init.d/ovswitch and I’ve configured it to start automatically with chkconfig ovswitch on.

# chkconfig: 2345 20 80
# description: ovswitch system startup-script using ovs-ctl
# author: Miguel Angel Alvarez Cabrerizo (n40lab.wordpress.com)

# Provides: openvswitch
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop openvswitch daemons
# Description: Load kernel modules, start and stop openvswitch daemons

# Source function library.
. /etc/rc.d/init.d/functions

# config="<path to major config file>"

# This init script starts ovswitch with bridge compatibility --brcompat

[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog


start() {
$exec start --system-id=random --brcompat
[ $retval -eq 0 ] && touch $lockfile
return $retval

stop() {
$exec stop
[ $retval -eq 0 ] && rm -f $lockfile
return $retval

restart() {

status() {
$exec status

case "$1" in
start && exit 0
stop || exit 0
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
exit $?

Installing openvswitch in CentOS 6.3

Okay, once I installed CentOS 6.3 in my N40L, it’s time to prepare the tools for my virtual lab environment.
I’m willing to test openvswitch so I read the documentation from the project’s webpage.

I’m goint to use openvswitch as a bridge module replacement. The documentation is easy to read and quite clear, just browse it slowly so you don’t miss important things. These are the notes I took during the installation…

  • First of all, check if the bridge kernel module is loaded with “lsmod | grep bridge”, it it’s loaded remove it with “rmmod bridge”.
  • Let’s install some packages with yum (I’m using epel repository just in case!):
     yum install make gcc pkgconfig openssl openssl-devel glibc-devel iproute kernel-devel git python python-zope-interface python-twisted-conch PyQt4 wget 
  • Warning #1: I tried to build the latest release (1.7.1 at the time of writing) and the long-term support release with no success. Compilation failed, complaining about skb_frag_page() was redefined, and here you can find the problem with Red Hat / CentOS 6.3. I had to use the source code from their git repository.
  • Warning #2:You’ll need autoconf > 2.63 if you want to build the latest openvswitch from git. Sorry… you’ll have to download and compile autoconf first:
    wget http://ftp.gnu.org/gnu/autoconf/autoconf-latest.tar.gz
     make install
  • Then I created a non-root user to build openvswitch and I got into /home/ovswitch:
    adduser ovswitch
    cd /home/ovswitch
  • I downloaded the source from the project’s git repository. Then inside openvswitch directory, and as your non-root user let’s compile Openvswitch:
    git clone git://openvswitch.org/openvswitch
    ./configure --with-linux=/lib/modules/`uname -r`/build
  • And now as root user:
    make install
  • Ok. As openvswitch’s documentation suggests, let’s try to load the module:
    cd datapath/linux
    insmod openvswitch.ko
  • If no error was shown…
    make modules_install

And that’s all!, now I’m going to learn how to use openvswitch…


I’ve recently unpacked my HP N40L Microserver and, as always, I’m a happy HP customer. I’m going to use this low cost server to build my own lab and I’ll write in this blog about my experiences and tests.

This is the first post, so maybe you’ll find this information useful. My HP N40L came with 2 GB of DDR3 ECC RAM Memory. I purchased a Kingston non-ECC 4 GB RAM module and… now I have 6 GB. I know, I know, I would not mix ECC and non-ECC RAM in a production environment, and yes!, it’s a better idea to use the same memory size in both memory banks to improve performance, but… non-ECC RAM was cheaper :-D.

See ya!