Share resources of Virtual Machine Linux and host windows

Source: Internet
Author: User
Tags ftp access

When using a virtual machine, if the virtual machine is Linux and the host is Windows, it would be too painful to share some files. Using FTP is too slow and troublesome. I found a related article on the Internet. I can still write it. I just switched it.

Environment Introduction:

Virtual Machine: VMware Workstation 5.5

Host system: Windows 2000 Server

Guest System: Red Hat Enterprise Linux 4

In fact, there are many ways to share resources as two systems. At first I tried to mount the file system using the mount command. From the command itself, it seems that there is no problem to mount a file system or drive disk under windows.

First, create a mount point in the Linux/mnt empty directory: # mkdir/mnt/mystudy

The/mnt directory is a directory used as a mount point. Mystudy is the custom dedicated mount point name.

Then let's take a look at the usage of the mount command:

Command Format: Mount [-T vfstype] [-O options] device dir

Main parameters:

①-T vfstype specifies the type of the file system, which is usually not required. Mount will automatically select the correct type, Windows nt ntfs file system: NTFS

②-O options is mainly used to describe the mounting method of a device or file.

③ Device: the device to be mounted. In Linux, device names are stored in/dev. device names follow certain rules. For example, in/dev/hda1, HD indicates hard disk, and a indicates the first hard disk device, 1 represents the first primary partition of the first hard disk.

④ Dir: the mount point of the device on the system ). For example, the mount point we just created:/mnt/mystudy

Follow this rule to mount the second primary partition of the hard disk

Type the command: # Mount-t ntfs/dev/hda2/mnt/mystudy

Returned information: Mount: FS type NTFS not supported by Kernel

Why can't I find partitions in NTFS format? So where does my windows system go? Check the partition information: # fdisk-l

The following result shows that the windows partition is not found.

My Linux is installed in a virtual machine. The device allocated by the virtual machine to the Linux system is only an 8 GB virtual hard disk partition, so there is no way to mount the partition where the Windows system is located and other hard disk partitions. In a virtual machine environment, if you want to share resources, the mount command is basically useless and can only be considered online.

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.
The addresses are starting
After the system is installed, an IP address temporarily provided to the guest host is obtained from the host machine. In this network connection mode, set the IP address acquisition method of the system in the guest machine to Automatic Acquisition
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 using this method, the Internet connection is very convenient, but the LAN connection between host-guest is really a headache, the virtual network card vmnet8 IP address and
The IP address of the host machine is not in the same CIDR block. After one night, no good solution was found. Finally, the NAT mode was abandoned. 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 with computers running Windows systems.
Printer. It is ideal for Windows and Linux networks. Red Hat as 4.0 with Samba
Server, 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.

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.