2012年7月22日 星期日

xencommons無法啟動

無法啟動無法啟動xencommons

出現下面訊息下面訊息下面訊息
libxenctrl.so.4.0: cannot open shared object file: No such file or directory
 
是因為無法找到libxenctrl.so.4.0 
所以要讓系統產生連結找到這個檔案
 
他有可能在
/usr/lib
/usr/lib32
/usr/lib64
/usr/local/lib
其中一個目錄中,找找看
 
之後打開ld.so.conf
 
加讓目錄位置之後存檔
使用指令使用指令 使用指令
sudo /sbin/ldconfig -v 
做更新
然後就修好了
 

2012年7月19日 星期四

ubuntu 11.10上安裝xen4.1.2(修)

直接make 一大堆錯誤需要安裝一大堆東西


其中 ACPI ASL compiler 要自己去網站下載原碼編譯安裝


安裝的方法跟普通有點不一樣


 http://acpica.org/downloads/


照著網站教學會發現錯誤


在 make 完compiler資料夾後需要把執行檔複製到usr/bin下面才能用


cp iasl /usr/local/bin


如果安裝有報撮要apt-get一些東西


sudo apt-get install flex


sudo apt-get install bison


 其他需要apt-get的東西


sudo apt-get install libz-dev


sudo apt-get install openssl libssl-dev


sudo apt-get install uuid-dev


sudo apt-get install libsdl1.2-dev


sudo apt-get install bin86


sudo  apt-get install bcc


sudo apt-get install gcc-multilib


sudo apt-get install python-dev


sudo apt-get install texinfo


sudo apt-get install gettext  

sudo apt-get install xfig


 sudo apt-get install build-essential
 sudo apt-get build-dep xen


都下載完之後

make xen


make tools


make stubdom


sudo make install-xen


sudo make install-tools


sudo make install-stubdom


make dist
 
sudo make install



以上xen安裝完

再來編譯xen 需要的kernel kernel

我用的是從kernel.org下載的3.2.23

參考文件

http://www.lancehendrix.com/techdocs/incubation/Xen4.1OnKernel3.2.html

http://wiki.xen.org/wiki/File:Building_and_Installing_Xen_4.x_and_Linux_Kernel_3.x_on_Ubuntu_and_Debian_Linux.pdf
http://wiki.xen.org/wiki/Compiling_Xen_From_Source



 make menuconfig

選項

Device Drivers --->

      Xen driver support --->

              全部*

[*] Networking support  --->
   Networking options  --->
      <*> 802.1d Ethernet Bridging







接下來

make

make modules_install

make install



修改grub
sudo update-grub

xencommons 設定開機啟動

sudo gedit /etc/rc.local

sudo /etc/init.d/xencommons start


將xen的模組設定開機載入
sudo gedit /etc/modules

xen-evtchn
xen-gntdev
xen-netback
xen-blkback
xenfs
blktap







2012年7月16日 星期一

SR-IOV載入

環境:

系統使用ubuntu 11.10
xen 是 apt-get install 的 xen4.1.1
igb版本是3.4.7


硬體:

cpu 是 intel i5-3470 L
主機板 是 asus P8B75-v
Bios  版本是 P8B75-V BIOS 0503
網路卡 是 intel i350-T2


因為bios支援性差
所以如果直接載入使用會出現錯誤訊息

SR-IOV: bus number out of range


所以要在grub.cfg設定pci=assign-busses


submenu "Xen 4.1-amd64" {
menuentry 'Ubuntu GNU/Linux, with Xen 4.1-amd64 and Linux 3.0.0-22-generic XD' --class ubuntu --class gnu-linux --class gnu --class os --class xen {
    insmod part_gpt
    insmod ext2
    set root='(hd0,gpt2)'
    search --no-floppy --fs-uuid --set=root 9d986b5a-4929-4c09-9740-b3e9bb0cbbe3
    echo    'Loading Xen 4.1-amd64 ...'
    multiboot    /boot/xen-4.1-amd64.gz placeholder 
    echo    '載入 Linux 3.0.0-22-generic ...'
    module    /boot/vmlinuz-3.0.0-22-generic placeholder root=UUID=9d986b5a-4929-4c09-9740-b3e9bb0cbbe3 ro  quiet splash pci=assign-busses
    echo    '載入初始化記憶體虛擬磁碟 (initial ramdisk) ...'
    module    /boot/initrd.img-3.0.0-22-generic
}





接著重開機


將igb卸載
sudo modprobe -r igb


再下參數載入
sudo modprobe igb max_vfs=4




用lspci查看就會成功出現下面訊息下面訊息下面訊息下面訊息
01:00.0 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
01:00.1 Ethernet controller: Intel Corporation I350 Gigabit Network Connection (rev 01)
02:10.0 Ethernet controller: Intel Corporation Device 1520 (rev 01)
02:10.4 Ethernet controller: Intel Corporation Device 1520 (rev 01)
02:11.0 Ethernet controller: Intel Corporation Device 1520 (rev 01)
02:11.4 Ethernet controller: Intel Corporation Device 1520 (rev 01)
04:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)


