XEN ENDIAN

# delegate nic for endian domain
http://www.panticz.de/xen_pci_delegation

DOMAIN_NAME=fw
#URL=http://dfn.dl.sourceforge.net/sourceforge/efw/EFW-COMMUNITY-2.2-rc3-200810071617.iso
URL=http://download.sourceforge.net/sourceforge/efw/EFW-COMMUNITY-2.2-200905211506.iso
URL=http://download.sourceforge.net/sourceforge/efw/EFW-COMMUNITY-2.5.1-201201261800.iso
# test # http://netcologne.dl.sourceforge.net/project/efw/Development/EFW-2.4-RESPIN/EFW-COMMUNITY-2.4-201005280528-RESPIN.iso

# download endian
wget ${URL} -P /tmp

# create lvm image
lvcreate --name fw-disk --size 8G vg1
#losetup /dev/loop0 /tmp/EFW-COMMUNITY-*.iso

# creae endian installation config
cat < /etc/xen/fw-inst
kernel='/usr/lib/xen-default/boot/hvmloader'
builder='hvm'
memory='512'
name='fw-inst'
device_model='/usr/lib/xen-default/bin/qemu-dm'
boot='d'
#disk=['phy:/dev/vg01/fw-disk,ioemu:hda,w', 'phy:/dev/loop0,ioemu:hdc:cdrom,r']
disk=['phy:/dev/vg1/fw-disk,ioemu:hda,w', 'file:/tmp/EFW-COMMUNITY-2.5.1-201201261800.iso,hdc:cdrom,r']
vnc=1
vncviewer=1
vncpasswd='fw-inst'
vif=['type=ioemu,bridge=eth0,ip=192.168.1.253,mac=00:00:00:00:02:53']
on_reboot ='destroy'
vnclisten='0.0.0.0'
EOF

# install
xm create fw-inst

# connect with vnc to endian installation
vncviewer YOUR_XEN_SERVER_IP # pass: "fw-inst"

# delete loop
#losetup -d /dev/loop0

# copy xen kernel
wget http://www.heise.de/ct/projekte/machmit/ctserver/browser/packages/v3/endian_2.2-1_all.deb?format=raw -O /tmp/endian_2.2-1_all.deb
dpkg -x /tmp/endian_2.2-1_all.deb /tmp
cp /tmp/boot/endian/* /boot/

# NEW test, xen kernel from ct server 4 repository
mkdir /boot/endian
wget 'http://www.heise.de/ct/projekte/machmit/ctserver/browser/extrasrc/endian/trunk/vmlinuz-2.6.26-2-xen-686?rev=678&format=raw' \
-O /boot/endian/vmlinuz-2.6.26-2-xen-686
wget 'http://www.heise.de/ct/projekte/machmit/ctserver/browser/extrasrc/endian/trunk/initrd.img-2.6.26-2-xen-686?rev=678&format=raw' \
-O /boot/endian/initrd.img-2.6.26-2-xen-686

# copy xen modules
wget http://www.heise.de/ct/projekte/machmit/ctserver/browser/packages/v3/endian-img_2.2-1_all.deb?format=raw -O /tmp/endian-img_2.2-1_all.deb
dpkg -x /tmp/endian-img_2.2-1_all.deb /tmp/
gzip -d /tmp/var/lib/xen/endian/hda3_512_root.img.gz
mount /tmp/var/lib/xen/endian/hda3_512_root.img /mnt -o loop
cp -a /mnt/lib/modules/2.6.21.7-2.neobiker.efw22xen/ /tmp/
umount /mnt

wget http://de.archive.ubuntu.com/ubuntu/pool/universe/x/xen-3.2/xen-utils-3.2_3.2.0-0ubuntu10.1_amd64.deb -P /tmp
dpkg -x /tmp/xen-utils-3.2_3.2.0-0ubuntu10.1_amd64.deb /tmp/
/tmp/usr/bin/lomount -diskimage /dev/vg01/fw-disk -partition 3 /mnt
#cp -a /tmp/2.6.21.7-2.neobiker.efw22xen/ /mnt/lib/modules/
# get modules online
tar xjf /root/xen.endian.modules.2.6.26-2-xen-686.tar.bz2 -C /mnt/lib/modules/
umount /mnt

cat < /etc/xen/fw
#kernel='/boot/vmlinuz-2.6.21.7-2.neobiker.efw22xen'
kernel='/boot/endian/vmlinuz-2.6.26-2-xen-686'
#ramdisk='/boot/initrd-2.6.21.7-2.neobiker.efw22xen.img'
ramdisk='/boot/endian/initrd.img-2.6.26-2-xen-686'
memory='256'
root='/dev/hda3 ro'
#root='/dev/xvda3 ro'
disk=['phy:/dev/vg01/fw-disk,ioemu:hda,w']
name='fw'
vif=['ip=192.168.1.254,mac=00:00:00:00:00:11']
pci=['01:07.0']
#extra = '2 single'
EOF

# add to autostart
ln -s /etc/xen/$DOMAIN_NAME /etc/xen/auto/

# start vm
xm create -c fw

# backup (optional)
dd if=/dev/vg01/fw-disk | pv | gzip -9 > fw-disk.dd.gz

# LINKS
http://www.heise.de/ct/projekte/machmit/ctserver/wiki/ctsrv4stick
http://www.heise.de/ct/projekte/machmit/ctserver/changeset/678 - endian on ct server 4 repository
http://www.neobiker.de/ftp/pub/efw-xen/
http://www.heise.de/ct/projekte/machmit/ctserver/wiki/Efw211Xen