Skip to content

Instantly share code, notes, and snippets.

@gbraad
Last active March 14, 2017 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gbraad/c66c7f00c101e34f8d7db2b2cbe9b943 to your computer and use it in GitHub Desktop.
Save gbraad/c66c7f00c101e34f8d7db2b2cbe9b943 to your computer and use it in GitHub Desktop.
Minishift hostfolders (manual mounting)

Minishift hostfolder (manual mounting)

Motivation

This allows a developer to mount their home directory inside the Minishift/CDK image, so they don't have to synchronize. This is to deal with the lack of Hyper-V offering a shared folder option like Guest Additions allows on Virtualbox for instance. In CDK a feature for sshfs was offered, but for Windows-based developers it is better to use the tools they are used to (such as not installing a ssh daemon, but using CIFS-based shares). Note: minikube only offers a similar functionality due to the fact of using Guest Additions in the B2D(Boot2Docker) image.

Video

"Minishift hostfolder (manual mounting)"

Steps

For the video we used Windows 10 + Hyper-V, running the CentOS-based LiveCD for Minishift. The environment was already bootstrapped with minishift start. This also works on our B2D-based image, and has been made consistent in usage between these two images.

# Prepare
PS> minishift.exe ssh "sudo mkdir -p /mnt/sda1/Disks ; sudo mkdir -p /mnt/sda1/Users"
PS> minishift.exe ssh
# and edit the credential files in /tmp/creds-disks and /tmp/creds-users

# This runs on CentOS 7
PS> minishift.exe ssh "cat /etc/os-release"

# We mount a samba exported fileshare
PS> minishift.exe ssh "sudo mount -t cifs //10.0.21.33/Disks/ /mnt/sda1/Disks/ -o credentials=/tmp/creds-disks"

/tmp/creds-disks

# /tmp/creds-disks looks as follows
username=root
password=[hidden]
# For the Windows Users share we have a problem
#   What is the host ip ? This can be anything in the IP range due to DHCP
#   Can be using a Microsoft Account or Domain (AD) account

PS> Get-NetIPAddress | Format-Table
PS> minishift hostip  # test command will check the intersection
PS> minishift.exe ssh "sudo mount -t cifs //10.0.21.122/Users/ /mnt/sda1/Users/ -o credentials=/tmp/creds-users"

/tmp/creds-users

# /tmp/creds-users looks as follows
username=gbraad@redhat.com
password=[hidden]
domain=RHGBWIN10
# Verify it got mounted
PS> minishift.exe ssh "mount | grep /mnt/sda1"
PS> minishift.exe ssh "ls -al /mnt/sda1/Users"
drwxr-xr-x. 2 root root 4096 Feb  7 20:03 .
drwxr-xr-x. 7 root root 4096 Mar 14 05:17 ..
dr-xr-xr-x. 2 root root    0 Feb  7 20:08 Default
drwxr-xr-x. 2 root root    0 Feb  7 20:04 Default.migrated
-rwxr-xr-x. 1 root root  174 Jul 16  2016 desktop.ini
drwxr-xr-x. 2 root root    0 Mar 14 05:10 gbraad

Images 'speak' louder than words ;-) "Minishift hostfolder (preview)"

Now what?

Most of the mentioned steps are identical to those needed for sshfs, such as mounting and determining the host IP address to address the host.

Automated functionality is shown in: https://www.youtube.com/watch?v=fJFvg69iEjw (currently under review and subject to change). Code is already prepared for use of mounting with other possible storage backends, eg. sshfs, nfs.

The following commands would be introduced:

$ minishift hostfolder [mount|umount|add|remove|view]

"Minishift hostfolder (automated mounting)"

Demo-ed by

"Gerard Braad"
@gbraad
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment