Monthly Archives: February 2013

Moving MS SQL 2008 database location

You cannot change the installation location (so master etc databases), but client databases can be moved like so:

First take the databases offline and move the mdf and ldf files to the new location, then do the following commands:

   Name = “db_name”,
   Filename = ‘Q:\sqldata\db_name.mdf’
   Name = “db_name_log”,
   Filename = ‘Q:\sqldata\db_name_log.LDF’


Taken from:

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
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.

Getting pypicache running on Ubuntu 10.04

Pypicache is a great way to host a local pypi repository.  Unfortunately, it took some time for me to get it working under Ubuntu 10.04.

Pypicache is written for 2.7+, and ubuntu 10.04 uses 2.6.  Lucikly, the only backwards incompatibility seems to be string formatting.  Sooooo, get a copy of pypicache source and fix all the string formatting in the py files under the pypicache directory (alternatively, clone this: – might be out of date so check first)

Then, while in the directory with your copy of pypicache, run pip install -r requirements.txt –use-mirrors
(Or ‘make init’ if you don’t mind it downloading all the dev requirements too.)

Then ‘make runserver’ to run the server in debug mode, with the target directory /tmp/pypicache

Test the server runs ok and you can use for whatever you want to use it for (in my case, a pip proxy).  Then you can run it using ‘PYTHONPATH=. python -m pypicache.main /tmp/mypackages’