一、Xen高级配置

0、之前安装xen的系统内核版本,做网桥奔溃处理

0.1 需要其他版本内核,内核降级

kernel不要做升级,要做安装:
[root@node1 ~]# yum install kernel-3.18.32 kernel-firmware-3.18.32

修改grub文件:
[root@node1 ~]# vim /etc/grub.conf 
title CentOS (3.18.32-20.el6.x86_64)
        root (hd0,0)
        kernel /xen.gz dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
        module /vmlinuz-3.18.32-20.el6.x86_64 ro root=UUID=01c53735-f7c4-4294-a944-e69df17ab9cd rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 crashkernel=auto  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet
        module /initramfs-3.18.32-20.el6.x86_64.img

0.2 测试新内核

重启:
[root@node1 ~]# shutdown -r now

0.3 重新做网桥

0.3.1 拆除eth0的IP地址

0.3.2 创建桥

0.3.3 将eth0关联至br0

0.3.4 配置xenbr0的IP地址

0.3.5 添加默认网关

[root@node1 ~]# route add default gw 10.201.106.2

强制安装软件, 不理会冲突

# yum install --nodeps --force  packet

1、DomU网卡配置

1.1 创建连接虚拟机

[root@node1 ~]# xl create /etc/xen/busybox -c

1.2 给虚拟机配置网卡

配置桥接到xenbr0,其他默认:
[root@node1 ~]# vim /etc/xen/busybox 

vif = [ 'bridge=xenbr0' ]


重新创建连接:
[root@node1 ~]# xl create /etc/xen/busybox -c

默认驱动目录:
/lib/modules/2.6.32-504.el6.x86_64/kernel/drivers

1.2.1 复制驱动文件:
挂载虚拟机的磁盘文件到/mnt,进行编辑
[root@node1 ~]# mount -o loop /images/xen/busybox.img /mnt/
[root@node1 ~]# ls /mnt/
bin  boot  dev  etc  home  linuxrc  lost+found  proc  sbin  sys  usr  var

mnt创建存放驱动的目录
[root@node1 net]# mkdir -pv /mnt/lib/modules

拷贝驱动文件到/mnt/lib/modules
首先查看内核模块有没有依赖:
[root@node1 net]# modinfo xen-netfront.ko
filename:       xen-netfront.ko
alias:          xennet
alias:          xen:vif
license:        GPL
description:    Xen virtual network device frontend
srcversion:     5C6FC78BC365D9AF8135201
*depends:        
vermagic:       2.6.32-504.el6.x86_64 SMP mod_unload modversions 

8139网卡依赖mii
[root@node1 net]# modinfo 8139too.ko | grep depends
depends:        mii

查看mii位置
[root@node1 net]# modinfo mii
filename:       /lib/modules/3.18.32-20.el6.x86_64/kernel/drivers/net/mii.ko

拷贝
[root@node1 net]# cp xen-netfront.ko 8139too.ko mii.ko /mnt/lib/modules/
[root@node1 net]# sync

1.2.2 重新创建连接虚拟机
[root@node1 ~]# xl create /etc/xen/busybox -c

1.2.3 装载网卡驱动程序
/ # insmod /lib/modules/xen-netfront.ko 
Initialising Xen virtual ethernet driver.

/ # ifconfig -a
eth0      Link encap:Ethernet  HWaddr 00:16:3E:5E:67:37  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
          Interrupt:247 

Dom0查看已经有了虚拟机的网卡:
[root@node1 ~]# ifconfig | grep -A3 vif
vif1.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF  
          inet6 addr: fe80::fcff:ffff:feff:ffff/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0

网卡跟随Dom0的ID号命名:
[root@node1 ~]# xl list
Name                                        ID   Mem VCPUs	State	Time(s)
Domain-0                                     0  1024     1     r-----     123.6
busybox-001                                  2   512     1     -b----       1.2
[root@node1 ~]# ifconfig | grep -A3 vif
vif2.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 