2012年7月8日 星期日

xen之domU全虛擬建立

參考資料
http://trac.nchc.org.tw/cloud/wiki/Xen_Lab1

使用dd建立一個空的img檔案
dd if=/dev/zero of=ubuntu01.img bs=1M seek=8000 count=1


設定格式ext3
mkfs.ext3 ./disk.img


開一個空白文件存成cfg檔
內容記得修改name disk 其他依照需求設定


#import os, re
#arch = os.uname()[4]
#if re.search('64', arch):
#    arch_libdir = 'lib64'
#else:
#    arch_libdir = 'lib'
#上面那段使用xl會發生錯誤,所以註解掉

kernel = "/usr/lib/xen/boot/hvmloader"
builder='hvm'
memory = 1024

# Should be at least 2KB per MB of domain memory, plus a few MB per vcpu.
shadow_memory = 8
name = "ubuntu01"#虛擬機的名字,名字記得取
vif2 = [ 'bridge=eth3,pdev=peth3' ]#這邊是網路設定研究中
disk = [ 'file:/home/nttu/domU/ubuntu01.img,hda,w', 'file:/home/nttu/ubuntu-11.10-desktop-amd64/ubuntu.iso,hdc:cdrom,r' ]   
# 'file:/home/nttu/ubuntu-11.10-desktop-amd64/ubuntu.iso,hdc:cdrom,r'這段建立後下一次開機即刪除要不然會進入iso
device_model = '/usr/lib/xen/bin/qemu-dm'

#-----------------------------------------------------------------------------
# boot on floppy (a), hard disk (c) or CD-ROM (d)
# default: hard disk, cd-rom, floppy
boot="dc"#這邊d是第一次建立虛擬機用 之後皆改為c即可

sdl=0
vnc=1#遠端的設定
vncconsole=1
vncpasswd=''
stdvga=0
serial='pty'
usbdevice='tablet'



因為是xen4.1.2所以使用xl

sudo xl create ubuntu01.cfg
 再使用vnc 安裝
sudo xl vnc [編號]
sudo xl list 可以查詢虛擬機編號



2012年7月4日 星期三

ubuntu 11.04編譯安裝xen4.1.2遇到問題與解決

按照這個網站的步驟編譯安裝xen


http://blog.jeoygin.org/2011/04/ubuntu-natty-install-xen-4.html






make xen tools stubdom<<這部會出現erro
原因是少安裝一個檔案,需要apt-get install 安裝起來
 sudo apt-get install  ocaml-findlib






編譯kernel的時候需要把xen相關選項打開


Processor type and features --->
[*] Enable Xen compatible kernel


Networking support --->
Networking options --->
<*> 802.1d Ethernet Bridging

Device Drivers --->
XEN --->
[*] Privileged Guest (domain 0)
[m]Backend driver support
[m]Block-device backend driver
[m]Block-device tap backend driver
[m]Block-device tap backend driver 2
[m]Network-device backend driver
<*> Export Xen attributes in sysfs
Xen version compatibility (no compatibility code) --->
no compatibility code
intel網卡driver因為實驗關係而關掉igb 與igbvf
Device Drivers --->
Networking device support --->
Ethernet(1000Mbit) --->
<>Intel(R) 82575/82576 PCI-Express Gigabit Ethernet support
  <>Intel(R) 82576 Virtual Function Ethernet suppport

Enable Xen compatible kernel
256要改成255



Device Drivers --->
Xen driver support--->
<*>Xen /dev/xen/evtchn device




grub設定 
從grub2降級成grub之後 設定menu.lst要記得看vmlinuz版本 initrd.img檔案 kernel版本 還有UUID


重開機後
sudo /etc/init.d/xencommons start
因為4.1.0版本後不再使用xm所以使用xl


sudo xl list 查看dom0










------------------網站備份



一、準備源碼

  首先,為系統安裝需要的包:

sudo apt-get install bcc bin86 gawk bridge-utils iproute libcurl3 libcurl4-openssl-dev bzip2 module-init-tools transfig tgif texinfo texlive-latex-base texlive-latex-recommended texlive-fonts-extra texlive-fonts-recommended pciutils-dev mercurial build-essential make gcc g++ libc6-dev zlib1g-dev python python-dev python-twisted libncurses5-dev patch libvncserver-dev libsdl-dev libjpeg62-dev iasl libbz2-dev e2fslibs-dev git-core uuid-dev ocaml libx11-dev bison flex libssl-dev gettext libgcrypt11-dev pkg-config fakeroot crash kexec-tools makedumpfile libncurses5
sudo apt-get build-dep linux
apt-get install gcc-multilib
apt-get install xz-utils
  下載源碼:
  Xen 4.0.1http://bits.xensource.com/oss-xen/release/4.0.1/xen-4.0.1.tar.gz
  Linux Kernel 2.6.38.4http://www.kernel .org/pub/linux/kernel/v2.6/linux-2.6.38.4.tar.gz

  還需要下載內核的xen補丁:
  xen-patches-2.6.38-2http://gentoo-xen-kernel.googlecode.com/files/xen-patches-2.6.38-2.tar.bz2

  將所有包移動到/usr/src後展開各個包:

sudo tar zxvf linux-2.6.38.4.tar.gz
sudo tar zxvf xen-4.0.1.tar.gz
sudo mkdir xen-patches
cd xen-patches
tar jxvf ../xen-patches-2.6.38-2.tar.bz2
  進入linux-2.6.38.4目錄,打上補丁:

sudo cat ../xen-patches/*.patch1 | patch -p1
二、編譯Xen

make xen tools stubdom
make install-xen
make install-tools PYTHON_PREFIX_ARG=
make install-stubdom
  在編譯的過程中可能會遇到如下問題:

In file included from tapdisk.h:62:0,
from blk_linux.c:4:
../lib/blktaplib.h:199:0: error: "WRITE" redefined
/usr/include/linux/fs.h:160:0: note: this is the location of the previous definition
  這個問題請打補丁:blk_linux.patch1

netfront.c:41:32: error: variably modified 'tx_freelist' at file scope
netfront.c:44:34: error: variably modified 'rx_buffers' at file scope
netfront.c:45:34: error: variably modified 'tx_buffers' at file scope
lib/math.c: In function '__qdivrem':
lib/math.c:196:9: error: 'tmp.ul[1]' may be used uninitialized in this function
mm.c: In function 'set_readonly':
mm.c:321:46: error: taking address of expression of type 'void'
  這個問題請打補丁:gcc-4.5.patch1

  如果使用xm命令報以下錯誤:

AttributeError: HTTPUnix instance has no attribute 'getresponse'
  請打補丁:xmlrpc.patch1

三、編譯內核

  先準備一個編譯配置,可以下載我使用的配置.config,執行make menuconfig命令,配置好內核參數後,保存配置文件,之後就可以開始編譯了:

sudo make
sudo make install
sudo make modules_install
sudo update-initramfs -c -k 2.6.38.4
sudo depmod 2.6.38.4
  將Xen的內核模塊加入/etc/modules文件,使系統啟動時自動加載:

sudo vi /etc/modules
...
netbk
blkbk
blktap
四、修改grub

  Ubuntu 11.04 使用了Grub2,Grub2Xen是不兼容的,於是將grub2降級到grub

sudo apt-get purge grub-pc
sudo rm /boot/grub/*
sudo apt-get install grub
sudo grub-install --recheck /dev/sda
sudo update-grub
  手動添加啟動菜單,/boot/grub/menu.lst中添加以下內容:

title Xen 4.0.1 / Linux 2.6.38.4
kernel /boot/xen-4.0.gz
module /boot/vmlinuz-2.6.38.4 root=[root-location] ro cnsole=tty0
module /boot/initrd.img-2.6.38.4
  重啟,不出意外的話xen應該是啟動了,可以使用以下命令查看:

ps -ef | grep xend
xm list