The solution when Ubuntu and the host share folders in the virtual machine, and the /mnt directory is empty and there is no shared folder
1. Enable shared folders
First shut down the virtual machine, in the virtual machine settings, select the options panel, select the shared folder, select always enable
Click Add, select Next in the pop-up panel, and select a shared folder (select or create a new folder in the host as a shared folder)
Select Enable this sharing and click Finish.
2. Install VMware Tools
The virtual machine is powered on and VMware Tools is installed
The VMware Tools directory appears in the directory
Copy the compressed package indicated by the arrow in the figure to the desktop, and decompress it
Go to the vmware-tools-distrlb directory and choose to open it in the terminal
Type in terminal
sudo ./vmware-install.pl
It will ask yes or no in the middle, choose yes for all, and keep pressing Enter until the loading is completed, as shown in the figure after completion
After completion, enter the mnt directory under the Ubuntu computer directory
If there is a /mnt/hgfs/ shared folder, it is successful, if not, the solution is as follows.
3. If there is no shared folder in the /mnt/hgfs/ directory
Open a terminal command window in the computer directory
Install command package
sudo apt-get install open-vm-tools
If there is no hgfs directory under mnt, you need to create a hgfs directory yourself (root permission is required)
Open a terminal command window in the mnt directory
Create a folder with root privileges. If you use simple installation of ubuntu in VMware, the root user has no password, which means that the root user cannot be used, and the root privilege cannot be opened. This is the security mode of ubuntu . But ubuntu provides a command to execute super management privileges as ordinary users—sudo
sudo passwd root
First enter the password of your own ordinary user, and then set the root password. Note that it must be greater than 8 characters, and do not include root
After setting up the root user, enter the command
su root
Enter the root password, as shown in the figure, you have the permission to create folders
To create a folder under the mnt directory, as shown in the figure above, you must enter the mnt directory. If you are not in the mnt directory, you must enter through the cd command. Execute the following command to create the hgfs directory.
sudo mkdir hgfs
Execute cd .../ to enter the computer directory
mount
sudo vmhgfs-fuse .host:/ /mnt/hgfs -o nonempty -o allow_other
If an error is reported due to -o nonempty, delete it
Execute commands such as
sudo vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
Then the shared folder appears under mnt/hgfs successfully
The shared folder under the mnt/hgfs directory disappears after restarting
It needs to be mounted here, that is, open a terminal command window in the root directory of the computer
sudo vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other
That is, it needs to be remounted after each restart.
4. The solution to the failure of the shared folder after restarting
Edit the fstab file under etc and execute the following command in the root directory
vim /etc/fstab
If the following situations occur
Then install vim first
sudo apt install vim
Then execute the above command
vim /etc/fstab
Move the cursor to the last digit, press a to enter insert mode, press Enter, and enter the following command
.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0
然后在执行上述命令
vim /etc/fstab
将光标移至最后一位,按a进入插入模式,按回车键,输入以下命令
.host:/ /mnt/hgfs fuse.vmhgfs-fuse allow_other 0 0
然后输入 :wq 保存并退出,不要忘记冒号。