How do I copy large datasets between two VirtualBox virtual machines?

I have two separate CentOS 7 virtual machines running in VirtualBox that is installed in a Windows 8.1 host. How do I transfer large amounts of data from one of the CentOS 7 virtual machines to the other?

The following screenshot shows the desktops of both virtual machines:

enter image description here

The VM on the right has mounted two disk partitions, called 45GB partition and 54GB partition. The amount of actual data in the partitions is much smaller than the partition size. But how do I transfer the contents of the 45GB disk partition in the VM shown on the right to the 45GB folder in the VM on the left? And then repeat for the 54GB disk partition.

A correct answer involves step by step working instructions.


Solution 1:

The answer should be complex, I hope not too much complicate, but more you read down more it is complex; for a large quantity of data I can suggest you the number 1 or the numbers 5 and 6:

  1. If you will not use at the same time both the virtual machines you can mount the same virtual disk to each of them: no need to copy.

  2. You can copy few (or more) lines or files with copy & paste mechanism.

    For this you need to share clipboard between host OS and guest OS, installing Guest Addition on both the virtual machines (probably setting bidirectional and restarting them).
    You copy from guest OS in the clipboard that is shared with the host OS.
    Then you paste from the host OS to the second guest OS.

  3. You can enable drag and drop too with the same method (Click on the machine, settings, general, advanced, drag and drop: set to bidirectional )

  4. You can have common Shared Folders on both virtual machines and use one of the directory shared as buffer to copy.

    Installing Guest Additions you have the possibility to set Shared Folders too. As you put a file in a shared folder from host OS or from guest OS, is immediately visible to the other. (Keep in mind that can arise some problems for date/time of the files when there are different clock settings on the different virtual machines).
    If you use the same folder shared on more machines you can exchange files directly copying them in this folder.

  5. You can use usual method to copy files between 2 different computer with client-server application. (e.g. scp with sshd active for linux... you can get some info about SSH servers e.g. here)

    You need an active server (sshd) on the receiving machine and a client on the sending machine. Of course you need to have the authorization setted (via password or, better, via an automatic authentication method).

    Note: many Linux/Ubuntu distribution install sshd by default: you can see if it is running with pgrep sshd from a shell. You can install with sudo apt-get install openssh-server.

  6. You can mount part of the file system of a virtual machine via NFS or SSHFS on the other, or you can share file and directory with Samba.
    You may find interesting the article Sharing files between guest and host without VirtualBox shared folders with detailed step by step instructions.

You should remember that you are dialling with a little network of machines, in you case with the same operative systems, and in particular:

  • Each virtual machine has its own operative system running on and acts as a physical machine.
  • Each virtual machine is an instance of a program owned by an user in the hosting operative system and should undergo the restrictions of the user in the hosting OS.

  • Windows likes mouse and Linux fingers. :-)
    I mean I suggest you to enable Drag & drop to be cosy with the Windows machines and the Shared folders or to be cosy with Linux.
    When you will need to be fast with Linux you will feel the need of ssh-keygen and to Generate once SSH Keys to copy files on/from a remote machine without writing password anymore. In this way it functions bash auto-completion remotely too!

Reference

  • You can find some additional details or comments in a similar answer given to the same question about two virtual machines with Windows and Linux as operative systems.