CentOS6.4 X86_64最小化安装  VMware9.0环境  内核版本为3.2.63   Xen版本为4.4.1(也可以安装xen4.2)

安装Xen需要的包

常用的包


yum install gcc gcc-c++ vim wget lrzsz ntpdate sysstat dstat wget man tree -y


开发环境



yum groupinstall "Development tools" "Compatibility libraries" -y
 
  
其他安装包
yum install transfig wget texi2html libaio-devel dev86 glibc-devel e2fsprogs-devel gitk mkinitrd iasl xz-devel bzip2-devel pciutils-libs pciutils-devel SDL-devel libX11-devel gtk2-devel bridge-utils PyXML qemu-common qemu-img mercurial texinfo libuuid-devel openssl-devel python-twisted python python-devel ncurses-devel hmaccalc  zlib-devel libtool-ltdl yajl yajl-devel readline-devel gcc-gfortran flex pcre-devel  blas-devel lapack-devel curl-devel bison gperf gnuplot texinfo-tex tetex-dvips libvirt git -y
与桌面有关的包,没有用桌面就不用装了
yum install xorg-x11-drv-evdev xorg-x11-drv-fbdev xorg-x11-drv-i810-devel xorg-x11-drv-via-devel xorg-x11-proto-devel xorg-x11-server-sdk xorg-x11-xtrans-devel libuuid-devel -y

Xen4.4.1下载且安装

关闭selinux步骤省略

#Xen下载页面http://www.xenproject.org/downloads/xen-archives/xen-44-series/xen-441.html  

xen4.4只有xl控制工具,xen4.2的话可以用xl或xm,如果常用xm,就安装xen4.2

http://www.xenproject.org/downloads/xen-archives/supported-xen-42-series/xen-425.html



wget http://bits.xensource.com/oss-xen/release/4.4.1/xen-4.4.1.tar.gz
tar -xzf xen-4.4.1.tar.gz
cd xen-4.4.1
./configure
make -j4 xen tools stubdom
make install-xen install-tools install-stubdom
#Xen配置文件 /etc/sysconfig/xendomains
/sbin/chkconfig --add xencommons
/sbin/chkconfig --add xendomains
/sbin/chkconfig xendomains on
/sbin/chkconfig xencommons on
# chkconfig --add xend      #安装xen4.2才需要添加
/sbin/chkconfig xend on
 
  

编译内核
编译linux长期维护版内核linux-3.2.63   
wget https://www.kernel.org/pub/linux/kernel/v3.x/linux-3.2.63.tar.xz
tar xf linux-3.2.63.tar.xz 
cd linux-3.2.63              #编译安装后此文件夹为5.4G,请提前准备磁盘空间
make menuconfig
1,进入 Processor type and features  ---> Paravirtualized guest support  --->[*]   Xen guest support

centos7 源码包安装内核 centos7编译安装内核_git

centos7 源码包安装内核 centos7编译安装内核_centos7 源码包安装内核_02

2,进入Device Drivers  ---> Block devices  --->  <*>   Xen virtual block device support
                                                                         <*>   Xen block-device backend driver 
           Device Drivers  --->Xen driver support  把下面的都选上

centos7 源码包安装内核 centos7编译安装内核_git_03

centos7 源码包安装内核 centos7编译安装内核_python_04


3, Device Drivers  ---> Network device support  ---> <*>   Xen network device frontend driver
                                                                                   <*>   Xen backend network device

centos7 源码包安装内核 centos7编译安装内核_Xen_05

保存并开始安装

# cat .config |grep XEN
CONFIG_XEN=y
CONFIG_XEN_DOM0=y
CONFIG_XEN_PRIVILEGED_GUEST=y
CONFIG_XEN_PVHVM=y
CONFIG_XEN_MAX_DOMAIN_MEMORY=128
CONFIG_XEN_SAVE_RESTORE=y
CONFIG_XEN_DEBUG_FS=y
CONFIG_PCI_XEN=y
CONFIG_XEN_PCIDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_FRONTEND=y
CONFIG_XEN_BLKDEV_BACKEND=y
CONFIG_NETXEN_NIC=m
CONFIG_XEN_NETDEV_FRONTEND=y
CONFIG_XEN_NETDEV_BACKEND=y
CONFIG_INPUT_XEN_KBDDEV_FRONTEND=y
CONFIG_HVC_XEN=y
# CONFIG_XEN_WDT is not set
CONFIG_XEN_FBDEV_FRONTEND=y
CONFIG_XEN_BALLOON=y
CONFIG_XEN_BALLOON_MEMORY_HOTPLUG=y
CONFIG_XEN_SCRUB_PAGES=y
CONFIG_XEN_DEV_EVTCHN=y
CONFIG_XEN_BACKEND=y
CONFIG_XENFS=y
CONFIG_XEN_COMPAT_XENFS=y
CONFIG_XEN_SYS_HYPERVISOR=y
CONFIG_XEN_XENBUS_FRONTEND=y
CONFIG_XEN_GNTDEV=y
CONFIG_XEN_GRANT_DEV_ALLOC=y
CONFIG_SWIOTLB_XEN=y
CONFIG_XEN_PCIDEV_BACKEND=y
 
  

 
  
make -j4 bzImage
make -j4 modules
make -j4 modules_install
make -j4 install
#sh /root/linux-3.2.63/arch/x86/boot/install.sh 3.2.63 arch/x86/boot/bzImage \
#System.map "/boot"
#ERROR: modinfo: could not find module vmware_balloon  #这个错误可以忽略不管
 
  
cp -a .config /boot/config-3.2.63
depmod -a
cat > /etc/ld.so.conf.d/libxl.conf <<eof
/usr/local/lib
eof
# ldconfig -v|grep libxl  #安装xen4.4的结果
        libxlutil.so.4.3 -> libxlutil.so.4.3.0
# ldconfig -v|grep libxl  #安装xen4.4的结果
	libxlutil.so.1.0 -> libxlutil.so.1.0.1
 
  
修改grub.conf
vim /boot/grub/grub.conf 
default=0
timeout=5
splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title   (3.2.63.centos.alt.x86_64)
root (hd0,0)
kernel /xen.gz dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
module /vmlinuz-3.2.63 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
module /initramfs-3.2.63.img
#default=1
#timeout=5
#splashp_w_picpath=(hd0,0)/grub/splash.xpm.gz
#hiddenmenu
#title CentOS (3.2.63)
#root (hd0,0)
#kernel /vmlinuz-3.2.63 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
#initrd /initramfs-3.2.63.img
title CentOS (2.6.32-358.el6.x86_64)
root (hd0,0)
kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
initrd /initramfs-2.6.32-358.el6.x86_64.img

# ls /boot/
config-2.6.32-358.el6.x86_64            symvers-2.6.32-358.el6.x86_64.gz       xen-4.4.1.gz
config-3.2.63                                   System.map                                      xen-4.4.gz
efi                                                   System.map-2.6.32-358.el6.x86_64     xen-4.gz
grub                                                System.map-3.2.63                            xen.gz
initramfs-2.6.32-358.el6.x86_64.img  vmlinuz                                             xen-syms-4.4.1
initramfs-3.2.63.img                         vmlinuz-2.6.32-358.el6.x86_64
lost+found                                      vmlinuz-3.2.63

编译安装完成后重启进入系统
查看Xen版本
[root@localhost ~]# xl info
host                   : localhost.localdomain
release                : 3.2.63
version                : #1 SMP Tue Oct 14 20:21:53 CST 2014
machine                : x86_64
nr_cpus                : 4
max_cpu_id             : 63
nr_nodes               : 1
cores_per_socket       : 1
threads_per_core       : 1
cpu_mhz                : 3392
hw_caps                : 0fabfbff:28100800:00000000:00007f00:b4ba2223:00000000:00000001:00000281
virt_caps              : hvm
total_memory           : 2047
free_memory            : 998
sharing_freed_memory   : 0
sharing_used_memory    : 0
outstanding_claims     : 0
free_cpus              : 0
xen_major              : 4
xen_minor              : 4
xen_extra              : .1
xen_version            : 4.4.1
xen_caps               : xen-3.0-x86_64 xen-3.0-x86_32p hvm-3.0-x86_32 hvm-3.0-x86_32p hvm-3.0-x86_64 
xen_scheduler          : credit
xen_pagesize           : 4096
platform_params        : virt_start=0xffff800000000000
xen_changeset          : 
xen_commandline        : dom0_mem=1024M,max:1024M loglvl=all guest_loglvl=all
cc_compiler            : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-4)
cc_compile_by          : root
cc_compile_domain      : 
cc_compile_date        : Tue Oct 14 17:59:32 CST 2014
xend_config_format     : 4


centos7 源码包安装内核 centos7编译安装内核_开发工具_06

ok,Xen安装完成,开始你的虚拟化吧


另,如果安装是xen4.2的版本,需要将xend服务加为开机启动,下面是xen4.2的截图

centos7 源码包安装内核 centos7编译安装内核_开发工具_07


结论,编译安装xen,然后升级内核,系统重启的时候有提示

XENBUS: Unable to read cpu state
NMI watchdog disabled (cpu0): hardware events not enabled installing Xen timer for CPU

只是单纯的编译内核还是行不通的,留着以后改@


https://blog.51cto.com/bbotte/1564187