自动添加到桥上面
[root@node1 ~]# brctl show
bridge name	bridge id		STP enabled	interfaces
xenbr0		8000.000c295d1b80	no		eth0
							vif2.0
1.2.4 配置IP
/ # ifconfig eth0 10.201.106.31 up

2、虚拟通道网络实现两台虚拟机互通,无法联通宿主机和外网

2.1 关闭删除之前的虚拟机

[root@node1 ~]# xl destroy busybox-001

2.2 复制磁盘文件、配文件,准备创建第二台虚拟机

[root@node1 ~]# cp /images/xen/busybox.img /images/xen/busybox2.img


复制编辑配置文件:
[root@node1 xen]# cp /etc/xen/busybox /etc/xen/busybox2

name = "busybox-002"
disk = [ '/images/xen/busybox2.img,raw,xvda,rw' ]

2.3 建立额外的桥设备

[root@node1 ~]# brctl addbr xenbr1
[root@node1 ~]# brctl show
bridge name	bridge id		STP enabled	interfaces
xenbr0		8000.000c295d1b80	no		eth0
xenbr1		8000.000000000000	no		

启动桥:
[root@node1 ~]# ifconfig xenbr1 up

修改虚拟主机配置:
[root@node1 ~]# vim /etc/xen/busybox

vif = [ 'bridge=xenbr1' ]

[root@node1 ~]# vim /etc/xen/busybox2

vif = [ 'bridge=xenbr1' ]

2.4 启动虚拟主机,装载配置网卡IP

[root@node1 ~]# xl create /etc/xen/busybox
[root@node1 ~]# xl create /etc/xen/busybox2

[root@node1 ~]# brctl show
bridge name	bridge id		STP enabled	interfaces
xenbr0		8000.000c295d1b80	no		eth0
xenbr1		8000.feffffffffff	no		vif3.0
							vif4.0
[root@node1 ~]# ifconfig | grep vif
vif3.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF  
vif4.0    Link encap:Ethernet  HWaddr FE:FF:FF:FF:FF:FF 

配置虚拟机1的IP:
[root@node1 ~]# xl console busybox-001

/ # insmod /lib/modules/xen-netfront.ko
/ # ifconfig eth0 10.201.106.31 up
/ # ifconfig | grep -A1 eth0
eth0      Link encap:Ethernet  HWaddr 00:16:3E:1E:72:D5  
          inet addr:10.201.106.31  Bcast:10.255.255.255  Mask:255.0.0.0

外面宿主机ping不通:
[root@node1 ~]# ping 10.201.106.31
PING 10.201.106.31 (10.201.106.31) 56(84) bytes of data.

换个IP:
/ # ifconfig eth0 10.0.11.1 up

配置虚拟机2的IP:
[root@node1 ~]# xl console busybox-002
/ # insmod /lib/modules/xen-netfront.ko
/ # ifconfig eth0 10.0.11.2 up
/ # ifconfig | grep -A1 eth0
eth0      Link encap:Ethernet  HWaddr 00:16:3E:18:6E:61  
          inet addr:10.0.11.2  Bcast:10.255.255.255  Mask:255.0.0.0

3、xl常用命令示例

3.1 虚拟机正常关机

[root@node1 ~]# xl shutdown busybox-002

3.2 查看PCI设备

[root@node1 ~]# xl pci-list busybox-002

3.3 暂停和开始虚拟机

[root@node1 ~]# xl pause busybox-002

开始虚拟机
[root@node1 ~]# xl unpause busybox-002

3.4 存储和恢复虚拟机

存储:类似挂起
[root@node1 ~]# xl save busybox-002 /tmp/busybox-002.img
Saving to /tmp/busybox-002.img new xl format (info 0x0/0x0/1328)
xc: Saving memory: iter 0 (last sent 0 skipped 0): 131072/131072  100%
[root@node1 ~]# ll -lht /tmp/busybox-002.img 
-rw-r--r-- 1 root root 514M Sep 11 20:38 /tmp/busybox-002.img


