Thursday 23 August 2012

Bonded interfaces in RHEL

Here's how to create a bonded interface in RHEL 6

This bond is working in failover mode with VLAN tagging over interfaces eth0 & eth1:


ifcfg-bond0
DEVICE=bond0
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
BONDING_OPTS="mode=1 miimon=100"
ifcfg-bond0.x  (where x is vlan number)

DEVICE=bond0.x
IPADDR=y.y.y.y
NETMASK=y.y.y.y
GATEWAY=y.y.y.y
USERCTL=no
BOOTPROTO=static
ONBOOT=yes
VLAN=yes
IPV6INIT=no
ifcfg-ethx (where x is 0 or 1)

DEVICE=ethx
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
USERCTL=no
Note that creating bonding.conf in /etc/modprobe.d is no longer required in the latest RHEL 6 releases.

Restart network services and the bond will be created. Make sure all previous non-bonded interfaces are destroyed before restarting network services otherwise they will interfere with the bond creation. A reboot is the easiest way to sort this out.

To check the status of a bonded interface:

cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009)
Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth1
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth1
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:9c:02:24:7c:dc
Slave queue ID: 0

Slave Interface: eth0
MII Status: up
Speed: 10000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:9c:02:24:7c:d8
Slave queue ID: 0



To force service to a specific interface:
 ifenslave --change-active bond0 eth0

To remove an interface from a bond
 ifenslave -d bond0 eth0

To add an interface back into a bond
 ifenslave bond0 eth0



Monday 13 August 2012

Linux Disk Benchmarking

A really quick way to see the write performance of your disk.....
Write a 512MB file


dd bs=1M count=512 if=/dev/zero of=test conv=fdatasync ; rm test

And it tells you how fast it did it

512+0 records in
512+0 records out
536870912 bytes (537 MB) copied, 2.74433 s, 196 MB/s

The fdatasync option forces dd to do a sync to ensure data is really written to disk before it exits which should give a more realistic figure.

Server imaging with SelfImage & Windows PE

Here's how to restore an image made with the SelfImage utility using a Windows PE boot environment. Previously I have used BartPE but were finding that I kept needing to rebuild the image to support the various different NIC & array drivers used on newer servers.

A recent WinPE enviroment has these drivers already built in. So if the server can build directly from the Windows server 2008 CD then it can use the WinPE disk without modification. I've been using WinPE version 2 for what it's worth. Version 1 was based on an earlier Windows version so doesn't have the newer drivers in it.

This post assumes you have access to a WinPE environment boot cd (or iso) and also that it has been modified to include the SelfImage utility.
  • Boot into WinPE environment 
  • Configure interface (n is the interface number, x is IP, y is netmask, z is gateway)
    • netsh interface ip set address name="Local Area Connection n" static x.x.x.x y.y.y.y z.z.z.z 1
  • Map a drive to where the image is loaded (remember the username is specified as server\usersname)
    • net use e: \\server\share
  • Configure a primary partition on the disk using diskpart
    • select disk 0
    • clean
    • create partition primary size=<size in mb>
    • select partition 1
    • active
    • assign letter=c:
  • Run the selfimage tool and select the output to be \Device\Harddisk0\Partition1 C:
  • Before rebooting fix the boot manager otherwise the server will blue screen
    • bcdedit /set {default} device partition=c:
    • bcdedit /set {default} osdevice partition=c:
    • bcdedit /set {bootmgr} device partition=c:
Reboot server and the job is done.

Note that on reboot Windows may complain that it was not shutdown properly, this can be ignored and Windows booted normally. Also once logged in you may find Windows installs some more device drivers, let it finish and do one more reboot to finish the job off.