vbox reports an error protocol error when setting the link in the shared folder

surroundings:

Vagrant (centos version) development environment based on VBox.

problem:

In the Virtualbox virtual machine (centOS), when compiling the go program, you need to set a linker, and then get the following error:

ln: failed to create symbolic link ‘/home/gopath/src/k8s.io/kubernetes/_output/local/go/src/k8s.io/kubernetes’: Protocol error

Check:

After investigation, it is found that this is because VirtualBox restricts the creation of soft links to shared folders from a security perspective, which leads to the occurrence of this problem. Therefore, the entry point for us to solve the problem is to determine how to solve the problem that the shared folder can create soft link permissions.

solve:

Close VBox and
add the installation directory of VBox to the environment variable PATH. Normally, when VirtualBox is installed, a system variable named VBOX_MSI_INSTALL_PATH will be automatically created in the environment variable, and this variable can be added to the system environment variable PATH.
Insert picture description here
Here, I directly added the installation directory to the PATH directory:

Insert picture description here
Open the cmd program with administrator rights:

Right-click and select administrator permissions.
Run the following command:

VBoxManage setextradata YOURVMNAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOURSHAREFOLDERNAME 1

PS: YOURVMNAME is modified to the name of the linux system in your virtual machine, which is the name of the virtual machine displayed in the list on the left side of the VirtualBox manager. YOURSHAREFOLDERNAME modify the shared directory name web-meiyou-wjt_default_1530530557254_91388 set by yourself, which is the name of my shared directory home_gopath_src_ in the figure below.

Insert picture description here
So the official order is as follows:

VBoxManage setextradata web-meiyou-wjt_default_1530530557254_91388 VBoxInternal2/SharedFoldersEnableSymlinksCreate/srv_www 1

Perform verification to see the key/value value information of our settings:

Copy code

C:\Windows\system32>  VBoxManage getextradata web-meiyou-wjt_default_1530530557254_91388  enumerate

Insert picture description here

Copy code
shows that it has been set up successfully.

Start with vagrant up and continue to compile. It is
found that the compilation process still reports the initial error. I think of the commands we used to execute with administrator privileges. Therefore, when we execute vagrant commands, we also try to execute with administrator privileges (open cmd with administrator privileges) OK, the rest of the operations remain the same), OK, there is no problem, and the compilation is successful.

PS. In this case, if you want to view the running status of the virtual machine in VBox, you also need to open the virtual machine with administrator privileges, otherwise you will see that the running status is stopped.

Guess you like

Origin blog.csdn.net/qq_26249609/article/details/103072798