Bienvenido! - Willkommen! - Welcome!

Bitácora Técnica de Tux&Cía., Santa Cruz de la Sierra, BO
Bitácora Central: Tux&Cía.
Bitácora de Información Avanzada: Tux&Cía.-Información
May the source be with you!

Friday, September 17, 2010

EtherDrive-Export your block devices with AoE

Source
Imagine you have a machine with all of his disk full and another with unused Gigabits, and you don't want to move the data from one to other. Why not using the second's disk on the first, you can do it with iSCSI but you can do it with ATA over Ethernet (AoE) too. It's the second method I'll explain is this article.
All of this was made with two computer running Debian Etch.
Prepare the kernelFirst check if your running kernel have AoE, the config option name is CONFIG_AT_OVER_ETH, have a look at fig1, my kernel has AoE in module
fig1
host:/# grep ATA_OVER /boot/config-`uname -r`
CONFIG_ATA_OVER_ETH=m
host:/#
If not, configure your kernel and activate AoE in core or in module like you prefer
Device Drivers -->
  |- Block Devices --->
      |-   ATA over Ethernet support
Ok now you have a kernel with AoE, just load the aoe module  
host:/# modprobe aoe
host:/#
You can check your syslog to be sure AoE is available
host:/# tail /var/log/syslog
Oct 10 11:54:07 host kernel: aoe: aoe_init: AoE v22 initialised.
host:/#
Now we'll call the client 'client' and the server 'server', funny isn't it ?
In SAN vocabulary we call the client 'initiator' and the server 'target', I prefer to continue using simplest therms.
The server side (target)
In first we need to install the vblade package
server:/# apt-get install vblade
Reading package lists... Done
Building dependency tree... Done
The following NEW packages will be installed:
  vblade
[...]
Unpacking vblade (from .../archives/vblade_11-1_i386.deb) ...
Setting up vblade (11-1) ...
server:/# 
On our server we'll export the /dev/sdd5 partition which has a size of 5GB, export a block device is easy at do
server:/# vbladed 0 1 eth0 /dev/sdd5
server:/# 
Some explication about this command, each AoE device is identify by a couple Major/Minor, with major between 0-65535 and minor between 0-255. AoE is based just over Ethernet on the OSI models so we need to indicate which ethercard we'll use.
Is this example we export /dev/sdd5 with a major value of 0 and minor if 1 on the eth0 interface.
We are ready to use our partition on the network !
Client Side (initiator)The client needs the aoe kernel module too, so prepare your kernel as we saw.
The userlands tools are present in the package aoetools
client:/# apt-get install aoetools
Now discover what we can use over our network :
client:/# aoe-discover
client:/# aoe-stat
      e0.1         5.000GB   eth0 up
client:/#
At this point we have a new block device available on the client box named /dev/etherd/e0.1. If we have a look at the /dev tree a new node appears
client:/# ls -al /dev/etherd/
total 4
drwxr-xr-x  2 root root     140 2007-10-10 13:30 .
drwxr-xr-x 16 root root   14660 2007-10-10 13:30 ..
c-w--w----  1 root disk 152,  3 2007-10-10 13:30 discover
brw-rw----  1 root disk 152, 16 2007-10-10 13:30 e0.1
cr--r-----  1 root disk 152,  2 2007-10-10 13:30 err
c-w--w----  1 root disk 152,  4 2007-10-10 13:30 interfaces
-rw-r--r--  1 root root       5 2007-10-10 13:00 revalidate
What to do with
Simply make a filesystem on your block device like
client:/# mkfs.ext3 /dev/etherd/e0.1
and use it like you do with your /dev/hd* or /dev/sd* the only difference is that block device is over the network ! 
----------------------------------------------------
AoE root for KVM guests
Source
So. I’m trying to get familiar with libvirt and friends. To this end, I’ve set up a Lucid virtual machine booting from PXE into an initrd environment which does a pivot_root to an AoE block device.
The #virt channel on irc.oftc.net told me that in order to have libvirt provide PXE capability, I would have to install a recent version of libvirt. I built version 0.7.5-3 from sid on my karmic laptop and it seems to be working okay.
I decided to set up the pxe root directoy in /var/lib/tftproot just because that’s what the example code had in it.
Configure the Virtual NetworkI had to manually configure a virtual network. Here is the XML config file:
$ sudo virsh net-dumpxml netboot

  netboot
  81ff0d90-c91e-6742-64da-4a736edb9a9b 

Install syslinuxThis, of course, depends on the pxelinux.0 file. Luckily, this is packaged up in syslinux and can be installed with a simple

$ sudo apt-get install syslinux
$ sudo mkdir /var/lib/tftproot
$ sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftproot

Configure PXE boot parametersI had to create a pxelinux config file for the virtual machine (indexed by mac address). Note that I put a console=ttyS0,115200 argument on the kernel command line so that I can attach to the serial port from the host system for copy/paste debugging. Also of importance is the root=/dev/etherd/e0.1p1 argument, specifying which block device we’ll be doing the pivot_root to eventually.

$ mkdir /var/lib/tftproot/pxelinux.cfg/
$ cat /var/lib/tftproot/pxelinux.cfg/01-52-54-00-44-34-67
DEFAULT linux
LABEL linux
SAY Now booting the kernel from PXELINUX...
KERNEL vmlinuz-lucid0
APPEND ro root=/dev/etherd/e0.1p1 console=ttyS0,115200 initrd=initrd.img-lucid0

I decided to use the karmic kernel for lucid initially. I’ll eventually switch over to the lucid kernel ;)

$ sudo cp /boot/vmlinuz-2.6.31-17-generic /var/lib/tftproot/vmlinuz-lucid0

Customize initramfs-tools [READ more]
------------------------------------------------ 
Etherboot Project
We, the Etherboot Project, create network booting code that allows computers to load their operating system from a network. Our code can be stored in a number of places, including BIOS Flash, EPROMs, floppy, CD, HD, or other bootable media.
The Etherboot project has been active since about 1995.
Our Code
Our oldest and most well-known software package is Etherboot. It is currently undergoing a major restructuring, and the next version of the package will be called “gPXE”.
gPXE implements PXE, the industry standard network booting specification, and extends it with a number of new protocols and features.
Additionally, we operate the http://rom-o-matic.net/ website, which dynamically generates Etherboot (and soon gPXE) images in a variety of formats.
If you prefer, you can download the full Etherboot package from our git repository.

-----------------------------------------------
Using AOE to virtualize our hardware
-----------------------------------------------

5.1 Q: How does the system know about the AoE targets on the network

A: When an AoE target comes online, it emits a broadcast frame indicating its presence. In addition to this mechanism, the AoE initiator may send out a query frame to discover any new AoE targets.
The Linux aoe driver, for example, sends an AoE query once per minute. The discovery can be triggered manually with the "aoe-discover" tool, one of the aoetools.

5.2 Q: How do I see what AoE devices the system knows about?

A: The /usr/sbin/aoe-stat program (from the aoetools) lists the devices the system considers valid. It also displays the status of the device (up or down). For example:

root@makki root# aoe-stat
      e0.0     10995.116GB   eth0 up            
      e0.1     10995.116GB   eth0 up            
      e0.2     10995.116GB   eth0 up            
      e1.0      1152.874GB   eth0 up            
      e7.0       370.566GB   eth0 up

No comments: