VMbuilder Ubuntu bug and simple workaround for failed umount of temporary devfs

While attempting to build virtual machines on Ubuntu 12.04 using the vmbuilder tool (package: python-vm-builder), and (IIRC) on a few other versions of Ubuntu (I think 11.10 and/or 11.04), I kept having vmbuilder crash on me with an unhandled exception (an VMBuilder.exception.VMBuilderException exception, to be specific).

The error read “umount of temporary devfs failed” and would be seen at the very end of the VM building process when trying to unmount some of the temporary installation directories.

A Workaround that Works

I attempted all sorts of workarounds involving editing the unmount_dev() function in the vmbuilder source and inserting os.sync() or sleep commands to try to wait for the temporary installation’s devfs to no longer be in use before unmounting it. These did not work!

A very simple workaround that did work for me was to tell vmbuilder to remove the cron package from the list of default packages to install in the VM. This is done by simply appending the following argument at the end of the vmbuilder command line: --removepkg=cron

For example:

vmbuilder [your_hypervisor] ubuntu [your_options] --removepkg=cron

I recommend trying to run vmbuilder with the --removepkg=cron option, as in the above example, and see if that fixes the problem for you!

More Information

Command-line tools like lsof reported that culprit was the Linux Kernel itself that was still using the temporarily installation’s devfs! Removing the cron package from being installed by default (a newer thing in recent versions of Ubuntu VMs) fixed the problem, but what does a cron package inside the VM we are building have to do with vmbuilder failing? I’m not entirely sure; however, I guess that, perhaps, the cron package inside the temporary installation was holding on to some sort of lock in the temporary installation’s devfs.

My stab-in-the-dark guess as to why the Kernel would appear to be hanging on to it, according to the lsof command, is that, perhaps, this somehow involved a chroot being used for VM building. If anyone knows more information that can shed light onto this issue, please let me know!

Reference: https://bugs.launchpad.net/vmbuilder/+bug/966439

Leave a Reply

Your email address will not be published. Required fields are marked *