Virtual machines are a must-have tool for every programmer. In this paper, according to the latest version of the VirtualBox user manual prompts, through their own hands-on practice, the Win7 system and run in VirtualBox 5.0.2 in which Ubuntu 14.04 shared information of three ways, not just to establish the two shared folders.
When learning new technologies, or doing different tests, we often install virtual machines and install different operating systems in order to save hardware. We refer to the original operating system running on the hardware as the main operating system (host OS), while the operating system running on the virtual machine is called the guest operating system (guest OS). It becomes necessary to share information between the host OS and the guest OS.
This article, with the help of [document][1], combined with personal exploration and practice, summarizes the following methods of sharing information between the host OS and guest OS.
Environment settings:
- Host Os:windows 7
- Virtualbox:version 5.0.2
- Guest Os:ubuntu 14.0
1 prerequisites for the preparation of work
One of the prerequisites for the following is to install the VirtualBox enhancements (guest addition) first. This feature is not installed by default when VirtualBox is installed. It is equivalent to a software installed on the guest OS, which strengthens the communication between the host OS and its interaction.
The installation is as follows: Start the Guest OS first, select Device (Devices) –> Install Enhancements on the menu bar above the windows of the VirtualBox running guest host, and then guest OS ( At this time for Ubuntu 14.04) in the terminal will automatically start, will give you the appropriate prompt, let you download the installation package, you install the appropriate prompt to complete.
With the installation of guest operating system enhancements, we have a variety of features, and then we mainly introduce the method of sharing information among them.
2 ways to share information 2.1 Clipboard sharing
This is the way the Clipboard is shared, and you can get that information only on one of the systems where you copy the information and then on the Clipboard on the other system.
- If your guest OS is running, then press the method and choose a different option depending on your needs.
- If the guest OS is not running, run VirtualBox and then use the method
2.2 Ways to temporarily share folders
This method is only for cases where the guest OS is already running. When the guest OS is turned off, previously created shared files are invalidated. This method is more flexible and is a temporary connection and sharing.
Here's how:
- On the Windows running Guest OS, clickshared Folders Settings, Devices,shared Folders, such as:
- In the New dialog box (such as), click Add (such as label 1 in), and then in the New Add Share dialog box (2) Fill in the folder path and name (note Do not select three check boxes), see:
Start terminal in the guest OS Ubuntu and enter the following command in it:
mkdir mntsudo mount -t vboxsf UbuntuShareFile mnt
First, create a folder in the user directory mnt, and then use the usual load command to connect the folder Ubuntusharefile on the host OS.
2.3 Automatically shared folders
The methods explained in section 2.2 each time the guest OS is shut down, the shared folders are invalidated and sometimes inconvenient, which requires a way to create a shared folder permanently, which is exactly what this sectionto explains.
Here's how:
Create a shared folder with automatic connection on the host OS, you can use the VirtualBox GUI, or you can use the command line tool Vboxmanage. Gui method when you create a shared folder, fill in the folder name and the path of the folder to select the auto-mount check box, and the Vboxmange command is:
add"Ubuntu""UbuntuShareFile""E:\UbuntuShareFile" --automount
Can accomplish the same function as the GUI method. Note: The operation of the above command needs to be switched to the same folder as the Vboxmanage and is run in Win7 cmd.
VirtualBox specifies that the automatic connection shared folder in the guest OS to the host OS is under Path/media, and the name of the shared folder on the host OS is prefixed sf_. For example, in the above example the name is Ubuntusharefile, then in Ubuntu VirtualBox automatically created folder name is Sf_ubuntusharefile. For the example above, as shown in:
At this point, if you click to enter the file, you will find that you do not have permission to browse any of the contents of the folder, because
Access to auto-mounted GKFX folders is a granted to the user group vboxsf.
So, we also need to enter the following command in Ubuntu terminal to get the read and write permission for this folder:
sudo-a -G vboxsf robert
The purpose of the above command is to add the user Robert to the user group vboxsf. If this command does not work, you will need to override the boot guest OS system.
This allows you to access the contents of the shared folder without having to reset the new shared folder every time.
3 concluding remarks
Regardless of the virtual machine technology you use, sharing information between the host OS and the guest OS is always a matter of conversation. For example, the first method of the application scenario is that you run the Win7 above the C++11 standard of the program, but failed to run, and then you want to change a compiler g++ to run the program, it looks like the program itself, or the reason for the compiler. The latter two methods provide a convenient way to share large volumes of files.
Things that looked easy at first, but there were a lot of details to take care of. You do not need to understand the use of VirtualBox, but also to the host OS and guest OS above the usage of terminal are familiar. By letting the host OS and the guest OS share information, I realize that there are some problems when you search the Internet for a while without getting an answer, the best way is to read the user Manual of the software related to the problem directly.
[1]: Oracle Corporation. Oracle VM VirtualBox User Manual Version 5.0.2, 2015.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Several methods of sharing information between the Win7 system and the Ubuntu14.04 installed in its VirtualBox