Your cloud app development can be made even easier with the help of sharing data between a Multipass VM and a locally hosted directory.
If you've started using Multipass as your virtual machine (VM) tool for developing your cloud apps and services, you might find yourself needing to share data between your host and your virtual machines. By doing this, you can more easily work with your VMs. Place all of your code in one local directory and mount it, as needed, to the various virtual machines you spin up.
I'm going to show you how to do just that--mount a local directory into a virtual machine deployed by Multipass. The process is incredibly easy, so you'll be adding this to your VM toolkit quickly.
SEE: Serverless computing: A guide for IT leaders (TechRepublic Premium)
What you'll need
A running instance of Multipass
A local directory to mount
I'll be demonstrating on Pop!_OS, but the platform you use doesn't matter, so long as it supports Multipass.
How to spin up a virtual machine
The first thing you need to do is spin up a virtual machine. You can do this with a VM that is already up and running, but let's test it with a new instance.
To spin up a new VM with multipass, issue the command:
multipass launch --name cloud-host
To make sure your new VM is up and running (Figure A), issue the command:
How to share a directory between host and virtual machine
To share a directory between host and VM, it has to be mounted. Say you want to share the directory ~/code to the newly created cloud-host VM. To mount this to the VM, issue the command:
multipass mount ~/code cloud-host
After a few seconds, you'll get your prompt back, with no errors. To make sure the mount was successful, issue the command:
multipass info cloud-host
You should see the new mount listed (Figure B).
Copy files to ~/code and then gain access to the VM with the command:
multipass shell cloud-host
Change into the directory housing the mount, which is presented within output of the multipass info cloud-host command, and issue the ls command. You should see the file(s) you added listed (Figure C).
How to unmount a directory
Once you've finished working, you might want to unmount that shared directory. To do so, issue the command:
multipass unmount cloud-host
The shared directory will no longer be accessible to the virtual machine. The VM directory will remain, but the files that were listed are no longer there (Figure D).
And that's all there is to sharing data between a host and a Multipass VM. As you can see, this task couldn't possibly be any simpler. At this point, you might be thinking Multipass might be the perfect VM tool to meet your cloud development needs.
- Hybrid cloud: A guide for IT pros (TechRepublic download)
- How to use Multipass, a new tool for launching virtual machines (TechRepublic)
- How to quickly spin up MicroK8s with Multipass (TechRepublic)
- How to manage VMs from the Multipass system tray tool (TechRepublic)
- How to add ISO images to VirtualBox 6 (TechRepublic)
- Zendesk launches Sales Suite, bundling Zendesk Sell, Chat and other tools (ZDNet)
- Best cloud services for small businesses (CNET)
- Cloud computing: More must-read coverage (TechRepublic on Flipboard)