Increase size of VirtualBox image (current state)

I had a Vista image that I foolishly set to 10GB. That was OK until I added the Java Runtime Engine, Eclipse, PyDev, Python, SOFA Statistics, another user for testing purposes (with non-English characters in their user name and home directory) etc. And once I ran the space-greedy system updates, I was out of disk space. A working solution was found in these two posts: Increase/Expand the Size of Windows 7 vdi file on VirtualBox Mac, and Cloning a VM with multiple snapshots?. If you want to copy the whole thing up to a particular snapshot (NB the result with be collapsed into one single VDI, unlike the original), get the hexUUID of the snapshot.

Step 1 – make a new and larger VDI. I did so by making a new virtual machine (testVista) with a new virtual disk image (testVista.vdi). An alternative approach would have been to make the vdi on its own but I couldn’t find a menu item to allow that. It was no great burden doing it as part of making a new virtual machine though.

Step 2 – clone the current state version of the old (and small) vdi. You need to find the hexUUID value of the snapshot you want. See Cloning a VM with multiple snapshots? for details. It gives guidance on how to tell which uuid you need.

The command that worked for me was (the path depends on where you are running the command from and your setup of course):

VBoxManage clonehd 0db42252-9240-4a0a-9393-a7d79778364d "../testVista/testVista.vdi" --existing

Note – testVista was the new VDI I was trying to clone into. It should take a few minutes to run.

Step 3 – disconnect to the old vdi and connect your machine to the larger vdi.

Step 4 – Boot into your system and resize the partition as per Increase/Expand the Size of Windows 7 vdi file on VirtualBox Mac On XP I needed EaseUS Partition. For a Ubuntu guest I downloaded the Gparted iso, added that to storage as a live CD, and booted in. Resized everything and exited. Then unlinked from GParted iso.

Step 5 – Success!

[Update – needed to do this again on another vdi – thus the clarified instructions here]

Foreign key support in SQLite and Python

Foreign key support was added in SQLite version 3.6.19, Oct 14th 2009 (Release History of SQLite). There is no point trying to use this feature if you have an earlier version of SQLite. But which version do you have? Here are the relevant commands. NB version is the version of pysqlite, not sqlite. So 2.6.0 does not refer to the SQLite version, which is 3.7.4 i.e. very up-to-date as at the time of posting.

>>> import sqlite3 as sqlite
>>> sqlite.version
>>> sqlite.sqlite_version

The default installation of Python 2.6.6 (which I had to stay with for various reasons) installed an older version of SQLite. But this was easily remedied by installing a newer version (2.7.2) alongside 2.6.6 and overwriting the older version of sqlite3.dll in the C:\Python26\DLL folder with the version from C:\Python27\DLL. It was as simple as that.

Now foreign key constraints are disabled by default, so they must be enabled for each connection.

cur.execute("PRAGMA foreign_keys = ON")

Now to check that it is set, run the following:

cur.execute("PRAGMA foreign_keys")

to run the PRAGMA command you need, and


to get the result back from it. Either (0,) or (1,). NB to do the fetchone() after “PRAGMA foreign_keys” not “PRAGMA foreign_keys = ON”. If nothing is returned, you either forgot the previous instruction and didn’t rerun “PRAGMA foreign_keys” before the fetchone() 😉 or SQLite was compiled with the wrong flags set.

Tip: If the command “PRAGMA foreign_keys” returns no data instead of a single row containing “0” or “1”, then the version of SQLite you are using does not support foreign keys (either because it is older than 3.6.19 or because it was compiled with SQLITE_OMIT_FOREIGN_KEY or SQLITE_OMIT_TRIGGER defined).
SQLite Foreign Key Support

See also:


Defining this option omits support for TRIGGER objects. Neither the CREATE TRIGGER or DROP TRIGGER commands are available in this case, and attempting to execute either will result in a parse error. This option also disables enforcement of foreign key constraints, since the code that implements triggers and which is omitted by this option is also used to implement foreign key actions.
Compilation Options for SQLite

If you are using SQLite as installed along with Python the most likely explanation for no result is that you made a mistake.