CentOS and Windows shared folder

Posted Jun 16, 20203 min read

  1. Virtual Machine -> Settings
    1.png

  2. Options -> Shared Folder -> Always Enable -> Add Open Wizard -> Next
    2.png

  3. Select the host path, that is, the folder in the Windows system, you can also create a new folder at a specified location
    3.png

  4. Enable sharing, click Finish
    4.png

  5. Click OK
    5.png

  6. Enter CentOS, enter the mnt folder(cd mnt, you can also directly create a folder in the root directory:mkdir /mnt/share)
    Create a shared folder:mkdir share
    Mount:mount -t fuse.vmhgfs-fuse .host://mnt/share/-o allow_other
    (The detailed explanation of the command is at the end, if you want to customize the location of the shared folder in Linux, you can refer to the last command analysis to change the command yourself)
    6.png

  7. Permanent mount settings
    Command:vi /etc/fstab
    .host://mnt/share fuse.vmhgfs-fuse allow_other 0 0
    7.png
    After editing, press the key:Esc -> :wq, save and exit
    The following is my operation history. Generally, creating a folder will not fail, so the ls command can check whether the creation is successful.

    [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. Enter the file system and manually view:
    8.png

  9. Windows 10 copy files into the shared folder:
    9.png

  10. View the Linux file system:
    10.png
    You can also view it from the command line:
    11.png
    (The file here is different because the command line view was added by me a few days later, so the file has changed)

    [root@localhost ~]# mount -h

    Usage:
    mount [-lhV]
    mount -a [options]
    mount [options][--source] | [--target]
    mount [options]
    mount []

    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 alternative file to /etc/fstab
    -i, --internal-only don't call the mount. helpers
    -l, --show-labels show also filesystem labels
    -n, --no-mtab don't write to /etc/mtab
    -o, --options comma-separated list of mount options
    -O, --test-opts limit the set of filesystems(use with -a)
    -r, --read-only mount the filesystem read-only(same as -o ro)
    -t, --types 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

    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 limit the set of filesystem types

    Restrict file system type set

    --source explicitly specifies source(path, label, uuid)

    Specify the source explicitly(path, label, uuid)
    uuid:https://baike.baidu.com/item/UUID/5921266?fr=aladdin

    --target explicitly specifies mountpoint

    Specify the mount point explicitly