700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > 重启vmware中的linux虚拟机后跟windows主机共享的文件失效解决方法

重启vmware中的linux虚拟机后跟windows主机共享的文件失效解决方法

时间:2023-11-23 04:19:43

相关推荐

重启vmware中的linux虚拟机后跟windows主机共享的文件失效解决方法

最近经常遇到,windows上用vmware安装好linux虚拟机,设置好共享文件后,也生效了。但是每次重启linux虚拟机之后,共享文件就无法访问了,每次都要手动在vmware的设置里禁用共享,然后再开启共享,操作有点麻烦而且慢,有什么方法可以比较简单快速的解决么,下面介绍一个命令就能解决的方法。

vmware共享文件,需要启动vmhgfs相关模块,应用程序为vmhgfs-fuse。

共享文件生效时,可以用ps命令看到vmhgfs-fuse进程

[root@zyg ~]# ps -ef |grep vmroot 5201 0 16:30 ? 00:00:00 /sbin/lvmetad -froot 8211 0 16:30 ? 00:00:00 /usr/bin/vmtoolsdroot 66811 0 16:36 ? 00:00:00 /usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_otherroot 6888 6295 0 16:36 pts/2 00:00:00 grep --color=auto vm

在linux系统上,执行vmhgfs-fuse -h,查看用法:

[root@zyg ~]# vmhgfs-fuse -hUsage: vmhgfs-fuse sharedir mountpoint [options]Examples:vmhgfs-fuse .host:/ /mnt/hgfsvmhgfs-fuse .host:/foo/bar /mnt/bargeneral options:-o opt,[opt...] mount options-h --help print help-V --version print version-e --enabled check if system is enabledfor the HGFS FUSE client. Exits with:0 - system is enabled for HGFS FUSE1 - system OS version is not supported for HGFS FUSE2 - system needs FUSE packages for HGFS FUSEFUSE options:-d -o debugenable debug output (implies -f)-f foreground operation-s disable multi-threaded operation-o allow_other allow access to other users-o allow_rootallow access to root-o auto_unmount auto unmount on process termination-o nonempty allow mounts over non-empty file/dir-o default_permissions enable permission checking by kernel-o fsname=NAME set filesystem name-o subtype=NAME set filesystem type-o large_readissue large read requests (2.4 only)-o max_read=Nset maximum size of read requests-o numa enable numa-o hard_remove immediate removal (don't hide files)-o use_ino let filesystem set inode numbers-o readdir_ino try to fill in d_ino in readdir-o direct_io use direct I/O-o kernel_cache cache files in kernel-o [no]auto_cacheenable caching based on modification times (off)-o umask=M set file permissions (octal)-o uid=Nset file owner-o gid=Nset file group-o entry_timeout=Tcache timeout for names (1.0s)-o negative_timeout=T cache timeout for deleted names (0.0s)-o attr_timeout=Tcache timeout for attributes (1.0s)-o ac_attr_timeout=T auto cache timeout for attributes (attr_timeout)-o noforget never forget cached inodes-o remember=Tremember cached inodes for T seconds (0s)-o nopath don't supply path if not necessary-o intrallow requests to be interrupted-o intr_signal=NUMsignal to send on interrupt (10)-o modules=M1[:M2...] names of modules to push onto filesystem stack-o max_write=N set maximum size of write requests-o max_readahead=Nset maximum readahead-o max_background=N set number of maximum background requests-o congestion_threshold=N set kernel's congestion threshold-o async_readperform reads asynchronously (default)-o sync_read perform reads synchronously-o atomic_o_truncenable atomic open+truncate support-o big_writesenable larger than 4kB writes-o no_remote_lockdisable remote file locking-o no_remote_flockdisable remote file locking (BSD)-o no_remote_posix_lock disable remove file locking (POSIX)-o [no_]splice_writeuse splice to write to the fuse device-o [no_]splice_movemove data while splicing to the fuse device-o [no_]splice_readuse splice to read from the fuse device-o [no_]auto_inval_data use automatic kernel cache invalidation logic-o readdirplus=S control readdirplus use (yes|no|auto)-o [no_]async_dio asynchronous direct I/O-o [no_]writeback_cache asynchronous, buffered writesModule options:[iconv]-o from_code=CHARSET original encoding of file names (default: UTF-8)-o to_code=CHARSETnew encoding of the file names (default: UTF-8)[subdir]-o subdir=DIR prepend this directory to all paths (mandatory)-o [no]rellinks transform absolute symlinks to relative

临时解决的话,直接执行:

vmhgfs-fuse .host:/ /mnt/hgfs

或者用上面ps打印出的命令:

/usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other

即可。

永久生效:

在/root/.bashrc 中添加命令:

vmhgfs-fuse .host:/ /mnt/hgfs或者/usr/bin/vmhgfs-fuse .host:/ /mnt/hgfs -o subtype=vmhgfs-fuse,allow_other

然后执行source命令,让本次修改生效:

source ~/.bashrc

之后,就可以cd到/mnt/hgfs/下的共享文件目录中了。

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。