恢复:
[root@node1 ~]# xl restore /etc/xen/busybox2 /tmp/busybox-002.img
Loading new save file /tmp/busybox-002.img (new xl fmt info 0x0/0x0/1328)
 Savefile contains xl domain config
Parsing config from /etc/xen/busybox2
xc: Reloading memory pages: 131072/131072  100%

3.5 查看虚拟机运行的CPU

[root@node1 ~]# xl vcpu-list busybox-001
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
busybox-001                          5     0    1   -b-       4.9  all

固定虚拟CPU运行在哪个物理CPU上:
[root@node1 ~]# xl vcpu-pin busybox-001 0 0
[root@node1 ~]# xl vcpu-list busybox-001
Name                                ID  VCPU   CPU State   Time(s) CPU Affinity
busybox-001                          5     0    0   -b-       5.2  0


动态设置CPU使用个数(不能超过max的CPU配置个数)
[root@node1 ~]# xl vcpu-set busybox-001 1

3.6 查看xen hypervisor的摘要信息

[root@node1 ~]# xl info
host                   : node1.com
release                : 4.9.75-30.el6.x86_64
version                : #1 SMP Fri Jan 5 20:58:49 UTC 2018
machine                : x86_64
nr_cpus                : 2
max_cpu_id             : 63
nr_nodes               : 1
cores_per_socket       : 2
threads_per_core       : 1
cpu_mhz                : 1495
hw_caps                : 1fabfbff:28100800:00000000:00007f00:84ba2223:00000000:00000001:00000281
virt_caps              : hvm
total_memory           : 4095
free_memory            : 1998
sharing_freed_memory   : 0
sharing_used_memory    : 0
outstanding_claims     : 0
free_cpus              : 0
xen_major              : 4
xen_minor              : 4
xen_extra              : .4-34.el6
xen_version            : 4.4.4-34.el6
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          : Mon Dec 11 13:19:35 2017 -0600 git:91dec91-dirty
xen_commandline        : dom0_mem=1024M cpufreq=xen dom0_max_vcpus=1 dom0_vcpus_pin
cc_compiler            : gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18)
cc_compile_by          : mockbuild
cc_compile_domain      : centos.org
cc_compile_date        : Tue Dec 12 17:19:05 UTC 2017
xend_config_format     : 4

3.7 查看Dom的ID

[root@node1 ~]# xl domid busybox-001
5

通过ID查找虚拟机名字
[root@node1 ~]# xl domname 5
busybox-001

3.8 查看虚拟机启动日志

[root@node1 ~]# xl dmesg busybox-001	

3.9 查看各虚拟主机各负载情况

[root@node1 ~]# xl top

3.10 查看虚拟机网络接口信息

[root@node1 ~]# xl network-list busybox-001
Idx BE Mac Addr.         handle state evt-ch   tx-/rx-ring-ref BE-path                       
0   0  00:16:3e:72:63:a8     0     4      9   768/769         /local/domain/0/backend/vif/5/0

手动热添加网卡:
[root@node1 ~]# xl network-attach busybox-001 bridge=xenbr0
[root@node1 ~]# xl network-list busybox-001
Idx BE Mac Addr.         handle state evt-ch   tx-/rx-ring-ref BE-path                       
0   0  00:16:3e:72:63:a8     0     4      9   768/769         /local/domain/0/backend/vif/5/0
1   0  00:16:3e:02:bd:cf     1     4     10  1280/1281        /local/domain/0/backend/vif/5/1
[root@node1 ~]# 

热拆除网卡:
[root@node1 ~]# xl network-detach busybox-001 1

3.11 热插硬盘

创建虚拟磁盘文件:
[root@node1 ~]# qemu-img create -f raw -o size=5G /images/xen/busybox1.2.img

查看磁盘设备
[root@node1 ~]# xl block-list busybox-001
Vdev  BE  handle state evt-ch ring-ref BE-path                       
51712 0   8      4     8      8        /local/domain/0/backend/vbd/8/51712

