本文共 2531 字,大约阅读时间需要 8 分钟。
Xen虚拟机的创建和启动
半虚拟化获取Sample Image
到Jailtime.org下载,并解压(注默认root密码为password) # tar jxvf centos.5-0.20070424.img.tar.bz2 centos.5-0.img centos.5-0.xen2.cfg centos.5-0.xen3.cfg centos.swap 当然,也可以到http://www.rpath.com/rbuilder下载 创建配置文件 参考centos.5-0.xen2.cfg和centos.5-0.xen3.cfg,其内容为: kernel = “/boot/vmlinuz-2.6.18-xen” ramdisk = “/boot/initrd-2.6.18-xen.img” memory = 256 name = “centos.5-0” dhcp = “dhcp” vif = [ ‘’ ] disk = [‘tap:aio:/home/xen/centos.5-0.img,xvda1,w’, ‘tap:aio:/home/xen/centos.swap,xvda2,w’] root = “/dev/xvda1 ro” Integrating Loadable Kernel Modules into Your Root Filesystem $ uname -r 2.6.18-xen $ su Password: ********* # mkdir -p /mnt/img # mount -o loop centos.5-0.img /mnt/img # cd /mnt/img/lib/modules # cp -r /lib/modules/`uname -r` . # ls 2.6.18-xen 修改其他的配置文件 # cat /mnt/img/etc/fstab /dev/xvda1 / ext3 defaults 1 1 /dev/xvda2 none swap sw 0 0 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0 # cat /mnt/img/etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet DEVICE=eth0 BOOTPROTO=dhcp ONBOOT=yes # cat /mnt/img/etc/network/interfaces auto lo iface lo inet loopback auto eth0 iface eth0 inet dhcp # cd / # sync # umount /mnt/img Creating Initial RAM Disks and Filesystems for Your Kernel # yaird --output initrd-2.6.18-xen.img 2.6.18-xen # mkinitramfs -o initrd-2.6.18-xen.img 2.6.18-xen # mkinitrd -o initrd-2.6.18-xen.img 2.6.18-xen 启动虚拟机 # xm create centos.5-0.xen3.cfg -c # xm list Name ID Mem(MiB) VCPUs State Time(s) Domain-0 0 1752 2 r----- 56978.8 Foresight 46 384 1 -b---- 1180.1 OpenSUSE 17 256 1 -b---- 2114.4 Ubuntu 34 256 1 -b---- 591.7 centos.5-0 45 256 1 -b---- 302.9 Freespire-HVM 49 256 1 -b---- 63.2