CentOS与Windows共享文件夹

41次阅读

共计 2803 个字符,预计需要花费 8 分钟才能阅读完成。

1. 虚拟机 -> 设置

2. 选项 -> 共享文件夹 -> 总是启用 -> 添加 打开向导 -> 下一步

3. 选择主机路径,即 Windows 系统中的文件夹,也可以新建一个指定位置的文件夹

4. 启用共享,点击完成

5. 点击确定

6. 进入 CentOS,进入 mnt 文件夹(cd mnt,也可以在根目录直接创建文件夹:mkdir /mnt/share)
创建共享文件夹:mkdir share
挂载:mount -t fuse.vmhgfs-fuse .host:/ /mnt/share/ -o allow_other
(命令的详解在最后,如果想自定义 Linux 中 共享文件夹的位置,可以参照最后的命令解析自行改动命令)

7. 永久挂载设置
命令:vi /etc/fstab
.host:/ /mnt/share fuse.vmhgfs-fuse allow_other 0 0

编辑完后,按键:Esc -> :wq,保存并退出
下面是我的操作历史,一般创建文件夹不会失败的,所以 ls 命令查看是否创建成功可以免了

[root@localhost ~\]# history
    1 vmware-hgfsclient
    2 cd /mnt
    3 ls
    4 mkdir share
    5 ls
    6 mount -t fuse.vmhgfs-fuse .host:/ /mnt/share/ -o allow\_other
    7 cd /mnt/share
    8 ls
    9 cd /.
    10 vi /etc/fstab
    11 history
[root@localhost ~\]#

8. 进入文件系统,手动查看:

9.Windows 10 复制文件进入共享文件夹:

10.Linux 文件系统查看:

也可以命令行查看:

(这里文件不同是因为命令行查看是我几天后新加的,所以文件有改变)

[root@localhost ~]# mount -h

Usage:
 mount [-lhV]
 mount -a [options]
 mount [options] [--source] <source> | [--target] <directory>
 mount [options] <source> <directory>
 mount <operation> <mountpoint> [<target>]

Mount a filesystem.

Options:
 -a, --all               mount all filesystems mentioned in fstab
 -c, --no-canonicalize   don't canonicalize paths
 -f, --fake              dry run; skip the mount(2) syscall
 -F, --fork              fork off for each device (use with -a)
 -T, --fstab <path>      alternative file to /etc/fstab
 -i, --internal-only     don't call the mount.<type> helpers
 -l, --show-labels       show also filesystem labels
 -n, --no-mtab           don't write to /etc/mtab
 -o, --options <list>    comma-separated list of mount options
 -O, --test-opts <list>  limit the set of filesystems (use with -a)
 -r, --read-only         mount the filesystem read-only (same as -o ro)
 -t, --types <list>      limit the set of filesystem types
     --source <src>      explicitly specifies source (path, label, uuid)
     --target <target>   explicitly specifies mountpoint
 -v, --verbose           say what is being done
 -w, --rw, --read-write  mount the filesystem read-write (default)

 -h, --help              display this help
 -V, --version           display version

Source:
 -L, --label <label>     synonym for LABEL=<label>
 -U, --uuid <uuid>       synonym for UUID=<uuid>
 LABEL=<label>           specifies device by filesystem label
 UUID=<uuid>             specifies device by filesystem UUID
 PARTLABEL=<label>       specifies device by partition label
 PARTUUID=<uuid>         specifies device by partition UUID
 <device>                specifies device by path
 <directory>             mountpoint for bind mounts (see --bind/rbind)
 <file>                  regular file for loopdev setup

Operations:
 -B, --bind              mount a subtree somewhere else (same as -o bind)
 -M, --move              move a subtree to some other place
 -R, --rbind             mount a subtree and all submounts somewhere else
 --make-shared           mark a subtree as shared
 --make-slave            mark a subtree as slave
 --make-private          mark a subtree as private
 --make-unbindable       mark a subtree as unbindable
 --make-rshared          recursively mark a whole subtree as shared
 --make-rslave           recursively mark a whole subtree as slave
 --make-rprivate         recursively mark a whole subtree as private
 --make-runbindable      recursively mark a whole subtree as unbindable

For more details see mount(8).
options:-t

--types <list> limit the set of filesystem types
    限制文件系统类型集
--source <src> explicitly specifies source (path, label, uuid)
    显式指定源(路径、标签、uuid)uuid:https://baike.baidu.com/item/UUID/5921266?fr=aladdin
--target <target> explicitly specifies mountpoint
    显式指定挂载点

正文完
 0