Монтирование папки linux vmware

darrenpmeyer / open-vm-tools-vmware-ubuntu-sharing.md

(NB: adapted from this Ask Ubuntu thread — tested to work on Ubuntu 16.04 LTS through Ubuntu 22.04 LTS (Jammy).

Unlike using VMWare Tools to enable Linux guest capabilities, the open-vm-tools package doesn’t auto-mount shared VMWare folders. This can be frustrating in various ways, but there’s an easy fix.

Install open-vm-tools and run:

sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other 

(Make sure /mnt/hgfs exists and is empty)

You can put configuration stanzas in /etc/fstab to facilitate this, and then mount /mnt/hgfs will work.

See the Setting up auto-mounting section for setting up auto-mounting instead.

Make sure open-vm-tools (and open-vm-tools-desktop if you’re using a desktop environment) are installed, and that you’ve rebooted after their installation.

sudo apt update sudo apt install open-vm-tools open-vm-tools-desktop 

Make sure you have a /mnt/hgfs directory made and empty. If not:

To mount the filesystem, run:

sudo mount -t fuse.vmhgfs-fuse .host:/ /mnt/hgfs -o allow_other 

The shared folders will now be in subdirectories of /mnt/hgfs

Add the following line to /etc/fstab :

.host:/ /mnt/hgfs fuse.vmhgfs-fuse auto,allow_other 0 0 

Update: based on extensive testing, the auto keyword seems to work fine. Prior versions suggested noauto . If you have trouble with auto , change to noauto and see below

If using the noauto keyword, but you want automount

    make sure rc.local is executable and owned by root:

sudo chown root:root /etc/rc.local sudo chmod 0755 /etc/rc.local 
sudo systemctl enable rc-local.service 

The rc.local script runs as the last step of startup, allowing the HGFS filesystem to mount after open-vm-tools services are running, which is required for successful operation.

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

#! /usr/bin/env bash
# # this must be run as root!
# # It should set up VMWare Shared folders on Ubuntu guests using open-vm-tools
# # USAGE setup-hgfs-automount-ubuntu.sh [noauto]
rclocal= » /etc/rc.local «
owner= » root:root «
mountpoint= » /mnt/hgfs «
# # fail if we’re not run as root
if [ » $EUID » != 0 ]
then
( >&2 echo » $0 must be run as root » )
exit 127
fi
# # set up FSTAB
mkdir -p $mountpoint
if [ » $1 » == » noauto » ]
then
echo » .host:/ $ fuse.vmhgfs-fuse nauto,allow_other 0 0 » >> /etc/fstab
else
echo » .host:/ $ fuse.vmhgfs-fuse auto,allow_other 0 0 » >> /etc/fstab
echo » You may now ` mount $ ` ; it will also be auto-mounted on next boot «
exit 0
# if using the `auto` keyword, no rc.local setup is required, and we’re done here.
fi
# # set up rc.local script
if ! [ -f » $rclocal » ]
then
echo ‘ #!/bin/sh ‘ > » $rclocal «
fi
echo » mount ‘ $mountpoint ‘ » >> » $rclocal «
chown $owner » $rclocal «
chmod 0755 » $rclocal «
# # enable rc.local service
systemctl enable rc-local.service
systemctl start rc-local.service
# # report and exit
( >&2 echo -e » set up and started $rclocal \nyou should be able to browse $mountpoint now and after reboots » )
exit 0
Читайте также:  Update initramfs astra linux

I tested your solution for auto-mounting with the option auto instead of noauto and it worked fine (Ubuntu 18.04). Can be considered as a valid solution or may cause problems in future?
BTW: congrats for good info.

I did the same thing in fstab and used option «auto» instead of «noauto» and it worked fine (Ubuntu 18.04).
No need «rc.local» at all.

Tested with elementary-os (16.04 based) with «auto», and works fine.

I did the same in fstab i.e «auto» and it worked(Ubuntu 18.04.1 LTS) and VMware Workstation 14 Player.
Thanks a lot for sharing this info.

nice work. auto in /etc/fstab seem to work fine on ubuntu 19.04 / vmw workstation 15.03

Can confirm this also works on PopOS 19.10 & VMware Fusion 11.5.1 — with the auto option instead of noauto

I tested your solution for auto-mounting with the option auto instead of noauto and it worked fine (Ubuntu 18.04). Can be considered as a valid solution or may cause problems in future?

I haven’t tested with Ubuntu 18.04; I can’t validate. It’s good news that they seem to have fixed the issue that required the rc.local workaround, but I don’t know what the issue was so I can’t comment about how safe it is to switch to using auto . It seems easy enough to fix either way, but for now I know that noauto + an rc.local script always works.

You’re probably better off using autofs rather than putting an entry in fstab. As the author pointed out, bad things can happen if the mount cannot happen at the proper point in the boot process and you have an entry in fstab that for whatever reason can’t mount, blowing the boot process out of the water. With autofs, the mount doesn’t occur until you actually try to stat below the mount point.

  1. Install autofs through your package manager
  2. Create a mount point for autofs:
    sudo mkdir /mnt/autofs
  3. Create a file (as root):
    /etc/auto.master.d/hgfs.autofs
    with the contents:
    /mnt/autofs /etc/auto.mnt
  4. Create a file (as root):
    /etc/auto.mnt
    with the contents (assuming you didn’t rename «Macintosh HD» in OS X):
    hgfs -fstype=fuse.vmhgfs-fuse,allow_other .host:/Macintosh\ HD
  5. enable autofs to start at boot, restart the service, and reload the autofs configs we just made:
    sudo systemctl enable autofs
    sudo systemctl restart autofs
    sudo systemctl reload autofs
  6. Navigate to your new automount, which will be your root OS X file system:
    cd /mnt/autofs/hgfs # fuse file system will mount on this command
  7. If you’re really ambitious, you could:
    sudo ln -s /mnt/autofs/hgfs /mnt
    cd /mnt/hgfs # fuse file system will mount on this command
Читайте также:  Linux включить вай фай

Confirmed, in (Kubuntu) Ubuntu 20.04, I only had to add the following line to /etc/fstab , then reboot:

.host:/ /mnt/hgfs fuse.vmhgfs-fuse auto,allow_other 0 0

No other steps were necessary for me.

I have domain user in AD with LDAP UID/GID, so I set uid=,gid= and permissions/ownership persist across platforms (note: I use local account in Linux, I just change the UID/GID of the account so AD knows who it is)

Adding the one line to /etc/fstab also worked for me.

I am using VMware Fusion 12.2.1 on macOS 11.6.1 (Big Sur) with an Ubuntu 18.04.2 guest. I had tried using the VMware Tools package supplied by VMware Fusion. The /mnt/hgfs service worked fine, but copy-and-paste between the guest and host did not work at all. Using the open-vm-tools-desktop package instead of VMware Tools solved the copy/paste issue, but /mnt/hgfs was empty until I opened the VM settings and toggled «Enable Shared Folders» off then on.

Great little piece of knowledge. All good for me.

Worked for me too. Thank you

@kfreund I followed your steps precisely but it didn’t load the shared folders.

root@debian:/home/debian# cat /etc/auto.master.d/hgfs.autofs /mnt/autofs /etc/auto.mnt root@debian:/home/debian# cat /etc/auto.mnt hgfs -fstype=fuse.vmhgfs-fuse,allow_other,uid=1000 .host:/ root@debian:/home/debian# automount -f -v Starting automounter version 5.1.8, master map /etc/auto.master using kernel protocol version 5.05 lookup_nss_read_master: reading master file /etc/auto.master do_init: parse(sun): init gathered global options: (null) lookup_read_master: lookup(file): read entry +dir:/etc/auto.master.d lookup_nss_read_master: reading master dir /etc/auto.master.d lookup_read_master: lookup(dir): scandir: /etc/auto.master.d include_file: lookup(dir): include: /etc/auto.master.d/hgfs.autofs lookup_nss_read_master: reading master file /etc/auto.master.d/hgfs.autofs do_init: parse(sun): init gathered global options: (null) lookup_read_master: lookup(file): read entry /mnt/autofs lookup_read_master: lookup(file): read entry +auto.master lookup_nss_read_master: reading master files auto.master do_init: parse(sun): init gathered global options: (null) master_do_mount: mounting /mnt/autofs automount_path_to_fifo: fifo name /var/run/autofs.fifo-mnt-autofs lookup_nss_read_map: reading map file /etc/auto.mnt do_init: parse(sun): init gathered global options: (null) mounted indirect on /mnt/autofs with timeout 300, freq 75 seconds st_ready: st_ready(): state = 0 path /mnt/autofs 
root@debian:/home/debian# vmhgfs-fuse .host:/ /mnt/hgfs/ -o allow_other -o uid=1000 root@debian:/home/debian# ls /mnt/hgfs/ Desktop 

But it is not a solution for putting into the /etc/fstab file if shared folders have not been enabled yet.

Источник

Монтирование папки linux vmware

You are using an outdated browser. Please upgrade your browser to improve your experience.

After you enable a shared folder, you can mount one or more directories or subdirectories in the shared folder to any location in the file system in addition to the default location of /mnt/hgfs .

Depending on the kernel version of the Linux guest operating system, VMware Tools uses different components to provide shared-folder functionality. In Linux kernels prior to version 4.0, the VMware Tools services script loads a driver that performs the mount. Linux kernels 4.0 and later use a FUSE file system component.

You can use different mount commands to mount all shares, one share, or a subdirectory within a share to any location in the file system. The commands also vary depending on the Linux-kernel version of the guest.

Читайте также:  Операционные системы семейства linux версии

Table 1. Mount Command Syntax

Linux Kernel Prior to 4.0 Linux Kernel 4.0 and Later Description
mount -t vmhgfs .host:/ /home/user1/shares /usr/bin/vmhgfs-fuse .host:/ /home/user1/shares -o subtype=vmhgfs-fuse,allow_other Mounts all shares to /home/user1/shares
mount -t vmhgfs .host:/foo /tmp/foo /usr/bin/vmhgfs-fuse .host:/foo /tmp/foo -o subtype=vmhgfs-fuse,allow_other Mounts the share named foo to /tmp/foo
mount -t vmhgfs .host:/foo/bar /var/lib/bar /usr/bin/vmhgfs-fuse .host:/foo/bar /var/lib/bar -o subtype=vmhgfs-fuse,allow_other Mounts the subdirectory bar within the share foo to /var/lib/bar

For Linux kernel prior to version 4.0, you can use VMware-specific options in addition to the standard mount syntax. Enter the command /sbin/mount.vmhgfs -h to list the options.

For Linux kernel version 4.0 or later, enter the command /usr/bin/vmhgfs-fuse -h to list the available options.

Note: The mount can fail if shared folders are disabled or if the share does not exist. You are not prompted to run the VMware Tools vmware-config-tools.pl configuration program again.

Источник

Монтирование папки linux vmware

You are using an outdated browser. Please upgrade your browser to improve your experience.

After you enable a shared folder, you can mount one or more directories or subdirectories in the shared folder to any location in the file system in addition to the default location of /mnt/hgfs .

Depending on the kernel version of the Linux guest operating system, VMware Tools uses different components to provide shared-folder functionality. In Linux kernels prior to version 4.0, the VMware Tools services script loads a driver that performs the mount. Linux kernels 4.0 and later use a FUSE file system component.

You can use different mount commands to mount all shares, one share, or a subdirectory within a share to any location in the file system. The commands also vary depending on the Linux-kernel version of the guest.

Table 1. Mount Command Syntax

Linux Kernel Prior to 4.0 Linux Kernel 4.0 and Later Description
mount -t vmhgfs .host:/ /home/user1/shares /usr/bin/vmhgfs-fuse .host:/ /home/user1/shares -o subtype=vmhgfs-fuse,allow_other Mounts all shares to /home/user1/shares
mount -t vmhgfs .host:/foo /tmp/foo /usr/bin/vmhgfs-fuse .host:/foo /tmp/foo -o subtype=vmhgfs-fuse,allow_other Mounts the share named foo to /tmp/foo
mount -t vmhgfs .host:/foo/bar /var/lib/bar /usr/bin/vmhgfs-fuse .host:/foo/bar /var/lib/bar -o subtype=vmhgfs-fuse,allow_other Mounts the subdirectory bar within the share foo to /var/lib/bar

For Linux kernel prior to version 4.0, you can use VMware-specific options in addition to the standard mount syntax. Enter the command /sbin/mount.vmhgfs -h to list the options.

For Linux kernel version 4.0 or later, enter the command /usr/bin/vmhgfs-fuse -h to list the available options.

Note: The mount can fail if shared folders are not enabled or if the share does not exist. You are not prompted to run the VMware Tools vmware-config-tools.pl configuration program again.

Источник

Оцените статью
Adblock
detector