{ "created": "2015-12-20T19:56:41Z", "hierarchy": [ { "name": "ROOT", "type": "folder", "uri": "/ROOT" }, { "name": "Xen Notes", "type": "article", "uri": "Xen_Notes" } ], "html": "\n\n \n \n \n \n\n \n \n\n \n \n \n \n \n\n Xen Notes\n\n \n \n \n \n
\n
\n \n
\n
\n \n \n\n\n

Xen Notes

\n\n

Background

\n\n

Glossary

\n

Not meant to be complete.

\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n
TermExplanation
Type I HypervisorRuns directly on hardware. Virtual machines don’t know they’re virtualized.
Type II HypervisorHypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines ‘‘know’’ they’re being run in a virtual environment
HVM (“Hardware Virtual Machine” or “Hardware-assisted Virtualization”)Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows “complete simulation of underlying hardware.” VMs don’t know they’re virtualized.
dom0The hypervisor itself
domUA single virtual instance
xmXen-provided tool to manage domU’s
virshA Red Hat-designed shell to manage VM’s. Differs from xm in that it can manage QEMU and HVM-based domU’s as well since it’s based on the libvirt API.
virt-install and virt-managerManagement and provisioning tools based on libvirt/
\n

Installation

\n
yum groupinstall Xen  \nyum install python-virtinst qemu*\n
\n

The first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.

\n

The First VM

\n

Preparing the dom0

\n\n

Creating the VM

\n

virt-manager is the easiest way to do things. You can do a\ncommand-line install via virt-install. Here’s a sample command that\ncreates a 64-bit VM called “devel1” running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.

\n
virt-install \\  \n--name=devel1 \\  \n--arch=x86_64 \\  \n--vcpus=2 --check-cpu \\  \n--ram=1200 \\  \n--disk path=/dev/xenspace/devel1 \\  \n--mac=00:0C:29:1A:98:D5 \\  \n--os-type=linux \\  \n--os-variant=rhel6 \\  \n--location=http://hypervisor.example.com/install/6/x86_64/ \\  \n--debug \\  \n--nographics\n
\n

Once the VM is installed, it’s a good idea to save the kickstart files.\nHere’s a sample:

\n
# Modified by Nikhil Anand \ninstall\nurl --url http://hypervisor.example.com/install/6/x86_64/\nlang en_US.UTF-8\nkeyboard us\nnetwork --device eth0 --bootproto dhcp\nrootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\nfirewall --enabled --port=22:tcp\nauthconfig --enableshadow --enablemd5\nselinux --enforcing\ntimezone --utc America/Chicago\nbootloader --location=mbr --driveorder=xvda\n# The following is the partition information you requested\n# Note that any partitions you deleted are not expressed\n# here so unless you clear all partitions first, this is\n# not guaranteed to work\nclearpart --linux --drives=xvda\npart /boot --fstype ext3 --size=100 --ondisk=xvda\npart pv.6 --size=0 --grow --ondisk=xvda\nvolgroup VolGroup00 --pesize=32768 pv.6\nlogvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\nlogvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n%packages\n@base\n@core\nkeyutils\niscsi-initiator-utils\ntrousers\nfipscheck\ndevice-mapper-multipath\n
\n

If you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:

\n
-x "ks=http://hypervisor.example.com/kickstarts/centos-6.ks"\n
\n

HVM Support

\n

You can find if your processor supports HVM by issuing

\n
egrep '^flags.*(vmx|svm)' /proc/cpuinfo\n
\n

Network Topologies

\n

Xen offers the following:

\n\n

It’s unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The brctl command is used to manage\nnetwork bridges.

\n

In our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn’t have to do anything other than specify\nthe MAC address in a domU’s config:

\n
vif = [ "mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge" ]\n
\n

More exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (vif’s), with public and private IPs. In this\ncase, the route and iptables commands become important, since you’ll\nhave to set up routes and masquerading.

\n

Edit /etc/xen/xend-config.sxp to set up these configs. For instance,\nif you only had a routed config, you’d comment out every other\nnetwork-script and vif-script other than these:

\n
#(network-script network-route)  \n#(vif-script     vif-route)\n
\n

PyGRUB

\n

virt-install removes the kernel and ramdisk lines from a domU’s\nconfig file and adds this instead:

\n
bootloader = "/usr/bin/pygrub"\n
\n

PyGRUB itself will look for the first partition or LVM container that\ncontain the kernel and init image.

\n

I made an error of using the CentOS project-supplied kernel and\nramdisk, which\nwere good for an install, but useless when the domU was rebooted.\nThey’re built specifically for installation :)

\n

“Could not connect to localhost:8000”

\n

You may see this when using virt-install or virt-manager. Edit\n/etc/xen/xend-config.sxp and make sure these lines are uncommented:

\n
(xend-http-server yes)  \n(xend-port 8000)  \n(xend-address localhost)\n
\n

And restart the Xen daemon.

\n

Logging

\n

You’re supposed to be able to edit /etc/sysconfig/xend, uncomment this\nline and see logs in /var/log/xen/console

