Category Archives: Virtualization

Error running vagrant provisioner when default vagrant share is disabled

If you have disabled the default vagrant shared directory

config.vm.synced_folder '.', '/vagrant', disabled: true

You will get the following error using a provisioner:

==> default: Running provisioner: ansible_local...
default: Installing Ansible...
default: Running ansible-playbook...
cd /vagrant && PYTHONUNBUFFERED=1 ANSIBLE_FORCE_COLOR=true ansible-playbook --limit="default" --inventory-file=/tmp/vagrant-ansible/inventory -v /ansible/init.yml
bash: line 3: cd: /vagrant: No such file or directory
Ansible failed to complete successfully. Any error output should be
visible above. Please fix these errors and try again.

To fix, set the provisioning_path configuration:

config.vm.provision "ansible_local" do |ansible|
ansible.provisioning_path = "/ansible"
end

Notes on fixing XenServer VDIs

If get the VDI is not available when scanning SR

xe sr-scan uuid=[uuid of the SR]

Should give you a more verbose error message, also
/var/log/SMlog
Should give an even more verbose error, eg VDI header error

Get the VDI uuid
xe vdi-list

Forget the VDI and re-scan the SR
xe vdi-forget uuid=[vdi uuid]
xe sr-scan uuid=[sr uuid]

Might fix the issue, otherwise, if need to preserve the data, need to restart the host
If can trash the data, can try to delete the vdi

xe vdi-destroy uuid=[vdi uuid]

Might not work, if not, try restart.  May also need to manually remove the LVM volume

lvremove /dev/VG_XenStorage-[uuid of sr]/VHD-[uuid of vdi]

Then restart the machine or Xen is confused by missing volume

If really need the data, there might be a way to fix broken headers/footers.  If the data on the VDI has issues, though, create a new VDI (larger than original), use dd to copy data from broken VDI to new one, mount new one and use a recovery tool on the VM to recover data.

Instructions taken from post on Citrix Forums by Fabian Baena:

xe vdi-create sr-uuid=bc4c43f3-1321-2b17-bef0-3b58686a8075 name-label=copy virtual-size=210130436096

the sr-uuid is the storage where you want to put the copy. Take note of the uuid that comes up after you execute the command

get the uuid of your xenserver control domain by doing
xe vm-list name-label=Control\ domain\ on\ host:\ <name of your xenserver host> params=uuid

then create the vbd
xe vbd-create vm-uuid=<;vm-uuid you got from the previous command>; vdi-uuid=&lt;vdi uuid you got from the vdi-create command> device=0

plug the vbd
xe vbd-plug uuid=<vbd uuid you got from the previous command>;

then do the copy

dd if=/dev/mapper/VG_XenStorage–bc4c43f3–1321–2b17–bef0–3b58686a8075-VHD–b079b55a–6679–47a1–b2a2–d207a476494e of=/dev/xvda

The copy will take several minutes. When finished unplug the vbd

xe vbd-unplug uuid=<vbd uuid you got from the vbd-create command>
xe vbd-destroy uuid=<vbd uuid you got from the vbd-create command>

Afterwards, you can connect the new vdi to a vm and see if you can recover anything.

Notes on XenServer and NTP

  • XenServer syncs with the NTP server anytime between once every one minute and once every 15-20 minutes, depending on the amount of “drift” your hardware clock exhibits (ref)
  • XenServer syncs the hardware clock with the system clock automatically – I think when ntp starts (ref: /etc/rc.d/init.d/ntpd – on XenServer 5.6 SP 2)
  • VMs (both with and without XenServer Tools) have their hardware clocks synced with XenServers system clock when they start up – if you try and use a command like “hwclock -r” and get the message that the hardware clock cannot be accessed; do not worry, it still works

 

 

Switching from load-balancing to active-backup on XenServer

By default, the NIC bonding in XenServer is load balancing (SLB); apparently every 10-30 seconds it switches the NIC it’s using, and the default setting is an up-delay of 3.1 seconds** (see here).

To change to active-backup, you need to do the following (this requires a reboot by the way):

  1. Have your bonds set up in XenServer (use the XenCenter GUI)
  2. Find the UUID of the bond (something like: bd25429f-f7ff-3206-e5b2-4c027c51947c)
    1. Get the network UUID of your bond: xe network-list
    2. Get the pif UUID by matching the network-uuid parameter with the one you found in the step above: xe pif-list
  3. Run the following command: xe pif-param-set uuid=<bond_pif_uuid> other-config:bond-mode=active-backup
  4. Reboot the XenServer
  5. Check your bond settings: cat /proc/net/bonding/bond0; the Bonding Mode should say “fault-tolerance (active-backup)”

I’ve not yet figured out how to set a primary NIC for the bond (it’s not officially supported*), will report back when have done.

 

*UPDATED: found this “Can be configured with one fast path, and one slow path for cost savings; in this scenario, the slow path should only be used if there is a failure on the fast path” – but that’s the only documentation I can find about it, so it may or may not be officially supported…Ref: http://support.citrix.com/article/CTX124421

**UPDATED: in the admin manual, they say this about the up-delay:
“Bonding is set up with an Up Delay of 31000ms and a Down Delay of 200ms. The seemingly
long Up Delay is purposeful because of the time taken by some switches to actually start
routing traffic. Without it, when a link comes back after failing, the bond might rebalance
traffic onto it before the switch is ready to pass traffic. If you want to move both connections
to a different switch, move one, then wait 31 seconds for it to be used again before moving
the other.”

It also says that XenServer supports Active-Passive NIC bonding which is derived from active-backup (ie, they state that it’s not actually active-backup), and that a fast path and slow path can be configured.  However, the steps to configure active-passive state to use “other-config:bond-mode=active-backup” (so the steps above are correct, only they set the server to XenServer’s implementation of active-backup which they call active-passive).  The manual also doesn’t mention how to configure the fast and slow paths, and while it lists PIF commands, it doesn’t even mention the other-config:bond-mode command…

Setting up Ubuntu 10.04 using XenCenter 5.6 experimental Ubuntu template

After a while of getting errors while trying to install an Ubuntu ISO to a new Ubuntu template VM, I got it working using the following URL for the install from web:

http://mirror.yandex.ru/ubuntu/
UPDATE: this URL also works – http://www.mirrorservice.org/sites/archive.ubuntu.com/ubuntu/
(The path they’re looking for is /dists/lucid/main/installer-i386/current/images/netboot/xen/vmlinuz)

Not sure why, but all of the mirrors I found apart from this had the wrong folder structure, and XenCenter wanted to find the ISO itself a few folders deep, rather than let me give it the exact location of the ISO to install.

 

Installing XenServer Tools is also easy.  Put the tools into the virtual drive, mount it, navigate to it and into the Linux directory, pick your package (64 or 32 bit) and install:

mkdir /media/cdrom
mount /dev/cdrom /media/cdrom
cd /media/cdrom/Linux
dpkg -i xe-guest-utilities_5.6.100-651_i386.deb