To enable SMB file sharing under Vagrant

Source: Internet
Author: User
Tags php development environment

When using vagrant to build a PHP development environment, you need to use the file synchronization synchronization function. After the comparison of many network file systems, found that the Windows file synchronization system is the most friendly SMB, then how to enable SMB file sharing in vagrant?

No matter how you get the Vagrant box, when you start vagrant box, modify the Vagrantfile:

Vagrant.configure ("2") do |config|  Config.vm.synced_folder "C:/work", "/home/code", type: "SMB", Smb_host: "192.168.33.1", Smb_username: "Ranwuer", Smb_password: "YourPassword", mount_options: ["Username=ranwuer", "PASSWORD=YOURPASSOWRD"]end

Parameter explanation:

1. Smb_host

Indicates which host to share the file with, here is the host side of the IP address, the following configuration needs to be started before the use of this IP.

Config.vm.network "Private_network", IP: "192.168.33.11"

This configuration means that the guest host has a private network that communicates with host hosts. The host side of the IP is 192.168.33.1, you can enter ipconfig in cmd to view:

In this way, you can use SMB to synchronize the data between the guest's folder and the folder on the host side.

2.smb_username,smb_password

If you do not enter this parameter, when you run vagrant up, vagrant will prompt you to enter Windows user name and password to implement a connection to a folder in Windows. I am currently on the Windows 10 system, and please fill in these two parameters according to the actual situation. In short, these two parameters are configured without having to enter the Windows user name and password each time they are started.

3.mount_options

Fill in this parameter to resolve the "wrong FS type" error, see: https://www.vagrantup.com/docs/synced-folders/smb.html COMMON issues Chapter. This is an official error solution, but I have no problem with it anyway.

Error message:

Some common techniques:

1. To prevent SMB sharing from rejecting inactive connections, you need to execute the following command to let the system not automatically kick off inactive connections
NET config server/autodisconnect:-1

2.vagrant does not automatically delete shares, to delete shared use commands
NET share C30268623ba3dedeaa9f098b570dca21/delete

3. viewing file share status with net share

In short, according to this configuration, I resolved the virtual machine under Windows with the Hos T host through the SMB sharing problem, also please crossing Pat.

To enable SMB file sharing under Vagrant

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.