添加设备:
[root@node1 ~]# xl block-attach busybox-001 '/images/xen/busybox1.2.img,raw,xvdb,w'
DEBUG libxl__blktap_devpath 76 aio:/images/xen/busybox1.2.img
DEBUG libxl__blktap_devpath 81 /dev/xen/blktap-2/tapdev2
[root@node1 ~]# xl block-list busybox-001
Vdev  BE  handle state evt-ch ring-ref BE-path                       
51712 0   10     4     8      8        /local/domain/0/backend/vbd/10/51712
51728 0   10     4     9      30       /local/domain/0/backend/vbd/10/51728

虚拟机查看:
/ # fdisk -l

Disk /dev/xvda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvda doesn't contain a valid partition table

Disk /dev/xvdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

可以正常分区:
Disk /dev/xvdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks  Id System
/dev/xvdb1               1          62      497983+ 83 Linux
/dev/xvdb2              63         185      987997+ 83 Linux

拆除硬盘:
[root@node1 ~]# xl block-detach busybox-001 51728

3.12 查看虚拟机运行时间

[root@node1 ~]# xl uptime busybox-001
Name                                ID Uptime
busybox-001                         10  0:17:13

4、使用DomU自有kernel来运行DomU

4.1 创建磁盘映像文件(这里有误,无法识别qcow2格式,直接跳到第4.4步骤)

[root@node1 ~]# qemu-img create -f qcow2 -o size=5G,preallocation=metadata /images/xen/busybox3.img
Formatting '/images/xen/busybox3.img', fmt=qcow2 size=5368709120 encryption=off cluster_size=65536 preallocation='metadata' 
4.1.1 磁盘映像文件分区
显示出所有本地已用的回环设备:
[root@node1 ~]# losetup -a

测试loop:
[root@node1 ~]# mount -o loop /images/xen/busybox.img /mnt/
[root@node1 ~]# losetup -a
/dev/loop0: [0806]:783642 (/images/xen/busybox.img)

查看第一个空间的loop设备:
[root@node1 ~]# losetup -f
/dev/loop0

手动关联上面新建的磁盘文件:
[root@node1 ~]# losetup /dev/loop0 /images/xen/busybox3.img 
[root@node1 ~]# losetup -a
/dev/loop0: [0806]:783645 (/images/xen/busybox3.img)

分区:
[root@node1 ~]# fdisk /dev/loop0
Command (m for help): p

Disk /dev/loop0: 5369 MB, 5369757696 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x9c8d6052

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1               1           7       56196   83  Linux
/dev/loop0p2               8         139     1060290   83  Linux

Command (m for help): w


[root@node1 ~]# kpartx -av /dev/loop0 
add map loop0p1 (253:0): 0 112392 linear /dev/loop0 63
add map loop0p2 (253:1): 0 2120580 linear /dev/loop0 112455
[root@node1 ~]# 

[root@node1 ~]# ls /dev/mapper/
control  loop0p1  loop0p2

格式化分区:
[root@node1 ~]# mke2fs -t ext2 /dev/mapper/loop0p1
[root@node1 ~]# mke2fs -t ext2 /dev/mapper/loop0p2

4.2 挂载上面格式的分区,存放内核

[root@node1 ~]# mkdir /mnt/{boot,sysroot}

挂载格式化好的两个文件系统:
[root@node1 ~]# mount /dev/mapper/loop0p1 /mnt/boot/
[root@node1 ~]# mount /dev/mapper/loop0p2 /mnt/sysroot/
4.2.1 拷贝内核文件
[root@node1 ~]# cp /boot/vmlinuz-2.6.32-504.el6.x86_64 /mnt/boot/vmlinuz

[root@node1 ~]# cp /boot/initramfs-2.6.32-504.el6.x86_64.img /mnt/boot/initramfs.img
4.2.2 安装grub
[root@node1 ~]# grub-install --root-directory=/mnt/ /dev/loop0
[root@node1 ~]# ls /mnt/boot/
grub  initramfs.img  lost+found  vmlinuz
4.2.3 创建grub文件
[root@node1 ~]# vim /mnt/boot/grub/grub.conf

