8

I've been using VirtualBox on my desktop for quite a while. Having recently bought a notebook, I want to be able to take my Ubuntu virtual machine with me, and have the changes I do on the notebook propagate to the desktop, and vice-versa, when I arrive/leave home. The host operating system is Windows 7 on both computers, running VirtualBox 4.

My first thought was synchronizing the virtual disk files themselves. My tool of choice would be rsync, more specifically the Cygwin version of it, using the --inplace option to reduce writes as much as possible. But that would be infeasible: it would stop me from ever working separately on the VMs, because rsync would have no way to detect conflicts and merge them properly without knowledge of the filesystems that lie inside the containers.

The next option would be rsyncing the running machines to each other. Would that work without messing up package management? Would I need to do anything manually besides updates like new kernel or drivers? Are there any other solution that could work better?

6
  • I think you should split this question in two. First ask about server mirroring. Then when you (hopefully) have a few answers ask how to implement them on a VM.
    – Nifle
    Jun 11, 2011 at 7:54
  • another possibility would be to have a single instance of the VM on the notebook, and remote access it from the main system when at home.
    – Journeyman Geek
    Jun 11, 2011 at 9:38
  • You would have to only sync software and documents - not the entire VMs - as you cannot have two machines on the network with the same MAC addresses and hostnames. That would cause mayhem.
    – paradroid
    Jun 11, 2011 at 11:45
  • @Journeyman Geek: I hadn't thought about that, it could work indeed, but it'd be quite a bit slower considering the hard drive on my notebook crawls in comparison to the SSD on my desktop.
    – danielkza
    Jun 12, 2011 at 4:11
  • 1
    Is there a reason you don't run the VM on an external drive and move it from system to system?
    – Dave M
    Mar 13, 2012 at 18:27

2 Answers 2

2

Using rsync for bidirectional operations is difficult; I'd suggest you look at unison as an alternative. It will work both ways, and tell you what it is going to do before doing so, and also detect files manipulated concurrently on both sides.

Running the sync outside the VM will have the problems you describe. Results when run inside the VM will greatly depend on what you sync.

  • Synchronizing your home directory should be no problem at all, and should synchronize most of your daily work I presume.
  • Synchronizing package manager data will only make sense if you do a full sync of almost everything, perhaps with a few well-considered exceptions. In a bidirectional sync, this will almost always lead to a conflict, though, so I'd only advise this for an rsync-style approach.
  • Synchronizing /etc as well as your home should synchronize most configuration data and still have little impact on what the package manager does. But if you install some software on one VM, you'll have to manually install it on the other as well, and probably should only sync after doing so, in case the upgrade changed some config file.
0

Consider not trying to "sync" the virtual machine at all.

Think about it: You don't "sync" your desktop and notebook in this way. You treat them as separate machines and use services such as Dropbox, Google Apps, etc., or even a USB stick, to work on your files. Similarly, treat the two Ubuntu VMs as separate computers and use services such as Ubuntu One and the above to keep your important files in sync.

If you're concerned about keeping the installed software in sync, you can use

dpkg --list-selections

to get a list of the software you've specifically installed on one machine, and then install the same software on the other.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .