Mutual file transfer between Windows and Linux in Virtual Machine (VM)

Source: Internet
Author: User

The following describes several methods I have found. Please forgive me for not writing well.
Method 1: USB flash drive
I have tried to use a USB flash drive, but it is not straightforward to mount a USB flash drive in Linux, and it is necessary to have a USB flash drive. If the Linux version is too low, the current large-capacity USB flash drive is not easy to operate.
To attach a USB flash drive to Linux, follow these steps:
# Fdisk-l view the device status
For Linux in a virtual machine, after a USB flash drive is inserted, the device name of the USB flash drive is usually/dev/sdb1.
# Mkdir/mnt/USB create a folder named USB under the MNT directory
Then mount the USB flash drive:
# Mount-T msdos/dev/sdb1/mnt/USB
If fat16 is used, use the following command.
# Mount-T msdos/dev/sdb1/mnt/USB
For FAT32
# Mount-T vfat/dev/sdb1/mnt/USB
If the format is ext2, run the following command:
# Mount-T ext2/dev/sda1/mnt/USB
Turn on/mnt/USB and you will be able to see what's in your USB flash drive!
If you want to copy files to a USB flash drive in Linux, copy the files directly to/mnt/USB
However, you must run the command to detach the USB flash drive before pulling out the USB flash drive.
# Umount/mnt/USB. Otherwise, the USB flash drive is invalid because it is not copied !!
Method 2: mount the directory shared by the window system
In the LAN, you often need to access the directories shared by other Windows systems. In Linux, after Samba is installed, you can use the commands in Samba to access the shared resources of Windows machines.
Use smbclient to list shared resources of Windows machines
Smbclient-l 192.168.100.111
Based on the Windows Shared resources listed above, you can select the Windows Shared resources to be attached to the local Linux, and then use smbmount or mount to add the resources. refer to the following commands:
Smbmount // 192.168.100.111/public/
Mount // 192.168.100.111/D/mnt/CDROM-O username = Terry (enter the password on the command line)
Mount // 192.168.100.111/D/mnt/CDROM-O username = Terry $1234 (you do not need to enter the password in the command line)
Note: In addition to the command line method described above, the best method is to use other clients, such as linneighborhood, networkneighbours, and ksmbshare. Please refer to other articles.
The above is a command line method. You must enter the command once each time you use it. If you often need to mount some file systems, what should you do if you want to automatically mount them at startup? The following two methods are described:
Method 1.
Place the mounting command in/etc/rc. d/rc. Local.
Method 2.
Modify the partition configuration file/etc/fstab and mount the file system at startup. The following is my/etc/fstab file:
Label = // ext3 defaults
1 1
None/dev/PTS devpts gid = 5, mode = 620
0 0
Label =/home ext3 defaults
1 2
None/proc defaults
0 0
None/dev/SHM tmpfs ults
0 0
/Dev/hda4 swap defaults
0 0
/Dev/CDROM/mnt/CDROM iso9660
Noauto, owner, kudzu, RO 0 0
/Dev/hda2/NTFS ults, iocharset = cp936 0 0
/Dev/hda6/win vfat defaults, codePage = 936, iocharset = cp936 0 0
// 192.168.100.228/Terry/MP3 smbfs username = Terry, password = Terry, codePage = cp936, iocharset = cp936 0 0
Note the last three lines:
The fourth to last line adds my C drive, NTFS format
In the last row, mount my d disk, in FAT32 format.
In the penultimate line, a directory is mounted to another Linux file server on which Samba is installed in my LAN.
All the preceding commands must be run as root.
Method 3: Use the shared folder option in the Virtual Machine (VM)
Step 1: install Linux in a virtual machine
Step 2: select the VM menu --> VM --> install VMware Tools and complete the installation.
Step 3: VM menu --> VM --> setting --> options --> shared folders --> Add --> browse
--> Select a directory in Windows as the shared directory (you do not need to set the directory to a shared file in windows.
Folder) and fill in the folder name displayed in Linux, such as AAA, and then OK.
Step 4: copy the file to the shared folder in windows.
Then run the following command in Linux
# Cd/mnt/HGFS
# Ls
You can see the files copied in windows. Likewise, you can copy files from Linux to Windows.
This is also the simplest and most convenient method.

Reprinted: http://www.linux-book.cn/comment/575.htm

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.