Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
hypervisor:base:xcp-xapi [2015/03/29 00:36] admin [Create a VBD for the VDI and plug it] |
hypervisor:base:xcp-xapi [2015/03/29 13:06] (current) admin [kpartx for Mapping Partition Tables] |
||
---|---|---|---|
Line 162: | Line 162: | ||
REPLACE: “openvswitch” with “bridge” (or vice-versa). | REPLACE: “openvswitch” with “bridge” (or vice-versa). | ||
- | ===== Reboot ===== | + | ==== Reboot ==== |
After making those changes a reboot will be needed | After making those changes a reboot will be needed | ||
Line 174: | Line 174: | ||
It is often interesting to setup at least one VM to autostart at boot time. | It is often interesting to setup at least one VM to autostart at boot time. | ||
- | Do do so you can follow this next procedure: | + | Do do so you can follow this next procedure, that is also described [[http://sysadmin.compxtreme.ro/autostart-vm-in-free-version-of-xenserver-6-x/|on this post]]: |
=== Gather the UUIDs of the pools you wish to auto-start === | === Gather the UUIDs of the pools you wish to auto-start === | ||
Line 206: | Line 206: | ||
> xe vm-param-set uuid=b7e42681-56c1-24cc-db45-9577981000b1 other-config:auto_poweron=true | > xe vm-param-set uuid=b7e42681-56c1-24cc-db45-9577981000b1 other-config:auto_poweron=true | ||
+ | </code> | ||
+ | |||
+ | === Modify rc.local === | ||
+ | The previous steps are documented to be enough when using Citrix's XenServer. As we're using XCP/XAPI, one supplementary step is required, having a script to start at boot time all vms with "auto_poweron" in their other-config. This can be achieved by editing the //**/etc/rc.local**// file, adding the following code: | ||
+ | |||
+ | <code> | ||
+ | > nano /etc/rc.local | ||
+ | |||
+ | #!/bin/sh -e | ||
+ | # | ||
+ | # rc.local | ||
+ | # | ||
+ | # This script is executed at the end of each multiuser runlevel. | ||
+ | # Make sure that the script will "exit 0" on success or any other | ||
+ | # value on error. | ||
+ | # | ||
+ | # In order to enable or disable this script just change the execution | ||
+ | # bits. | ||
+ | # | ||
+ | # By default this script does nothing. | ||
+ | |||
+ | [ -e /proc/xen ] || exit 0 | ||
+ | |||
+ | XAPI_START_TIMEOUT_SECONDS=240 | ||
+ | |||
+ | # wait for xapi to complete initialisation for a max of XAPI_START_TIMEOUT_SECONDS | ||
+ | /usr/lib/xcp/bin/xapi-wait-init-complete ${XAPI_START_TIMEOUT_SECONDS} | ||
+ | |||
+ | if [ $? -eq 0 ]; then | ||
+ | |||
+ | pool=$(xe pool-list params=uuid --minimal 2> /dev/null) | ||
+ | |||
+ | auto_poweron=$(xe pool-param-get uuid=${pool} param-name=other-config param-key=auto_poweron 2> /dev/null) | ||
+ | if [ $? -eq 0 ] && [ "${auto_poweron}" = "true" ]; then | ||
+ | logger "$0 auto_poweron is enabled on the pool-- this is an unsupported configuration." | ||
+ | |||
+ | # if xapi init completed then start vms (best effort, don't report errors) | ||
+ | xe vm-start other-config:auto_poweron=true power-state=halted --multiple >/dev/null 2>/dev/null || true | ||
+ | fi | ||
+ | fi | ||
+ | </code> | ||
+ | |||
+ | You can test that the code works using the following command, it is important to validate its function as line 19 may need to be adapted, i.e: YMMV for /usr/lib/xcp/bin/xapi-wait-init-complete | ||
+ | |||
+ | <code> | ||
+ | > /etc/rc.local | ||
</code> | </code> | ||
---- | ---- | ||
- | ===== Create and Access a VDI from Dom0 ===== | + | ===== Create and Access File Based VDI from Dom0 ===== |
+ | ---- | ||
+ | |||
+ | The following procedure is based on the one described [[http://discussions.citrix.com/topic/334905-mount-vm-disk-image-as-file-system-in-xenserver-6/|in this post]]. | ||
---- | ---- | ||
==== Create the Virtual Hard Disk (VDI) ==== | ==== Create the Virtual Hard Disk (VDI) ==== | ||
Line 231: | Line 281: | ||
</code> | </code> | ||
+ | We'll now have a new vhd file at:\\ | ||
+ | //**/run/sr-mount/<sr-uuid>/<vdi-uuid>.vhd**// | ||
+ | |||
+ | Which, in our example, translates to:\\ | ||
+ | /run/sr-mount/26b9d87b-f344-1c8d-c5c5-a155d4e4e2e0/72e00fc6-98bb-48fe-ab4d-b52d1ef721b5.vhd | ||
---- | ---- | ||
==== Create a VBD for the VDI and plug it ==== | ==== Create a VBD for the VDI and plug it ==== | ||
Line 244: | Line 299: | ||
</code> | </code> | ||
- | Then let's create and link the VBD (virtual block device) to our Dom: | + | Then let's create and link the VBD to our Dom: |
<code> | <code> | ||
> xe vbd-create vm-uuid=76868e4b-4d82-320e-dd46-41340e6a67f3 vdi-uuid=72e00fc6-98bb-48fe-ab4d-b52d1ef721b5 device=autodetect | > xe vbd-create vm-uuid=76868e4b-4d82-320e-dd46-41340e6a67f3 vdi-uuid=72e00fc6-98bb-48fe-ab4d-b52d1ef721b5 device=autodetect | ||
Line 255: | Line 310: | ||
<code> | <code> | ||
> xe vbd-plug uuid=7472f458-ba3f-7344-99a7-6660a39037a6 | > xe vbd-plug uuid=7472f458-ba3f-7344-99a7-6660a39037a6 | ||
+ | </code> | ||
+ | |||
+ | At this stage, a new device will get listed under //**/dev/sm/backend/<sr-uuid>/<vdi-uuid>**// like: | ||
+ | |||
+ | Before vdb-plug instruction: | ||
+ | <code> | ||
+ | ls -l /dev/sm/backend/26b9d87b-f344-1c8d-c5c5-a155d4e4e2e0/ | ||
+ | total 0 | ||
+ | brw------- 1 root root 253, 0 Mar 29 01:38 4ea98b0d-b3fc-4f62-86bd-19a80f7d356b | ||
+ | </code> | ||
+ | |||
+ | After vdb-plug instruction: | ||
+ | <code> | ||
+ | ls -l /dev/sm/backend/26b9d87b-f344-1c8d-c5c5-a155d4e4e2e0/ | ||
+ | total 0 | ||
+ | brw------- 1 root root 253, 0 Mar 29 01:38 4ea98b0d-b3fc-4f62-86bd-19a80f7d356b | ||
+ | brw------- 1 root root 253, 1 Mar 29 01:59 72e00fc6-98bb-48fe-ab4d-b52d1ef721b5 | ||
</code> | </code> | ||
---- | ---- | ||
+ | ==== kpartx for Mapping Partition Tables ==== | ||
+ | ---- | ||
+ | The kpartx command creates device maps from partition tables. Each guest storage image has a partition table embedded in the file. | ||
+ | We'll first need to install the package if it is not already available. | ||
+ | <code> | ||
+ | > apt-get install kpartx | ||
+ | </code> | ||
+ | === Inspect an .img file === | ||
+ | kpartx lets you inspect an img file, showing its contained partitions using the -l command: | ||
+ | <code> | ||
+ | > kpartx -l /opt/xen/X-Local-ISO/<image_file_name>.img | ||
+ | loop0p1 : 0 122880 /dev/loop0 8192 | ||
+ | loop0p3 : 0 1536000 /dev/loop0 131072 | ||
+ | loop deleted : /dev/loop0 | ||
+ | </code> | ||
+ | ---- | ||
+ | |||
+ | === Add the partition mappings to the recognized devices in /dev/mapper/ === | ||
+ | <color darkorange>**THIS DOESN'T WORK!**</color> | ||
+ | <code> | ||
+ | > kpartx -av /run/sr-mount/26b9d87b-f344-1c8d-c5c5-a155d4e4e2e0/72e00fc6-98bb-48fe-ab4d-b52d1ef721b5.vhd | ||
+ | </code> | ||
+ | ==== END ==== | ||
+ | ---- | ||
++++ X11 & VNC viewer | | ++++ X11 & VNC viewer | |