Copy a semi-virtualized guest from Xen Host kernel Create and start a Xen PV client

Source: Internet
Author: User

In the

Create and start a Xen semi-virtualized PV clientArticle explains how to install a semi-virtualized Xen guest OS from an Ubuntu HTTP source, the core idea is to download the client's vmlinuz and INITRD first, and then launch the Xen virtual machine and choose the Ubuntu Network source for online installation. Later, when preparing to make a few guest copies, it was found that the guest installed in the logical volume was difficult to replicate (temporarily unaware, mostly unaware of how to mount this logical volume, since it was again partitioned into Linux and swap formats), as seen in a LV_DOMU2 used by the virtual machine:


To facilitate the replication of multiple semi-virtualized guest, and to re-examine and experiment with the installation of guest in IMG, after installing a guest in this way, we only need to copy the guest's img and Xen configuration files.

This method is mainly for reference: Http://www.virtuatopia.com/index.php/Building_a_Xen_Virtual_Guest_Filesystem_on_a_Disk_Image_ ( Cloning_host_system). A guest is copied from the Xen host.

Prerequisite: Install Kernel-xen and xen4.5, and XL info view no problem.

1) Create root img and swap for guest

Create a 20G img for the root file system

# dd If=/dev/zero of=centos1.img bs=1m seek=20480 count=0

Then format it into the Linux 83 file system format

# mkfs-t Ext3 centos1.img

Create a 2G img for swap swap

# dd If=/dev/zero of=centos1.swap bs=1m seek=2048 count=0

Format to swap

# Mkswap Centos1.swap

2) Copy the host's root file system to the guest's root file system img

# Mkdir/tmp/loop

# Mount-o Loop Centos1.img/tmp/loop

# Cp-ax/{bin,dev,etc,lib,lib64,root,sbin,usr,var}/tmp/loop

Be very careful here!!! It is important to remember to copy the/lib64 in x86_64 because there are some libraries in the lib64 that must be linked.

Create the remaining folders

# mkdir/tmp/loop/{home,proc,opt,sys.tmp}

# chmod 777/tmp/loop/tmp

3) Modify some of the files in guest root filesystem

/tmp/loop/etc/fstab:

/DEV/XVDA1               /                       ext3    defaults 1 1/dev/xvda2               none                    swap    SW       0 0none                    /dev/pts                devpts  gid=5,mode=620 0 0none                    /dev/shm                tmpfs   defaults 0 0none                    /proc                   proc    defaults 0 0none                    /sys                    sysfs   defaults 0 0

Note The user information and host information saved in these files

/tmp/loop/etc/passwd

/tmp/loop/etc/group

/tmp/loop/etc/hosts

Modify Network Configuration

/tmp/loop/etc/sysconfig/network Modifying the hostname=centos6-1,gateway=192.168.122.1 (xenbr0 IP)

/tmp/loop/etc/sysconfig/network-scripts/ifcfg-eth0 set up an IPwith host xenbr0 on the same network segment, and remove theuuid and HWADDR, Otherwise, the hardware address of the host side is the same. Or it can be modified after connecting to the virtual machine via the console.

Exported for NFS access to remote systems files

/tmp/loop/etc/exports

Uninstall the root directory of the guest

# umount/tmp/loop/

4) Create a Xen virtual machine configuration file centos1.cfg

In order to avoid the SCSI module error, we re-generate a initrd, reference http://www.virtuatopia.com/index.php/A_Xen_Guest_OS_fails_to_boot_with_a_% 22switchroot:_mount_failed:_no_such_file_or_directory_error_message%22_error_message.:

MKINITRD--omit-scsi-modules--with=xennet--with=xenblk--preload=xenblk initrd-$ (uname-r)-no-scsi.img $ (uname-r)

Specifies the kernel file that launches the kernel as host

Kernel = "/boot/vmlinuz-3.14.42-1.el6xen.x86_84" RAMDisk = "/boot/initrd-3.14.42-1.el6xen.x86_64.img" memory = 1024name = "CENTOS1" vif = [' bridge=xenbr0 ']disk = [' tap:aio:/path/to/centos1.img,xvda1,w ', ' tap:aio:/path/to/ Centos1.swap,xvda2,w ']root = "/dev/xvda1 ro"

It is important to note that the dracut:chroot:failed to Run command '/sbin/load_policy ': No such file or directorymay be reported when the virtual machine is started, because C Lone the root file system did not copy the/lib64 to guest, refer to http://marc.info/?l=xen-users&m=135907220030809.


5) Start and console connected to the virtual machine

XL Create/path/to/centos1.cfg-c

Finally, the login prompt, using the host OS account password login can

CentOS Release 6.6 (Final)
Kernel 3.14.42-1.el6xen.x86_64 on an x86_64

CENTOS6-1 Login:


6) This allows us to clone multiple virtual machines easily by copying the root file system img and swap of the guest that has been created, and by copying and modifying a Xen client configuration file, modifying some files in the root filesystem such as fstab and network.

Copy a semi-virtualized guest from Xen Host kernel Create and start a Xen PV client

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.