Connecting your Linux Ubuntu 18.04 Virtual Machine to your Windows 10 Operating System - Rufian55/Docs GitHub Wiki

This doc describes the process of sharing a folder and files across a virtual machine running Ubuntu 18.04 as a guest OS running, in turn, on a Windows 10 host machine. The intent is to access a git repo directly from your VM instance and to keep repo working copies updatedand from a shared folder on your Windows machine. You want to do this because VM's get destroyed / rebooted, etc. and we want to preserve, update, and otherwise easily access the working copy to use with the wonderful IDE's / tools provided on Windows, such as Sublime, et. al. but still have the linux VM environment reflect changes and vice versa. This is particularly useful for things like setting up a Django Project and Applications development environment without the cost and expense of servers mirroring the production environment.

We assume you have created the new virtual machine on your desktop using Oracle VM VirtualBox Manager.

On you Host machine (Windows 10), add a new directory being sure to leave it empty. We use "Ruffian" here w/o quotes.

Right click the Ruffian directory folder, click Properties, Sharing, and Share. We only shared it with ourselves, but you can do more if you needed.

Now, In your Linux virtual machine instance:

Switch to the root user by entering the command - "sudo su"

Create an empty directory with a name of your choice, located conveniently next to or just above where your project files will live. We use "Ruffian" located in "/opt" as it seems easier to remember this way, but you can name the directories differently if you wish.

Enter: cd /opt mkdir Ruffian

Using the VM's window menu bar, select Devices → Shared Folders → Shared Folder Settings

Select "Machine Folders" and click the green + Folder icon on the right hand side. (See below.)

Insert 1.JPG here.

See illustration below.

In the Folder Path drop down, select "Other..." and a "Select Folder" window will immediately render. Select the directory you made on your windows machine - "rabbithole", located at C:\Users\ckearns\rabbithole (in the demo here), then click "Select Folder". You can also use "New Folder" and make one on the fly here - just make sure the directory you end up selecting is empty.

Now, back in the Add Share folder, select "Make Permanent" and OK.

Now, still in your Linux VM environment, enter:

yum update

yum install kernel-devel bzip2

The "yum update" process installed a new Linux kernel, which must be running before we can continue, so hard reboot here. Once the VM has restarted, use the VirtualBox UI's "Devices" menu to "Insert Guest Additions CD image..."

Enter:

mount -t iso9660 /dev/sr0 /mnt

cd /mnt

./VBoxLinuxAdditions.run

Once this finishes successfully:

cd /

umount /mnt

eject /dev/sr0

Remember, this all needs to be accomplished as root.

Reboot your VM again, login, change to root user, and enter: [Read]

sudo mount -t vboxsf $shared_folder_name $mount_point

...replacing

$shared_folder_name with the name of the windows/Mac OS folder you want to share - "rabbithole" here in this demo.

and

$mount_point with the location you want it to appear inside the VM - "wormhole" here in this demo (said location must be an empty directory)

Note: If you reboot your virtual machine without saving state or if this method isn';t working -

On your virtual Machine, "cd .." out of the wormhole directory if you are in it.

Then enter:

sudo mount -t vboxsf $shared_folder_name $mount_point

...replacing

$shared_folder_name with the name of the windows/Mac OS folder you want to share - "rabbithole" here in this demo.

and

$mount_point with the location you want it to appear inside the VM

If you find this unacceptably inconvenient, then use the below procedure to permanently set your share directories (for as long as your VM instance exists).

If you already have your shared folder mounted, unmount it with "umount $mount_point" (replacing $mount_point with the name of your linux share directory) before starting this procedure! (Notice the lack of an "n" in that command.)

Be sure you don't have any shell processes inside that directory currently, otherwise the system will consider the directory to be in use and not unmount it.

Edit "/etc/fstab" with your favorite editor ( "vi", "vim", "nano", "emacs", etc.) - this is a system file so you will need to use `sudo` or be logged in as root.

Add the following on a new line: " $named_of_shared_folder /path/to/empty/directory vboxsf " (An example would be " wormhole /usr/local/wormhole ".)

Save the file and exit your editor with "<esc></esc>wq!" .

"mount -a" (again, with "sudo" or as root) to mount everything in "/etc/fstab" "cd" to your (formerly) empty directory and see if everything worked - you should now see any files that you have in the shared folder.

⚠️ **GitHub.com Fallback** ⚠️