default=0
timeout=5
title BusyBox(kernel-2.6.32)
    root (hd0,0)
    kernel /vmlinuz root=/dev/svda1 ro selinux=0 init=/bin/sh
    initrd /initramfs.img
4.2.4 复制busybox根文件系统
[root@node1 ~]# cp -a busybox-1.22.1/_install/* /mnt/sysroot/
[root@node1 ~]# ls /mnt/sysroot/
bin  linuxrc  lost+found  sbin  usr
[root@node1 ~]# 

创建其他目录:
[root@node1 sysroot]# mkdir -pv lib/modules dev proc sys etc var tmp 

复制网卡驱动:
[root@node1 sysroot]# cp /lib/modules/2.6.32-504.el6.x86_64/kernel/drivers/net/xen-netfront.ko lib/modules/
[root@node1 sysroot]# sync
4.2.5 拆除设备
卸载:
[root@node1 ~]# umount /mnt/boot/
[root@node1 ~]# umount /mnt/sysroot/

拆除:
[root@node1 ~]# kpartx -d /dev/loop0
[root@node1 ~]# ls /dev/mapper/
control

已经没了:
[root@node1 ~]# losetup -a
[root@node1 ~]# losetup -f
/dev/loop0

4.3 配置虚拟机配置文件

[root@node1 ~]# cd /etc/xen/
[root@node1 xen]# cp busybox busybox3

[root@node1 xen]# vim busybox3

#kernel = "/boot/vmlinuz"       #自用内核,不需要Dom0

#ramdisk = "/boot/initramfs.img" #自用系统文件,不需要Dom0

#extra = "selinux=0 init=/bin/sh

vif = [ 'bridge=xenbr0' ]

disk = [ '/images/xen/busybox3.img,qcow2,xvda,rw' ]
#root = "/dev/xvda ro"
bootloader = '/usr/bin/pygrub'

4.4 启动虚拟机测试

[root@node1 ~]# xl create /etc/xen/busybox3 -c

报错:磁盘映像文件问题(通过loop挂载格式这种文件系统,xen无法识别,qcow2),使用测试模式
[root@node1 ~]# xl -v create /etc/xen/busybox3 -n

只能将格式改回raw格式了,需要删除磁盘,重新创建:

[root@node1 xen]# rm -rf busybox3.img
4.4.1 创建磁盘映像文件
[root@node1 xen]# qemu-img create -f raw -o size=2G /images/xen/busybox3.img
4.4.2 关联磁盘文件为loop0设备
[root@node1 xen]# losetup /dev/loop0 /images/xen/busybox3.img 
[root@node1 xen]# losetup -a
/dev/loop0: [0806]:783469 (/images/xen/busybox3.img)
4.4.3 磁盘分区格式
[root@node1 xen]# fdisk /dev/loop0
Command (m for help): p

Disk /dev/loop0: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x6b4d69d2

      Device Boot      Start         End      Blocks   Id  System
/dev/loop0p1               1           7       56196   83  Linux
/dev/loop0p2               8         139     1060290   83  Linux

Command (m for help): w

[root@node1 xen]# kpartx -av /dev/loop0
add map loop0p1 (253:0): 0 112392 linear /dev/loop0 63
add map loop0p2 (253:1): 0 2120580 linear /dev/loop0 112455


[root@node1 xen]# ls /dev/mapper/
control  loop0p1  loop0p2

[root@node1 xen]# mke2fs -t ext2 /dev/mapper/loop0p1
[root@node1 xen]# mke2fs -t ext2 /dev/mapper/loop0p2
4.4.4 挂载分区
[root@node1 xen]# mount /dev/mapper/loop0p1 /mnt/boot/
[root@node1 xen]# mount /dev/mapper/loop0p2 /mnt/sysroot/
4.4.5 复制内核文件和根文件
[root@node1 xen]# cp /boot/vmlinuz-2.6.32-504.el6.x86_64 /mnt/boot/vmlinuz

[root@node1 xen]# cp /boot/initramfs-2.6.32-504.el6.x86_64.img /mnt/boot/initramfs.img

