Make provisioning tools correctly work out where the VM's root partition is rather than hard code it.

And refactor the code in the process.