File Sharing with linux virtual machines in windows

Source: Internet
Author: User
Tags ftp access
File Sharing with linux virtual machines in windows-general Linux technology-Linux technology and application information. The following is a detailed description. File Sharing between virtual machines and hosts

Method 1: Use the shared folder function of the Virtual Machine
Use the shared folders feature in vmware (vmware workstation 5) to transfer files between hosts and ghosts in vmware, without any network-related settings or any network protocol, the host and ghost can be linux and windows operating systems. Here we only introduce that the host is windows and the ghost is set in linux. If the ghost is windows, see setting up shared folders in the help of vmware.

1. Install vmtools for linux:
Choose VM> install vmware tools from the VMware workstation program menu...

Start linux on the guest computer and run mkdir/mnt/cdrom.

Mount/dev/cdrom/mnt/cdrom (the vmtools Installation File is placed in the vmware virtual cdrom. First, you must mount the optical drive to find the Installation File)

Cd/mnt/cdrom

Tar-zxvf VMwareTools-5.0.0-12124.i386.tar.gz-C/tmp (unzip the installation file to/tmp)

Cd/tmp/vmware-tools-distrib

/Vmware-install.pl

(Run the vwware installation script, which is written in perl)

Here, the installer will ask a series of questions, such as the location of the installation file and the resolution setting. In most cases, the installation of the default vmware tools configuration can work normally, click the Enter key to select the default configuration for each problem.

After the installation, vmware will add a vmhgfs module to the kernel. You can use lsmod to view

Enter the name of the shared directory in the text box "name" (the directory name entered here will be displayed in the linux System of ghost computer with the same directory name), which is assumed to be fc4_iso; fill in the "host folder" in the host computer windows system to share the directory, Assuming F: \ linux-cd \ RedHat \ Fedora_Core_4 \ stentz-dvd-i386, and then click Finish

In the next dialog box, select the sharing mode: Enable this share indicates that the sharing is valid for a long time and the directory can be Read and written; Read-only means that the sharing is valid for a long time and the directory is Read-only; disable after this session means that the sharing will expire after the ghost computer is shut down or suspended next time. Generally, select Enable this share and click "finish"

Since then, shared folder settings have been completed

3. Use of shared folder directory
Switch to the linux System of the ghost computer and run:

Cd/mnt/hgfs

Ls

You can see the fc3_iso directory and use commands such as cp to perform read and write operations from windows to linux and from linux to windows.

4. Notes
Adding a shared folder in vmware software or performing a version of the shared folder parameter immediately takes effect, that is to say, you can immediately see the newly added shared directory in the linux System of the ghost computer and experience the parameter changes.

Conclusion: The purpose of this article is to reduce the number of new users who repeatedly ask questions about the shared files of vmware host/ghost computer on CU linux and the repeated answers from other brothers, so that the layout is more informative. In addition, I think most of the answers to this question are implemented by using ftp, samba, and nfs (nfs can be implemented by installing microsoft service for unix on windows, it is much easier to use the shared folder method provided by vmware than to use the network protocol for file transfer. For Beginners, copying files using the cp command is much easier than using the ftp and smbmount commands.

Two other common methods

Two solutions are most commonly used:

1. FTP access

2. Samba Service

For both FTP and Samba, you must first analyze the Host-Guest network connection in the virtual machine environment. Basically, the Host and Guest machines can be interconnected as two machines in the LAN. Now we need to reconsider the network connection methods mentioned in "Virtual Machine network configuration.

At that time, we chose to use the NAT mode for network connection. This is a way to use the DHCP service for network connection. That is to say, the Guest machine does not have its own fixed IP address, this address is obtained from the Host machine after the system is started, and is temporarily provided to the Guest machine. In this network connection mode, set the IP address acquisition method of the system in the Guest machine to automatic retrieval. No matter how the Host machine is connected to the Internet, as long as the Host can access the Internet, the Guest machine can also access the internet.

Although this method is used, it is very convenient to connect to the Internet, but the LAN connection between Host-Guest is really a headache, the IP address of VMnet8 is not in the same CIDR block as the IP address of the Host. After one night, no good solution was found. Finally, the NAT mode was discarded. Change the network connection mode of the Linux virtual machine to Bridge.

Bridge mode bridges the virtual network card of a VM to the physical network card of a Host. It can be understood that the Guest Host and the Host are in the same status, and the network relationship is equal, this is the most understandable LAN interconnection method for people like me who are more idiotic about routing.

My network service is a Community LAN network, and the IP address is automatically obtained. I don't have to worry about changing it. I also set the network of the Guest machine to automatically get the IP Address:

Application --> system settings --> network --> edit eth0 Device

The Host and Guest are in the same network segment, basically like the two machines in the LAN. Set FTP for the Host. FTP is used to access the Host resources, and file management is not convenient.

Another way to share Windows resources is Samba, which is favored by many Linux users. Samba is a set of software that enables UNIX systems to apply the Microshoft network communication protocol. It enables computers running UNIX systems to share drives and printers with computers running Windows systems. It is ideal for Windows and Linux networks. The Samba Server is attached to Red Hat AS 4.0, but it does not run automatically at system startup by default. You can use the service command to view and control the Samba service:

View the Samba service running status: # service smb status
Start the Samba service: # service smb start
Stop Samba service: # service smb stop

You can also set to automatically start the Samba service when the system restarts: # chkconfig -- level 345 smb on

First, set the folder or drive Web Sharing in Windows and set its alias, such as:/study

Then, log on to the smb service as a user in Linux:

Common error messages:

1. Firewall Problems
When using the Samba service, both Host and Guest should disable the firewall. How to disable firewall in Linux: System Settings> Server Settings> services> iptable

2. the logon username or password is incorrect.

Verify the user name and password.

Successfully logged on to smb

Use the LS command to view shared files in the current directory

You can use the get command to download an object from the server:
Smb: \> get file1 file2 (download file1 from the server and save it locally in the name of file2-the default root directory)

Exit command to Exit the smb server

If you still find file management inconvenient, you can use the smbmount command to mount Windows Shared Folders or drives:

# Smbmount // 192.168.0.162/study/mnt/mystudy? O username = admin

Among them, 192.168.0.162 is the Host IP address, study is the alias of the shared folder,/mnt/mystudy is the mount point, which can be created by # mkdir/mnt/mystudy, and admin is the Host login username.

Open the Mount directory.

Does this seem to get used to much more? The file management interface in Windows is almost the same.

At this point, the virtual machine Linux shared host Windows resources are basically implemented, and it is very simple to complete, but it has encountered many problems.

I have not studied linux in depth, so I chose a simple shared folder to share files. For the FTP and SAMBA modes, We will summarize them here and learn more about the network later! Haha!
Related Article

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.