Chapter 6. Host Folders
6.1. Host Folders Overview
Host folders are directories on the host which are shared between the host and the Minishift VM. They allow for a two way file synchronization between host and VM. The following sections discuss the various types of host folders, driver provided host folders, as well as the Minishift hostfolder
command.
6.2. Driver Provided Host Folders
Some drivers mount a default host folder into the VM in order to share files between the VM and the host. These folders are currently not configurable and differ for each driver and OS.
Driver | OS | HostFolder | VM |
---|---|---|---|
Virtualbox | Linux | /home | /hosthome |
Virtualbox | OSX | /Users | /Users |
Virtualbox | Windows | C://Users | /c/Users |
VMWare Fusion | OSX | /Users | /Users |
Xhyve | OSX | /Users | /Users |
Host folder sharing is not implemented in the KVM and Hyper-V drivers. If you use one of these drivers, you need to use Minishift specific host folder options.
6.3. Minishift hostfolder Command
Minishift provides the hostfolder
command to list, add, mount, unmount and remove host folders. In contrast to the driver provided host folders, the hostfolder
command allows you to mount multiple shared folders onto custom specified mount points.
At the moment only CIFS is supported as host folder type. Support for SSHFS based host folders is in progress (see GitHub issue #317).
If you want to use SSHFS now, refer to Section 6.10, “SSHFS Host Folders” for manual instructions.
The following sections describe the prerequisite for using the hostfolder
command, as well as the various sub-commands it provides.
6.4. Prerequisite
To use the hostfolder command, you need to be able to share directories using CIFS. On Windows CIFS is the default technology for sharing directories. For example, on Microsoft Windows 10 the C:\Users folder is shared by default and can be accessed by locally-authenticated users.
It is also possible to use CIFS on OS X and Linux. On the former you can enable CIFS based shares under System Preferences > Sharing. Refer to How to connect with File Sharing on your Mac for detailed setup instructions.
On Red Hat Enterprise Linux, install samba with yum:
~]$ yum install "samba-*"
6.5. Displaying Host Folders
The hostfolder list
command gives you an overview of the defined host folders, their name, mount point, remote path and whether they are currently mounted. An example output could look like:
~]$ minishift hostfolder list
Name Mountpoint Remote path Mounted
myshare /mnt/sda1/myshare //192.168.1.82/MYSHARE N
In this example, there is a host folder with the name myshare which mounts //192.168.1.82/MYSHARE
onto /mnt/sda1/myshare
in the Minishift VM. The share is currently not mounted.
The remote path must be reachable from within the VM. In the example above 192.168.1.82 is the IP of host within the LAN which is one options one can use. You can use ifconfig
(or Get-NetIPAddress | Format-Table
on Windows) to determine a routable IP address.
6.6. Adding Host Folders
The hostfolder add
command allows you to define a new host folder. This in an interactive process which queries the relevant details for a host folder based on CIFS.
Adding a CIFS based hostfolder
~]$ minishift hostfolder add myshare 1 UNC path: //192.168.99.1/MYSHARE 2 Mountpoint [/mnt/sda1/myshare]: 3 Username: john 4 Password: [HIDDEN] 5 Domain: 6 Added: myshare
- 1
- (Required) Actual
hostfolder add
command, specifying a hostfolder with a name of myshare. - 2
- (Required) The UNC path for the share.
- 3
- The mount point within the VM. The default is
/mnt/sda1/<host folder name>
. - 4
- (Required) The username for the CIFS share.
- 5
- (Required) The password for the CIFS share.
- 6
- The domain of the share. Often this can be left blank, but for example on Windows, when your account is linked to a Microsoft account, you must use the Microsoft account email address as username as well as your machine name as displayed by $env:COMPUTERNAME as domain.
On Windows hosts the hostfolder add
command also provides a users-share option. When specified no UNC path needs to be specified and the C:\Users
is assumed.
When you use the Boot2Docker ISO along with the VirtualBox driver, VirtualBox guest additions are automatically enabled and occupy the /Users
mountpoint.
6.6.1. Instance Specific Host Folders
Per default, host folder definitions are persistent, similar to options specified using the minishift config
command explained in the the section Section 3.2.3, “Persistent Configuration”. This means that these host folder definitions will survive the deletion and subsequent re-creation of a Minishift VM.
In some cases you might want to define a host folder just for a specific Minishift instance. To do so you can use the instance-only flag of the hostfolder add
command. Host folder definition created with the instance-only flag will be removed together with any other instance specific state during minishift delete
.
6.7. Mounting Host Folders
Once you have added your host folder definitions, the hostfolder mount
command allows you to mount a host folder by its name:
~]$ minishift hostfolder mount myshare
Mounting 'myshare': '//192.168.99.1/MYSHARE' as '/mnt/sda1/myshare' ... OK
You can verify that the host folder is mounted by running:
~]$ minishift hostfolder list
Name Mountpoint Remote path Mounted
myshare /mnt/sda1/myshare //192.168.99.1/MYSHARE Y
Alternatively, you can list the actual content of the mounted host folder:
~]$ minishift ssh "ls -al /mnt/sda1/myshare"
6.7.1. Auto-mounting Host Folders
Host folders can also be mounted automatically on each minishift start
. To achieve this you need to set the persistent configuration option hostfolders-automount:
~]$ minishift config set hostfolders-automount true
Once hostfolders-automount is set, Minishift will attempt to mount all defined host folders during minishift start
.
6.8. Unmounting host folders
In contrast to the hostfolder add
command, hostfolder umount
can be used to unmount a host folder:
~]$ minishift hostfolder umount myshare Unmounting 'myshare' ... OK ~]$ minishift hostfolder list Name Mountpoint Remote path Mounted myshare /mnt/sda1/myshare //192.168.99.1/MYSHARE N
6.9. Deleting Host Folders
The hostfolder remove
command finally enabled you to remove a host folder definition:
~]$ minishift hostfolder list Name Mountpoint Remote path Mounted myshare /mnt/sda1/myshare //192.168.1.82/MYSHARE N ~]$ minishift hostfolder remove myshare Removed: myshare ~]$ minishift hostfolder list No host folders defined
6.10. SSHFS Host Folders
This host folder type is not supported by the hostfolder
command for now. You need to manually configure it.
You can also use SSHFS-based host folders provided you have an SSH daemon running on your host. Normally, this prerequisite is met by default on Red Hat Enterprise Linux and macOS.
To use the SSH server on macOS, make sure that Remote Login is enabled in System Preferences > Sharing.
On Microsoft Windows you can install OpenSSH for Windows.
The following steps demonstrate how to mount host folders with SSHFS.
-
Run
ip address show
on Red Hat Enterprise Linux,ifconfig
on macOS,(orGet-NetIPAddress
on Microsoft Windows) to determine the local IP address from the same network segment as your Minishift instance. Create a mountpoint and mount the shared folder.
~]$ minishift ssh "sudo mkdir -p /Users/<username>" ~]$ minishift ssh "sudo chown -R docker /Users" ~]$ minishift ssh ~]$ sshfs <username>@<IP>:/Users/<username>/ /Users
Verify the share mount.
~]$ minishift ssh "ls -al /Users/<username>"