Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to mount filesystems #39

Closed
blissdev opened this issue Jun 19, 2019 · 8 comments
Closed

How to mount filesystems #39

blissdev opened this issue Jun 19, 2019 · 8 comments

Comments

@blissdev
Copy link

Are there any guides on usage especially regarding mounts? I'm interested in setting up a development environment using slim and hyperkit, but I need to mount my code in a performant manner. Any other tips or writeups out there? This may be the wrong place to ask, feel free to point me in a different direction.

@chrisparnin
Copy link
Contributor

Yes, this is very possible. We’ve had this working in our embedded ansible server (Baker) for virtualbox and hyper-kit. Will create a demo Dockerfile with this working.

@chrisparnin
Copy link
Contributor

chrisparnin commented Jun 19, 2019

The basic idea for virtualbox is up and running. Requires a few steps, with pointers to line in Dockerfile or init: https://github.com/ottomatica/slim-images/tree/master/alpine3.8-vbox-mount

  • Need to add virtualbox-guest-modules-virt to kernel layer in order to get right kernel modules.

  • Need to add virtualbox-guest-additions to main layer.

  • Need to mount share in init:

    modprobe vboxsf 
    mkdir -p /shared
    mount.vboxsf -o uid=1000,gid=1000 vbox-share-0 /shared
    

Now, can access shared folder (set to / of host-system by virtualbox-provider).

$ slim build alpine3.8-vbox-mount
$ slim run m0 alpine3.8-vbox-mount
...
Executing VBoxManage sharedfolder add m0 --name "vbox-share-0" --hostpath "/" 
....
nanobox:~# ls /shared/Users/cjparnin/projects/slim-images/
README.md               alpine3.8-kubernetes    alpine3.9-runc-ansible  ubuntu16.04-kubernetes
alpine3.8-datascience   alpine3.8-vbox-mount    docs                    ubuntu16.04-simple

Hyperkit, is going to be a bit more "gnarly".

@chrisparnin
Copy link
Contributor

chrisparnin commented Jun 20, 2019

Ok, proof-of-concept for hyperkit shared folders for @blissdev:
image

First, build this image in the slim-images repo.

slim build slim-images/alpine3.8-9p-mount

The main difference is that you just add steps to mount the 9p network filesystem in the init script.

# 9p
mkdir -p /shared
modprobe 9pnet_virtio
mount -t 9p -o trans=virtio shared /shared 

However, the real difference is how you run hyperkit (see run.sh).

a) You need to pass a unix socket that will be used for 9p protocol.
b) You need a 9p filesystem server running.

I've provided a proof of concept script that does this. It will boot up this image directly in hyperkit.

cd slim-images/alpine3.8-9p-mount/scripts/ && ./run.sh 
...
nanobox:~# ls /shared/
Applications               home
Library                    installer.failurerequests
Network                    net
System                     opt
Users                      private

At some point, we can migrate some of this leg work into slim.

@blissdev
Copy link
Author

@chrisparnin Wow, thank you so much for putting this together! I was initially thinking that hyperkit may provide a better experience, but from your perspective what do you think is the better option? Will hyperkit be lighter weight? Any advice?

@chrisparnin
Copy link
Contributor

chrisparnin commented Jun 20, 2019

Honestly, this is probably something that would best be answered with longer term experimentation.

My use cases tends to center around being able to quickly spin up VMs, doing some local testing for infrastructure scripts, and throwing them away. For this, VirtualBox, isn't so bad, and actually can be ready just as fast as hyperkit. Hyperkit might be better for compute heavy tasks, but it is also pretty rough around the edges when it comes to other features.

@blissdev
Copy link
Author

Guess I'll have to experiment, thanks again! :)

@gjabell
Copy link
Contributor

gjabell commented Jun 23, 2019

Slim will now automatically mount / at /host and cwd (ie the directory where you run the slim run command) at /slim within the VM. This automounting can be disabled by passing the --nosync option in the slim run command.

@chrisparnin
Copy link
Contributor

Closing issue since we now support sync by default. Can revisit any problems with new issue. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants