Centos上源码安装xen-4.8.0

    xiaoxiao2021-03-25  138

    安装dom0内核

    wget https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.10.1.tar.xz tar zxf linux-4.10.1.tar.xz cd linux-3.18.18 make menuconfig

    参考:https://wiki.xen.org/wiki/Mainline_Linux_Kernel_Configs

    (修改.config文件)

    Configuring the Kernel for domU Support

    If building x86 32 bit kernel make sure you have CONFIG_X86_PAE enabled (which is set by selecting CONFIG_HIGHMEM64G) non-PAE mode doesn't work in 2.6.25, and has been dropped altogether from 2.6.26 and newer kernel versions.For x86 , enable these core options (Processor type and features| Paravirtualized guest support] CONFIG_HYPERVISOR_GUEST=y (3.10+ only)CONFIG_PARAVIRT=yCONFIG_XEN=yCONFIG_PARAVIRT_GUEST=yCONFIG_PARAVIRT_SPINLOCKS=yFor ARM, enable these core options (Kernel Features) CONFIG_XEN=yCONFIG_PARAVIRT=yAnd Xen pv console device support (Device Drivers|Character devices CONFIG_HVC_DRIVER=yCONFIG_HVC_XEN=yAnd Xen disk and network support (Device Drivers|Block devices and Device Drivers|Network device support) CONFIG_XEN_FBDEV_FRONTEND=yCONFIG_XEN_BLKDEV_FRONTEND=yCONFIG_XEN_NETDEV_FRONTEND=yAnd the rest (Device Drivers|Xen driver support) CONFIG_XEN_PCIDEV_FRONTEND=yCONFIG_INPUT_XEN_KBDDEV_FRONTEND=yCONFIG_XEN_FBDEV_FRONTEND=yCONFIG_XEN_XENBUS_FRONTEND=yCONFIG_XEN_SAVE_RESTORE=yCONFIG_XEN_GRANT_DEV_ALLOC=mAnd for tmem support (x86 only): CONFIG_XEN_TMEM=yCONFIG_CLEANCACHE=yCONFIG_FRONTSWAP=yCONFIG_XEN_SELFBALLOONING=y

    Configuring the Kernel for dom0 Support

     

    NOTE: Xen dom0 support depends on ACPI support. Make sure you enable ACPI support or you won't see Dom0 options at all.

    In addition to the config options above you also need to enable:

    CONFIG_XEN_DOM0=yCONFIG_XEN_DEV_EVTCHN=yCONFIG_XENFS=yCONFIG_XEN_COMPAT_XENFS=yCONFIG_XEN_SYS_HYPERVISOR=yCONFIG_XEN_GNTDEV=yCONFIG_XEN_BACKEND=yCONFIG_XEN_NETDEV_BACKEND=mCONFIG_XEN_BLKDEV_BACKEND=mCONFIG_XEN_BALLOON=yCONFIG_XEN_SCRUB_PAGES=y

    For x86, you will also need to enable:

    CONFIG_X86_IO_APIC=yCONFIG_ACPI=yCONFIG_ACPI_PROCFS=y (optional)CONFIG_PCI_XEN=yCONFIG_XEN_PCIDEV_BACKEND=m

    If you're using RHEL5 or CentOS5 as a dom0 (ie. you have old udev version), make sure you enable the following options as well:

    CONFIG_SYSFS_DEPRECATED=yCONFIG_SYSFS_DEPRECATED_V2=y

    For more current Xen related config options check the example .config files from the troubleshooting section, and check the 2.6.18-to-2.6.31-and-higher wiki page.

    $ make all -j <2*number_of_cores>

    安装需要的软件包

    yum install -y gcc gcc-c++ git patch texinfo python-devel acpica-tools libuuid-devel ncurses-devel glib2 glib2-devel libaio-devel openssl-devel yajl-devel glibc-devel glibc-devel.i686 pixman-devel bc rpm -ivh  http://mirror.centos.org/centos/6/os/x86_64/Packages/dev86-0.16.17-15.1.el6.x86_64.rpm

    安装Xen

    git clone git://xenbits.xen.org/xen.git

     

    cd xen/ # ./configure # make world

     

    # make install

    配置 GRUB

    grub2-mkconfig -o /etc/grub2.cfg #查看grub2.cfg相关配置 cat /etc/grub2.cfg #静态文件系统信息,定义了存储设备和分区整合到整个系统的方式 cat /etc/fstab #复制grub2.cfg里第一个引导配置到下面的文件,添加一行 multiboot /xen.gz,linux16、initrd16修改为module vi /etc/grub.d/40_custom #!/bin/sh exec tail -n +3 $0 # This file provides an easy way to add custom menu entries. Simply type the # menu entries you want to add after this comment. Be careful not to change # the 'exec tail' line above. menuentry 'CentOS Linux 7 (Core), with Linux 3.18.18 Xen' --class centos --class gnu-linux --class gnu --class os --unrestricted $menuentry_id_option 'gnulinux-3.18.18-advanced-dfad9c15-962d-492d-b83a-31d22a5f0eec' { load_video insmod gzio insmod part_msdos insmod xfs set root='hd0,msdos1' if [ x$feature_platform_search_hint = xy ]; then search --no-floppy --fs-uuid --set=root --hint-bios=hd0,msdos1 --hint-efi=hd0,msdos1 --hint-baremetal=ahci0,msdos1 --hint='hd0,msdos1' 8089210c-1bb3-4589-b18d-cc5b2b97774e else search --no-floppy --fs-uuid --set=root 8089210c-1bb3-4589-b18d-cc5b2b97774e fi multiboot /xen.gz module /vmlinuz-3.18.18 root=/dev/mapper/centos-root ro rd.lvm.lv=centos/root rd.lvm.lv=centos/swap crashkernel=auto rhgb quiet module /initramfs-3.18.18.img } #重新生成菜单 grub2-mkconfig -o /etc/grub2.cfg

     

    可能出现的错误和解决办法

     

    重启后,选择 CentOS Linux, with Linux 3.15.4 Xen 进入 Xen 系统,使用 xl info 命令发现有错,这是因为 Xen 相关的软件库被安装到了 /usr/local/lib 目录,系统找不到。所以做一些链接就可以了:

    xl info xl: error while loading shared libraries: libxlutil.so.4.3: cannot open shared object file: No such file or directory cd /usr/lib/ ln -s /usr/local/lib/libxlutil.so.4.3.0 libxlutil.so.4.3 ln -s /usr/local/lib/libxlutil.so.4.3.0 libxlutil.so ln -s /usr/local/lib/libxenlight.so.4.5.0 libxenlight.so.4.5 ln -s /usr/local/lib/libxenlight.so.4.5.0 libxenlight.so ln -s /usr/local/lib/libxenctrl.so.4.5.0 libxenctrl.so.4.5 ln -s /usr/local/lib/libxenguest.so.4.5.0 libxenguest.so.4.5 ln -s /usr/local/lib/libxenguest.so.4.5.0 libxenguest.so ln -s /usr/local/lib/libxenstat.so.0.0 libxenstat.so.0 ln -s /usr/local/lib/libxenstat.so.0.0 libxenstat.so ln -s /usr/local/lib/libxenstore.so.3.0.3 libxenstore.so.3.0 ln -s /usr/local/lib/libxenstore.so.3.0.3 libxenstore.so ln -s /usr/local/lib/libxenvchan.so.1.0.0 libxenvchan.so.1.0 ln -s /usr/local/lib/libxenvchan.so.1.0.0 libxenvchan.so ln -s /usr/local/lib/libblktapctl.so.1.0.0 libblktapctl.so.1.0 ln -s /usr/local/lib/libblktapctl.so.1.0.0 libblktapctl.so ldconfig

     

    再次运行 xl info 发现如下问题:

     

    xl info xc: error: Could not obtain handle on privileged command interface (2 = No such file or directory): Internal error libxl: error: libxl.c:99:libxl_ctx_alloc: cannot open libxc handle: No such file or directory cannot init xl context

    是因为没有挂载 xenfs 的缘故,挂载一下就可以了:

    modprobe xenfs mount -t xenfs xenfs /proc/xen ls /proc/xen/ capabilities privcmd xenbus xsd_kva xsd_port # 一劳永逸的办法修改fstab文件 vim /etc/fstab #追加如下一行 none /proc/xen xenfs defaults 0 0

    xl info

    记得启动 xencommons:

    /etc/init.d/xencommons start #开机启动xencommons /sbin/chkconfig --add xencommons /sbin/chkconfig --add xendomains /sbin/chkconfig xendomains on /sbin/chkconfig xencommons on xl list     Name                                        ID   Mem VCPUs    State    Time(s)     Domain-0                                     0  7870     2     r-----     213.0

     

    Xen 从 4.1 版本开始引入了新版工具集 xl/libxl,并在后续的版本中逐步替代旧的 xm/xend,在 4.5 版本中已经完全删除了 xm/xend.

    每次启动菜单有很多选项,进去把除当前版本以外的删除掉

    # !!! 保留vmlinuz-3.18.18、initramfs-3.18.18.img cd /boot/ rm -fr vmlinuz-* initramfs-*.img #重新生成菜单

     

    grub2-mkconfig -o /etc/grub2.cfg

     

    参考:http://chenbaocheng.com/2015/07/16/在CentOS-7-x上源码安装Xen-4-5/

    转载请注明原文地址: https://ju.6miu.com/read-6063.html

    最新回复(0)