复制busybox文件:
[root@node1 ~]# cp -a busybox-1.22.1/_install/* /mnt/sysroot/

创建驱动目录:
[root@node1 sysroot]# mkdir lib/modules -pv

复制网卡驱动:
[root@node1 ~]# modinfo xen-netfront | grep filename
filename:       /lib/modules/4.9.75-30.el6.x86_64/kernel/drivers/net/xen-netfront.ko
[root@node1 ~]# cp /lib/modules/4.9.75-30.el6.x86_64/kernel/drivers/net/xen-netfront.ko /mnt/sysroot/lib/modules/

创建其他系统目录:
[root@node1 sysroot]# mkdir -pv dev proc sys tmp var home boot
[root@node1 sysroot]# sync
4.4.6 测试磁盘能否识别
测试:
开启之前的虚拟机,看能否加载busybox3的磁盘
[root@node1 ~]# xl block-attach busybox-001 '/images/xen/busybox3.img,raw,xvdb' 

可以正常识别:
/ # fdisk -l

Disk /dev/xvda: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvda doesn't contain a valid partition table

Disk /dev/xvdb: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

    Device Boot      Start         End      Blocks  Id System
/dev/xvdb1               1           7       56196  83 Linux
/dev/xvdb2               8         139     1060290  83 Linux


测试挂载正常:
/ # mount /dev/xvdb1 /etc
EXT2-fs warning: mounting unchecked fs, running e2fsck is recommended
/ # ls /etc/
initramfs.img  lost+found     vmlinuz
卸载:
/ # umount /etc

拆除硬盘:
[root@node1 ~]# xl block-list busybox-001
Vdev  BE  handle state evt-ch ring-ref BE-path                       
51712 0   14     4     8      8        /local/domain/0/backend/vbd/14/51712
51728 0   14     4     9      30       /local/domain/0/backend/vbd/14/51728
[root@node1 ~]# xl block-detach busybox-001 51728
4.4.7 安装grub
[root@node1 ~]# grub-install --root-directory=/mnt /dev/loop0

[root@node1 ~]# ls /mnt/boot/grub/
device.map     ffs_stage1_5      minix_stage1_5     stage2           xfs_stage1_5
e2fs_stage1_5  iso9660_stage1_5  reiserfs_stage1_5  ufs2_stage1_5
fat_stage1_5   jfs_stage1_5      stage1             vstafs_stage1_5
4.4.8 编辑grub文件
[root@node1 ~]# vim /mnt/boot/grub/grub.conf

default=0
timeout=5
title BusyBox(kernel-2.6.32)
    root (hd0,0)
    kernel /vmlinuz root=/dev/xvda1 ro selinux=0 init=/bin/sh
    initrd /initramfs.img

同步
[root@node1 ~]# sync
4.4.9 确认配置文件
[root@node1 ~]# vim /etc/xen/busybox3

	[root@node1 xen]# cp busybox busybox3
	
	[root@node1 xen]# vim busybox3
	
	#kernel = "/boot/vmlinuz"       #自用内核,不需要Dom0
	
	#ramdisk = "/boot/initramfs.img" #自用系统文件,不需要Dom0
	
	#extra = "selinux=0 init=/bin/sh
	
	vif = [ 'bridge=xenbr0' ]
	
	disk = [ '/images/xen/busybox3.img,raw,xvda,rw' ]
	#root = "/dev/xvda ro"
	bootloader = '/usr/bin/pygrub'
4.4.10 拆除设备
卸载:
[root@node1 ~]# umount /mnt/boot/
[root@node1 ~]# umount /mnt/sysroot/

拆除:
[root@node1 ~]# kpartx -d /dev/loop0
[root@node1 ~]# ls /dev/mapper/
control

已经没了:
[root@node1 ~]# losetup -d
[root@node1 ~]# losetup -a
[root@node1 ~]# losetup -f
/dev/loop0
4.4.11 启动虚拟机测试
[root@node1 ~]# xl create /etc/xen/busybox3 -c