\n
XENCONSOLED_LOG_DIR=/var/log/xen/console\n
\n

Didn’t work for me.

\n

Miscellaneous

\n

“Guest name already in use”

\n
virsh undefine <guestname>\n
\n\n\n\n
\n \n
\n \n \n \n \n \n\n", "id": "aa41cbc3-0f38-5499-ac88-1b20ed06e2e4", "modified": "2022-06-13T23:23:48Z", "revisions": [ { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2022-06-13T23:23:48Z", "id": "6be928c4c8de048934c03e3c61539c9ceec7d59a", "shortId": "6be928c4", "subject": "Update config.yml", "content": "Background\n----------\n\n* Vanilla installation of Xen v3.0.3 on `hypervisor.example.com`.\n All defaults.\n* Platform is CentOS 5. Paravirtualization [is not supported on CentOS\n 6](https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37151).\n It's possible to [make it work](http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization),\n but I think you should get a newer processor and run KVM if using\n CentOS 6 to save yourself the trouble.\n\nGlossary\n--------\n\nNot meant to be complete.\n\n\n| Term | Explanation |\n|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Type I Hypervisor | Runs directly on hardware. Virtual machines don't know they're virtualized. |\n| Type II Hypervisor | Hypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines ''know'' they're being run in a virtual environment |\n| HVM (\"Hardware Virtual Machine\" or \"Hardware-assisted Virtualization\") | Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows \"complete simulation of underlying hardware.\" VMs don't know they're virtualized. |\n| `dom0` | The hypervisor itself |\n| `domU` | A single virtual instance |\n| `xm` | Xen-provided tool to manage domU's |\n| `virsh` | A Red Hat-designed shell to manage VM's. Differs from `xm` in that it can manage QEMU and HVM-based domU's as well since it's based on the `libvirt` API. |\n| `virt-install` and `virt-manager` | Management and provisioning tools based on `libvirt`/ |\n\nInstallation\n------------\n\n yum groupinstall Xen \n yum install python-virtinst qemu*\n\nThe first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.\n\nThe First VM\n------------\n\n### Preparing the `dom0`\n\n* My VMs will be running CentOS 6. So I\n [downloaded](http://mirror.anl.gov/pub/centos/6/isos/) and\n loop-mounted the latest CentOS 6 ISO. I then offered the mount via\n HTTP for VM installation.\n* I then created logical volumes for use as storage by the VMs. You\n can [also format and use disk\n images](http://www.chrisabernethy.com/how-to-resize-a-xen-virtual-disk/).\n\n### Creating the VM\n\n`virt-manager` is the easiest way to do things. You can do a\ncommand-line install via `virt-install`. Here's a sample command that\ncreates a 64-bit VM called \"devel1\" running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.\n\n virt-install \\ \n --name=devel1 \\ \n --arch=x86_64 \\ \n --vcpus=2 --check-cpu \\ \n --ram=1200 \\ \n --disk path=/dev/xenspace/devel1 \\ \n --mac=00:0C:29:1A:98:D5 \\ \n --os-type=linux \\ \n --os-variant=rhel6 \\ \n --location=http://hypervisor.example.com/install/6/x86_64/ \\ \n --debug \\ \n --nographics\n\nOnce the VM is installed, it's a good idea to save the kickstart files.\nHere's a sample:\n\n # Modified by Nikhil Anand \n install\n url --url http://hypervisor.example.com/install/6/x86_64/\n lang en_US.UTF-8\n keyboard us\n network --device eth0 --bootproto dhcp\n rootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\n firewall --enabled --port=22:tcp\n authconfig --enableshadow --enablemd5\n selinux --enforcing\n timezone --utc America/Chicago\n bootloader --location=mbr --driveorder=xvda\n # The following is the partition information you requested\n # Note that any partitions you deleted are not expressed\n # here so unless you clear all partitions first, this is\n # not guaranteed to work\n clearpart --linux --drives=xvda\n part /boot --fstype ext3 --size=100 --ondisk=xvda\n part pv.6 --size=0 --grow --ondisk=xvda\n volgroup VolGroup00 --pesize=32768 pv.6\n logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\n logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n %packages\n @base\n @core\n keyutils\n iscsi-initiator-utils\n trousers\n fipscheck\n device-mapper-multipath\n\nIf you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:\n\n -x \"ks=http://hypervisor.example.com/kickstarts/centos-6.ks\"\n\nHVM Support\n-----------\n\nYou can find if your processor supports HVM by issuing\n\n egrep '^flags.*(vmx|svm)' /proc/cpuinfo\n\nNetwork Topologies\n------------------\n\nXen offers the following:\n\n* Bridged\n* NAT-ted\n* Routed\n\nIt's unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The `brctl` command is used to manage\nnetwork bridges.\n\nIn our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn't have to do anything other than specify\nthe MAC address in a domU's config:\n\n vif = [ \"mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge\" ]\n\nMore exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (`vif`'s), with public and private IPs. In this\ncase, the `route` and `iptables` commands become important, since you'll\nhave to set up routes and masquerading.\n\nEdit `/etc/xen/xend-config.sxp` to set up these configs. For instance,\nif you only had a routed config, you'd comment out every other\n`network-script` and `vif-script` other than these:\n\n #(network-script network-route) \n #(vif-script     vif-route)\n\nPyGRUB\n------\n\n`virt-install` removes the `kernel` and `ramdisk` lines from a domU's\nconfig file and adds this instead:\n\n bootloader = \"/usr/bin/pygrub\"\n\nPyGRUB itself will look for the [*first partition or LVM container* that\ncontain the kernel and init image](http://wiki.xen.org/xenwiki/PyGrub).\n\nI made an error of using the [CentOS project-supplied kernel and\nramdisk](http://mirror.centos.org/centos/5/os/x86_64/images/xen/), which\nwere good for an install, but useless when the domU was rebooted.\nThey're built specifically for installation :)\n\n\"Could not connect to localhost:8000\"\n-------------------------------------\n\nYou may see this when using `virt-install` or `virt-manager`. Edit\n`/etc/xen/xend-config.sxp` and make sure these lines are uncommented:\n\n (xend-http-server yes) \n (xend-port 8000) \n (xend-address localhost)\n\nAnd restart the Xen daemon.\n\nLogging\n-------\n\nYou're supposed to be able to edit `/etc/sysconfig/xend`, uncomment this\nline and see logs in `/var/log/xen/console`\n\n XENCONSOLED_LOG_DIR=/var/log/xen/console\n\nDidn't work for me.\n\nMiscellaneous\n-------------\n\n### \"Guest name already in use\"\n\n virsh undefine \n\n* A [nice quickstart](http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool#Saving_and_Restoring_Xen_Guest_Systems)\n to administering Xen guests with `xm`.\n* SPICE is [supposed to be better than VNC](http://zee-nix.blogspot.com/2011/06/welcome-to-virtual-world.html)\n to remote into guests.\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-27T07:27:56Z", "id": "5a5b1a32f41081d062ab86f8869a961bcad79668", "shortId": "5a5b1a32", "subject": "Fix Markdown conversion\n\nSaw half a season of The Office\n", "content": "Background\n----------\n\n* Vanilla installation of Xen v3.0.3 on `hypervisor.example.com`.\n All defaults.\n* Platform is CentOS 5. Paravirtualization [is not supported on CentOS\n 6](https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37151).\n It's possible to [make it work](http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization),\n but I think you should get a newer processor and run KVM if using\n CentOS 6 to save yourself the trouble.\n\nGlossary\n--------\n\nNot meant to be complete.\n\n\n| Term | Explanation |\n|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Type I Hypervisor | Runs directly on hardware. Virtual machines don't know they're virtualized. |\n| Type II Hypervisor | Hypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines ''know'' they're being run in a virtual environment |\n| HVM (\"Hardware Virtual Machine\" or \"Hardware-assisted Virtualization\") | Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows \"complete simulation of underlying hardware.\" VMs don't know they're virtualized. |\n| `dom0` | The hypervisor itself |\n| `domU` | A single virtual instance |\n| `xm` | Xen-provided tool to manage domU's |\n| `virsh` | A Red Hat-designed shell to manage VM's. Differs from `xm` in that it can manage QEMU and HVM-based domU's as well since it's based on the `libvirt` API. |\n| `virt-install` and `virt-manager` | Management and provisioning tools based on `libvirt`/ |\n\nInstallation\n------------\n\n yum groupinstall Xen \n yum install python-virtinst qemu*\n\nThe first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.\n\nThe First VM\n------------\n\n### Preparing the `dom0`\n\n* My VMs will be running CentOS 6. So I\n [downloaded](http://mirror.anl.gov/pub/centos/6/isos/) and\n loop-mounted the latest CentOS 6 ISO. I then offered the mount via\n HTTP for VM installation.\n* I then created logical volumes for use as storage by the VMs. You\n can [also format and use disk\n images](http://www.chrisabernethy.com/how-to-resize-a-xen-virtual-disk/).\n\n### Creating the VM\n\n`virt-manager` is the easiest way to do things. You can do a\ncommand-line install via `virt-install`. Here's a sample command that\ncreates a 64-bit VM called \"devel1\" running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.\n\n virt-install \\ \n --name=devel1 \\ \n --arch=x86_64 \\ \n --vcpus=2 --check-cpu \\ \n --ram=1200 \\ \n --disk path=/dev/xenspace/devel1 \\ \n --mac=00:0C:29:1A:98:D5 \\ \n --os-type=linux \\ \n --os-variant=rhel6 \\ \n --location=http://hypervisor.example.com/install/6/x86_64/ \\ \n --debug \\ \n --nographics\n\nOnce the VM is installed, it's a good idea to save the kickstart files.\nHere's a sample:\n\n # Modified by Nikhil Anand \n install\n url --url http://hypervisor.example.com/install/6/x86_64/\n lang en_US.UTF-8\n keyboard us\n network --device eth0 --bootproto dhcp\n rootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\n firewall --enabled --port=22:tcp\n authconfig --enableshadow --enablemd5\n selinux --enforcing\n timezone --utc America/Chicago\n bootloader --location=mbr --driveorder=xvda\n # The following is the partition information you requested\n # Note that any partitions you deleted are not expressed\n # here so unless you clear all partitions first, this is\n # not guaranteed to work\n clearpart --linux --drives=xvda\n part /boot --fstype ext3 --size=100 --ondisk=xvda\n part pv.6 --size=0 --grow --ondisk=xvda\n volgroup VolGroup00 --pesize=32768 pv.6\n logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\n logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n %packages\n @base\n @core\n keyutils\n iscsi-initiator-utils\n trousers\n fipscheck\n device-mapper-multipath\n\nIf you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:\n\n -x \"ks=http://hypervisor.example.com/kickstarts/centos-6.ks\"\n\nHVM Support\n-----------\n\nYou can find if your processor supports HVM by issuing\n\n egrep '^flags.*(vmx|svm)' /proc/cpuinfo\n\nNetwork Topologies\n------------------\n\nXen offers the following:\n\n* Bridged\n* NAT-ted\n* Routed\n\nIt's unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The `brctl` command is used to manage\nnetwork bridges.\n\nIn our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn't have to do anything other than specify\nthe MAC address in a domU's config:\n\n vif = [ \"mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge\" ]\n\nMore exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (`vif`'s), with public and private IPs. In this\ncase, the `route` and `iptables` commands become important, since you'll\nhave to set up routes and masquerading.\n\nEdit `/etc/xen/xend-config.sxp` to set up these configs. For instance,\nif you only had a routed config, you'd comment out every other\n`network-script` and `vif-script` other than these:\n\n #(network-script network-route) \n #(vif-script     vif-route)\n\nPyGRUB\n------\n\n`virt-install` removes the `kernel` and `ramdisk` lines from a domU's\nconfig file and adds this instead:\n\n bootloader = \"/usr/bin/pygrub\"\n\nPyGRUB itself will look for the [*first partition or LVM container* that\ncontain the kernel and init image](http://wiki.xen.org/xenwiki/PyGrub).\n\nI made an error of using the [CentOS project-supplied kernel and\nramdisk](http://mirror.centos.org/centos/5/os/x86_64/images/xen/), which\nwere good for an install, but useless when the domU was rebooted.\nThey're built specifically for installation :)\n\n\"Could not connect to localhost:8000\"\n-------------------------------------\n\nYou may see this when using `virt-install` or `virt-manager`. Edit\n`/etc/xen/xend-config.sxp` and make sure these lines are uncommented:\n\n (xend-http-server yes) \n (xend-port 8000) \n (xend-address localhost)\n\nAnd restart the Xen daemon.\n\nLogging\n-------\n\nYou're supposed to be able to edit `/etc/sysconfig/xend`, uncomment this\nline and see logs in `/var/log/xen/console`\n\n XENCONSOLED_LOG_DIR=/var/log/xen/console\n\nDidn't work for me.\n\nMiscellaneous\n-------------\n\n### \"Guest name already in use\"\n\n virsh undefine \n\n* A [nice quickstart](http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool#Saving_and_Restoring_Xen_Guest_Systems)\n to administering Xen guests with `xm`.\n* SPICE is [supposed to be better than VNC](http://zee-nix.blogspot.com/2011/06/welcome-to-virtual-world.html)\n to remote into guests.\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-21T02:30:47Z", "id": "3f2c54b1d767218fcb4855fbac306b015afaf551", "shortId": "3f2c54b1", "subject": "Incremental\n", "content": "Background\n----------\n\n- Vanilla installation of Xen v3.0.3 on `hypervisor.example.com`.\n All defaults.\n- Platform is CentOS 5. Paravirtualization [is not supported on CentOS\n 6](https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37151).\n It's possible to [make it\n work](http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization),\n but I think you should get a newer processor and run KVM if using\n CentOS 6 to save yourself the trouble.\n\nGlossary\n--------\n\nNot meant to be complete.\n\n| Term | Explanation |------- | Type I Hypervisor | Runs directly on hardware. Virtual machines don't know they're virtualized. |------- | Type II Hypervisor | Hypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines *know* they're being run in a virtual environment |------- | HVM (\"Hardware Virtual Machine\" or \"Hardware-assisted Virtualization\") | Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows \"complete simulation of underlying hardware.\" VMs don't know they're virtualized. |------- | `dom0` | The hypervisor itself |------- | `domU` | A single virtual instance |------- | `xm` | Xen-provided tool to manage domU's |------- | `virsh` | A Red Hat-designed shell to manage VM's. Differs from `xm` in that it can manage QEMU and HVM-based domU's as well since it's based on the `libvirt` API. |------- | `virt-install` and `virt-manager` | Management and provisioning tools based on `libvirt`/ |\n|------|----------------------|-------------------|--------------------------------------------------------------------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|--------------------------------|--------|------------------------------------|------|---------------------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|-------------------------------------------------------|\n\nInstallation\n------------\n\n` yum groupinstall Xen` \n` yum install python-virtinst qemu*`\n\nThe first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.\n\nThe First VM\n------------\n\n### Preparing the `dom0`\n\n- My VMs will be running CentOS 6. So I\n [downloaded](http://mirror.anl.gov/pub/centos/6/isos/) and\n loop-mounted the latest CentOS 6 ISO. I then offered the mount via\n HTTP for VM installation.\n- I then created logical volumes for use as storage by the VMs. You\n can [also format and use disk\n images](http://www.chrisabernethy.com/how-to-resize-a-xen-virtual-disk/).\n\n### Creating the VM\n\n`virt-manager` is the easiest way to do things. You can do a\ncommand-line install via `virt-install`. Here's a sample command that\ncreates a 64-bit VM called \"devel1\" running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.\n\n` virt-install \\` \n` --name=devel1 \\` \n` --arch=x86_64 \\` \n` --vcpus=2 --check-cpu \\` \n` --ram=1200 \\` \n` --disk path=/dev/xenspace/devel1 \\` \n` --mac=00:0C:29:1A:98:D5 \\` \n` --os-type=linux \\` \n` --os-variant=rhel6 \\` \n` --location=`[`http://hypervisor.example.com/install/6/x86_64/`](http://hypervisor.example.com/install/6/x86_64/)` \\` \n` --debug \\` \n` --nographics`\n\nOnce the VM is installed, it's a good idea to save the kickstart files.\nHere's a sample:\n\n # Modified by Nikhil Anand \n install\n url --url http://hypervisor.example.com/install/6/x86_64/\n lang en_US.UTF-8\n keyboard us\n network --device eth0 --bootproto dhcp\n rootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\n firewall --enabled --port=22:tcp\n authconfig --enableshadow --enablemd5\n selinux --enforcing\n timezone --utc America/Chicago\n bootloader --location=mbr --driveorder=xvda\n # The following is the partition information you requested\n # Note that any partitions you deleted are not expressed\n # here so unless you clear all partitions first, this is\n # not guaranteed to work\n clearpart --linux --drives=xvda\n part /boot --fstype ext3 --size=100 --ondisk=xvda\n part pv.6 --size=0 --grow --ondisk=xvda\n volgroup VolGroup00 --pesize=32768 pv.6\n logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\n logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n %packages\n @base\n @core\n keyutils\n iscsi-initiator-utils\n trousers\n fipscheck\n device-mapper-multipath\n\nIf you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:\n\n`   -x \"ks=`[`http://hypervisor.example.com/kickstarts/centos-6.ks`](http://hypervisor.example.com/kickstarts/centos-6.ks)`\"`\n\nHVM Support\n-----------\n\nYou can find if your processor supports HVM by issuing\n\n` egrep '^flags.*(vmx|svm)' /proc/cpuinfo`\n\nNetwork Topologies\n------------------\n\nXen offers the following:\n\n- Bridged\n- NAT-ted\n- Routed\n\nIt's unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The `brctl` command is used to manage\nnetwork bridges.\n\nIn our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn't have to do anything other than specify\nthe MAC address in a domU's config:\n\n` vif = [ \"mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge\" ]`\n\nMore exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (`vif`'s), with public and private IPs. In this\ncase, the `route` and `iptables` commands become important, since you'll\nhave to set up routes and masquerading.\n\nEdit `/etc/xen/xend-config.sxp` to set up these configs. For instance,\nif you only had a routed config, you'd comment out every other\n`network-script` and `vif-script` other than these:\n\n` #(network-script network-route)` \n` #(vif-script     vif-route)`\n\nPyGRUB\n------\n\n`virt-install` removes the `kernel` and `ramdisk` lines from a domU's\nconfig file and adds this instead:\n\n` bootloader = \"/usr/bin/pygrub\"`\n\nPyGRUB itself will look for the [*first partition or LVM container* that\ncontain the kernel and init image](http://wiki.xen.org/xenwiki/PyGrub).\n\nI made an error of using the [CentOS project-supplied kernel and\nramdisk](http://mirror.centos.org/centos/5/os/x86_64/images/xen/), which\nwere good for an install, but useless when the domU was rebooted.\nThey're built specifically for installation :)\n\n\"Could not connect to localhost:8000\"\n-------------------------------------\n\nYou may see this when using `virt-install` or `virt-manager`. Edit\n`/etc/xen/xend-config.sxp` and make sure these lines are uncommented:\n\n` (xend-http-server yes)` \n` (xend-port 8000)` \n` (xend-address localhost)`\n\nAnd restart the Xen daemon.\n\nLogging\n-------\n\nYou're supposed to be able to edit `/etc/sysconfig/xend`, uncomment this\nline and see logs in `/var/log/xen/console`\n\n` XENCONSOLED_LOG_DIR=/var/log/xen/console`\n\nDidn't work for me.\n\nMiscellaneous\n-------------\n\n### \"Guest name already in use\"\n\n` virsh undefine `*`guestname`*\n\n- A [nice\n quickstart](http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool#Saving_and_Restoring_Xen_Guest_Systems)\n to administering Xen guests with `xm`.\n- SPICE is [supposed to be better than\n VNC](http://zee-nix.blogspot.com/2011/06/welcome-to-virtual-world.html)\n to remote into guests.\n" }, { "authorEmail": "mail@nikhil.io", "authorName": "Nikhil Anand", "date": "2015-12-20T19:56:41Z", "id": "fa60c048df031accd8a489ff74f999dbeee083e3", "shortId": "fa60c048", "subject": "Xen Notes : First Draft", "content": "Background\n----------\n\n- Vanilla installation of Xen v3.0.3 on `hypervisor.example.com`.\n All defaults.\n- Platform is CentOS 5. Paravirtualization [is not supported on CentOS\n 6](https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37151).\n It's possible to [make it\n work](http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization),\n but I think you should get a newer processor and run KVM if using\n CentOS 6 to save yourself the trouble.\n\nGlossary\n--------\n\nNot meant to be complete.\n\n| Term | Explanation |------- | Type I Hypervisor | Runs directly on hardware. Virtual machines don't know they're virtualized. |------- | Type II Hypervisor | Hypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines *know* they're being run in a virtual environment |------- | HVM (\"Hardware Virtual Machine\" or \"Hardware-assisted Virtualization\") | Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows \"complete simulation of underlying hardware.\" VMs don't know they're virtualized. |------- | `dom0` | The hypervisor itself |------- | `domU` | A single virtual instance |------- | `xm` | Xen-provided tool to manage domU's |------- | `virsh` | A Red Hat-designed shell to manage VM's. Differs from `xm` in that it can manage QEMU and HVM-based domU's as well since it's based on the `libvirt` API. |------- | `virt-install` and `virt-manager` | Management and provisioning tools based on `libvirt`/ |\n|------|----------------------|-------------------|--------------------------------------------------------------------------------------|--------------------|----------------------------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------|--------------------------------|--------|------------------------------------|------|---------------------------------------------|---------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|-----------------------------------|-------------------------------------------------------|\n\nInstallation\n------------\n\n` yum groupinstall Xen` \n` yum install python-virtinst qemu*`\n\nThe first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.\n\nThe First VM\n------------\n\n### Preparing the `dom0`\n\n- My VMs will be running CentOS 6. So I\n [downloaded](http://mirror.anl.gov/pub/centos/6/isos/) and\n loop-mounted the latest CentOS 6 ISO. I then offered the mount via\n HTTP for VM installation.\n- I then created logical volumes for use as storage by the VMs. You\n can [also format and use disk\n images](http://www.chrisabernethy.com/how-to-resize-a-xen-virtual-disk/).\n\n### Creating the VM\n\n`virt-manager` is the easiest way to do things. You can do a\ncommand-line install via `virt-install`. Here's a sample command that\ncreates a 64-bit VM called \"devel1\" running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.\n\n` virt-install \\` \n` --name=devel1 \\` \n` --arch=x86_64 \\` \n` --vcpus=2 --check-cpu \\` \n` --ram=1200 \\` \n` --disk path=/dev/xenspace/devel1 \\` \n` --mac=00:0C:29:1A:98:D5 \\` \n` --os-type=linux \\` \n` --os-variant=rhel6 \\` \n` --location=`[`http://hypervisor.example.com/install/6/x86_64/`](http://hypervisor.example.com/install/6/x86_64/)` \\` \n` --debug \\` \n` --nographics`\n\nOnce the VM is installed, it's a good idea to save the kickstart files.\nHere's a sample:\n\n # Modified by Nikhil Anand \n install\n url --url http://hypervisor.example.com/install/6/x86_64/\n lang en_US.UTF-8\n keyboard us\n network --device eth0 --bootproto dhcp\n rootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\n firewall --enabled --port=22:tcp\n authconfig --enableshadow --enablemd5\n selinux --enforcing\n timezone --utc America/Chicago\n bootloader --location=mbr --driveorder=xvda\n # The following is the partition information you requested\n # Note that any partitions you deleted are not expressed\n # here so unless you clear all partitions first, this is\n # not guaranteed to work\n clearpart --linux --drives=xvda\n part /boot --fstype ext3 --size=100 --ondisk=xvda\n part pv.6 --size=0 --grow --ondisk=xvda\n volgroup VolGroup00 --pesize=32768 pv.6\n logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\n logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n %packages\n @base\n @core\n keyutils\n iscsi-initiator-utils\n trousers\n fipscheck\n device-mapper-multipath\n\nIf you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:\n\n`   -x \"ks=`[`http://hypervisor.example.com/kickstarts/centos-6.ks`](http://hypervisor.example.com/kickstarts/centos-6.ks)`\"`\n\nHVM Support\n-----------\n\nYou can find if your processor supports HVM by issuing\n\n` egrep '^flags.*(vmx|svm)' /proc/cpuinfo`\n\nNetwork Topologies\n------------------\n\nXen offers the following:\n\n- Bridged\n- NAT-ted\n- Routed\n\nIt's unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The `brctl` command is used to manage\nnetwork bridges.\n\nIn our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn't have to do anything other than specify\nthe MAC address in a domU's config:\n\n` vif = [ \"mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge\" ]`\n\nMore exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (`vif`'s), with public and private IPs. In this\ncase, the `route` and `iptables` commands become important, since you'll\nhave to set up routes and masquerading.\n\nEdit `/etc/xen/xend-config.sxp` to set up these configs. For instance,\nif you only had a routed config, you'd comment out every other\n`network-script` and `vif-script` other than these:\n\n` #(network-script network-route)` \n` #(vif-script     vif-route)`\n\nPyGRUB\n------\n\n`virt-install` removes the `kernel` and `ramdisk` lines from a domU's\nconfig file and adds this instead:\n\n` bootloader = \"/usr/bin/pygrub\"`\n\nPyGRUB itself will look for the [*first partition or LVM container* that\ncontain the kernel and init image](http://wiki.xen.org/xenwiki/PyGrub).\n\nI made an error of using the [CentOS project-supplied kernel and\nramdisk](http://mirror.centos.org/centos/5/os/x86_64/images/xen/), which\nwere good for an install, but useless when the domU was rebooted.\nThey're built specifically for installation :)\n\n\"Could not connect to localhost:8000\"\n-------------------------------------\n\nYou may see this when using `virt-install` or `virt-manager`. Edit\n`/etc/xen/xend-config.sxp` and make sure these lines are uncommented:\n\n` (xend-http-server yes)` \n` (xend-port 8000)` \n` (xend-address localhost)`\n\nAnd restart the Xen daemon.\n\nLogging\n-------\n\nYou're supposed to be able to edit `/etc/sysconfig/xend`, uncomment this\nline and see logs in `/var/log/xen/console`\n\n` XENCONSOLED_LOG_DIR=/var/log/xen/console`\n\nDidn't work for me.\n\nMiscellaneous\n-------------\n\n### \"Guest name already in use\"\n\n` virsh undefine `*`guestname`*\n\n- A [nice\n quickstart](http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool#Saving_and_Restoring_Xen_Guest_Systems)\n to administering Xen guests with `xm`.\n- SPICE is [supposed to be better than\n VNC](http://zee-nix.blogspot.com/2011/06/welcome-to-virtual-world.html)\n to remote into guests.\n\n[Category:Nikhil's Notes](Category:Nikhil's_Notes \"wikilink\")\n[Category:Installation Logs](Category:Installation_Logs \"wikilink\")\n[Category:From a past sysadmin\nlife](Category:From_a_past_sysadmin_life \"wikilink\")\n" } ], "sizeInBytes": 8473, "source": "Background\n----------\n\n* Vanilla installation of Xen v3.0.3 on `hypervisor.example.com`.\n All defaults.\n* Platform is CentOS 5. Paravirtualization [is not supported on CentOS\n 6](https://www.centos.org/modules/newbb/viewtopic.php?topic_id=37151).\n It's possible to [make it work](http://www.howtoforge.com/virtualization-with-xen-on-centos-6.2-x86_64-paravirtualization-and-hardware-virtualization),\n but I think you should get a newer processor and run KVM if using\n CentOS 6 to save yourself the trouble.\n\nGlossary\n--------\n\nNot meant to be complete.\n\n\n| Term | Explanation |\n|------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| Type I Hypervisor | Runs directly on hardware. Virtual machines don't know they're virtualized. |\n| Type II Hypervisor | Hypervisor (Xen) runs in OS (RHEL/CentOS). The virtual machines ''know'' they're being run in a virtual environment |\n| HVM (\"Hardware Virtual Machine\" or \"Hardware-assisted Virtualization\") | Not entirely sure about this. Certain processor technology (e.g. Intel VT-x) allows \"complete simulation of underlying hardware.\" VMs don't know they're virtualized. |\n| `dom0` | The hypervisor itself |\n| `domU` | A single virtual instance |\n| `xm` | Xen-provided tool to manage domU's |\n| `virsh` | A Red Hat-designed shell to manage VM's. Differs from `xm` in that it can manage QEMU and HVM-based domU's as well since it's based on the `libvirt` API. |\n| `virt-install` and `virt-manager` | Management and provisioning tools based on `libvirt`/ |\n\nInstallation\n------------\n\n yum groupinstall Xen \n yum install python-virtinst qemu*\n\nThe first installs the Xen-enabled kernel, Xen daemon, virtualization\nlibraries, etc. Make sure that (a) SELinux is disabled, and (b) that you\nreboot into the Xen kernel before doing anything else.\n\nThe First VM\n------------\n\n### Preparing the `dom0`\n\n* My VMs will be running CentOS 6. So I\n [downloaded](http://mirror.anl.gov/pub/centos/6/isos/) and\n loop-mounted the latest CentOS 6 ISO. I then offered the mount via\n HTTP for VM installation.\n* I then created logical volumes for use as storage by the VMs. You\n can [also format and use disk\n images](http://www.chrisabernethy.com/how-to-resize-a-xen-virtual-disk/).\n\n### Creating the VM\n\n`virt-manager` is the easiest way to do things. You can do a\ncommand-line install via `virt-install`. Here's a sample command that\ncreates a 64-bit VM called \"devel1\" running CentOS 6 with two virtual\nCPUs and 1.2GB of RAM. Observe that I explicitly specify the MAC\naddress.\n\n virt-install \\ \n --name=devel1 \\ \n --arch=x86_64 \\ \n --vcpus=2 --check-cpu \\ \n --ram=1200 \\ \n --disk path=/dev/xenspace/devel1 \\ \n --mac=00:0C:29:1A:98:D5 \\ \n --os-type=linux \\ \n --os-variant=rhel6 \\ \n --location=http://hypervisor.example.com/install/6/x86_64/ \\ \n --debug \\ \n --nographics\n\nOnce the VM is installed, it's a good idea to save the kickstart files.\nHere's a sample:\n\n # Modified by Nikhil Anand \n install\n url --url http://hypervisor.example.com/install/6/x86_64/\n lang en_US.UTF-8\n keyboard us\n network --device eth0 --bootproto dhcp\n rootpw --iscrypted $1$9P2b0WZe$CSd.fBGCVjjUfzlZ6m5Rk1\n firewall --enabled --port=22:tcp\n authconfig --enableshadow --enablemd5\n selinux --enforcing\n timezone --utc America/Chicago\n bootloader --location=mbr --driveorder=xvda\n # The following is the partition information you requested\n # Note that any partitions you deleted are not expressed\n # here so unless you clear all partitions first, this is\n # not guaranteed to work\n clearpart --linux --drives=xvda\n part /boot --fstype ext3 --size=100 --ondisk=xvda\n part pv.6 --size=0 --grow --ondisk=xvda\n volgroup VolGroup00 --pesize=32768 pv.6\n logvol / --fstype ext3 --name=LogVol00 --vgname=VolGroup00 --size=1024 --grow\n logvol swap --fstype swap --name=LogVol01 --vgname=VolGroup00 --size=528 --grow --maxsize=1056\n\n %packages\n @base\n @core\n keyutils\n iscsi-initiator-utils\n trousers\n fipscheck\n device-mapper-multipath\n\nIf you ever wanted to reinstall the VM, you can now append a flag with\nthe (HTTP downloadable) path to the kickstart file:\n\n -x \"ks=http://hypervisor.example.com/kickstarts/centos-6.ks\"\n\nHVM Support\n-----------\n\nYou can find if your processor supports HVM by issuing\n\n egrep '^flags.*(vmx|svm)' /proc/cpuinfo\n\nNetwork Topologies\n------------------\n\nXen offers the following:\n\n* Bridged\n* NAT-ted\n* Routed\n\nIt's unusual (and crazy) to use all three on a given dom0 instance. The\ndefault is bridged networking. The `brctl` command is used to manage\nnetwork bridges.\n\nIn our case, the router hands out DHCP leases depending on MAC\naddresses. This is why I didn't have to do anything other than specify\nthe MAC address in a domU's config:\n\n vif = [ \"mac=00:50:56:78:0a:1b,bridge=xenbr0,script=vif-bridge\" ]\n\nMore exotic configurations are possible. You can, for example, specify\ntwo virtual interfaces (`vif`'s), with public and private IPs. In this\ncase, the `route` and `iptables` commands become important, since you'll\nhave to set up routes and masquerading.\n\nEdit `/etc/xen/xend-config.sxp` to set up these configs. For instance,\nif you only had a routed config, you'd comment out every other\n`network-script` and `vif-script` other than these:\n\n #(network-script network-route) \n #(vif-script     vif-route)\n\nPyGRUB\n------\n\n`virt-install` removes the `kernel` and `ramdisk` lines from a domU's\nconfig file and adds this instead:\n\n bootloader = \"/usr/bin/pygrub\"\n\nPyGRUB itself will look for the [*first partition or LVM container* that\ncontain the kernel and init image](http://wiki.xen.org/xenwiki/PyGrub).\n\nI made an error of using the [CentOS project-supplied kernel and\nramdisk](http://mirror.centos.org/centos/5/os/x86_64/images/xen/), which\nwere good for an install, but useless when the domU was rebooted.\nThey're built specifically for installation :)\n\n\"Could not connect to localhost:8000\"\n-------------------------------------\n\nYou may see this when using `virt-install` or `virt-manager`. Edit\n`/etc/xen/xend-config.sxp` and make sure these lines are uncommented:\n\n (xend-http-server yes) \n (xend-port 8000) \n (xend-address localhost)\n\nAnd restart the Xen daemon.\n\nLogging\n-------\n\nYou're supposed to be able to edit `/etc/sysconfig/xend`, uncomment this\nline and see logs in `/var/log/xen/console`\n\n XENCONSOLED_LOG_DIR=/var/log/xen/console\n\nDidn't work for me.\n\nMiscellaneous\n-------------\n\n### \"Guest name already in use\"\n\n virsh undefine \n\n* A [nice quickstart](http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool#Saving_and_Restoring_Xen_Guest_Systems)\n to administering Xen guests with `xm`.\n* SPICE is [supposed to be better than VNC](http://zee-nix.blogspot.com/2011/06/welcome-to-virtual-world.html)\n to remote into guests.\n", "title": "Xen Notes", "untracked": false, "uri": "/Xen_Notes" }