Share windows folder with linux virtualbox

How To Share a Folder From Windows to Arch Linux Guest OS in VirtualBox

I like many others, use a Linux virtual machine in VirtualBox from my Windows PC to do development work. There are many Linux distributions out there and many choose Ubuntu or some variant of it, I’ve chosen Manjaro which is an Arch based Linux. Completing tasks in Manjaro can be a bit different than in Ubuntu and other Debian Linux variants. One of those tasks is sharing a folder from my Windows PC through VirtualBox to my Manjaro Linux virtual machine. It’s not difficult, just a slight bit different and I will show you here how to share a windows folder with your Manjaro or Arch based Linux VM in VirtualBox.

Table of Contents

Before proceeding with the following steps, make sure that you have the VirtualBox Guest Additions installed on your Manjaro or Arch Linux virtual machine. You can install these required tools with the following command.

sudo pacman -Sy virtualbox-guest-utils

Create the Folder in Windows

The first step here is to either locate or create the folder you want to share from your Windows OS.

In my example here, it will be a folder in my Windows user directory called “Projects”. C:\Users\username\Projects

Create a Folder on Your Manjaro/Arch Linux VM

Next, we need to create a folder within the Manjaro VM, where the folder from Windows will appear.

For my example, I have created a folder within my Manjaro user account folder called “Shared_Projects”. cd /home/username/Shared_Projects

To create this folder you could use the following command from the Manjaro terminal prompt.

The ~ symbol is used here to represent the currently logged-in user’s home folder. You can choose any folder you want however, this is just an example.

Add the User Account to the VBOXSF User Group

When VirtualBox links the Windows folder to our Manjaro folder, it does so using the vboxsf group, which means that our user account must be a member of this group, otherwise, you will get permission errors. Adding a user to the vboxsf group just takes one command.

sudo usermod --append --groups vboxsf username

Run this command by replacing the username with your Manjaro Linux accounts username and this will make that account a member of the proper group to obtain access to the share folder files.

Setup the Share Folder in VirtualBox

In VirtualBox, we need to configure the folder we are sharing from Windows, along with the folder we are attaching it to in Manjaro. So open up VirtualBox and head to the settings of your virtual machine. In settings, you will find an option for “Shared Folders”. Click that option then on the right side you will see a folder icon with a plus symbol on it, this allows you to add new share folders. Click that icon to create your new shared folder.

Читайте также:  Red hat linux 2020

VirtualBox Shared Folder Windows and Manjaro Linux

In the folder path field, you put the path to the Windows folder you are sharing, it’s easier to just browse to the path by using the dropdown.

Folder Name is filled out automatically, no changes are needed here.

Check the Auto-mount box so that your folder is automatically available in Manjaro each time you boot up.

In the mount point field, this is where you put the path to the folder you created on Manjaro. We used the users home directory and a folder called Shared_Projects within it. So the path is /home/username/Shared_Projects.

Click ok to close the box, make sure the folder shows up under “Machine Folders” and not “Transient Folders”.

You can now power on or restart your Manjaro Linux VM and you will be able to access your newly created shared folder.

I’ve been working in the IT field for nearly 15 years, specifically with desktop engineering. I have a degree in Computer Science as well as some industry certifications from Microsoft. Outside of work, I have 21 years of experience in various programming languages and enjoy making toy projects. I’m also an avid Linux user, currently using Manjaro as my main OS. I enjoy writing about my experiences in programming and with Linux as well.

Источник

How to create Virtualbox shared folder between Windows host and Ubuntu18.04 guest machine [closed]

Closed. This question is not about programming or software development. It is not currently accepting answers.

This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.

I’ve read docs and all questions about sharing folder from host machine to Virtualbox’s guest machine and still can’t get it working. In my case the host is Windows machine and guest is Ubuntu18.04 server machine. What is advised and what I’ve already tried: 1) In the VM’s menu I found ‘devices’ submenu and clicked ‘Insert Guest Additions CD image’ option after which the CD icon in the status bar was lit and shows that the CD is inserted and the path to iso is C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso (I checked that file really exists there). 2) In the same ‘devices’ VM’s settings submenu I opened ‘Shared Folder Settings’ and added shared folder with name ‘test’ and path ‘D:\test’ which leads to the folder on my D: disk which contains test files. 3) I reboot my Ubuntu VM and look into /media directory expecting to find /media/cdrom directory or something like this with file VBoxLinuxAdditions.run in it, which should be run according to docs. But /media directory is empty so I have nothing to do with it. I looked for this file into other directories but had no success. After that I tried to install Virtualbox-guest-additions from repository as was advised on ubuntu forum:

sudo apt-get update sudo apt-get install virtualbox-guest-dkms 
mkdir -p /home/myusername/test sudo mount -t vboxsf test /home/myusername/test 
mount: /home/myusername/test: wrong fs type, bad option, bad superblock on /home/myusername/test, missing codepage or helper program or other error. 

I see there is no /sbin/mount.vboxsf link present, I’m not sure if this is a problem, also I tried add my user to ‘vboxsf’ group with:

sudo usermod -a -G vboxsf myusername 

Источник

Читайте также:  Check mbr or gpt linux

How to access a shared folder in VirtualBox?

I followed the steps for sharing folders between Windows 7 and Ubuntu in VirtualBox. Despite that the folder appears with a X sign and gives me the following message when a try to open it:

On the system page, you have assigned more than 50% of your computer’s memory (2.93 GB) to the virtual machine.

10 Answers 10

Access to shared folders in Virtual Box

Command line

By default, VirtualBox shared folders are created with read/write permission for the guest. This can be done from the command line on the host with:

VBoxManage sharedfolder add "VM name" --name sharename --hostpath "C:\test" 

By adding the option —readonly we can restrict these for read-only access. Use the —transient option if you only want the shares to appear in the present session but not persistent for following sessions. There are some limitations for shared folders (see this question for details). If prerequisites are met we may mount these shared folders manually by running the following commands in the guest:

mkdir /home//vboxshare sudo mount -t vboxsf -o uid=1000,gid=1000 sharename /home//vboxshare 

Of course, we can also use different mount options to mount as read/only or mount with read access only to root.

Auto-Mount through Virtual Box Manager

In case we enabled auto-mounting on creating a shared folder from the Virtual Box Manager those shared folders will automatically be mounted in the guest with mount point /media/sf_ . To have access to these folders users in the guest need to be a member of the group vboxsf .

sudo usermod -aG vboxsf $USER 

The guest will need to restart to have the new group added.

Source and further reading: Virtual Box User Manual

i set a shared folder in the GUI and also set the Auto-Mount. restarted the VM, went to /media but still nothing there

This command, suggested by another answer here, seems clearer and has better output: sudo adduser your_username vboxsf

@JordanBrough: totally correct — all ways lead to Rome. You can even use a graphical frontend users-admin . The command was edited in by another user.

Thanks for your answer.. in the command you mentioned above sudo mount -t vboxsf -o uid=1000,gid=1000 share /home//vboxshare , I don’t see a mention of the sharename , which is used when creating the shared folder using VBoxManage sharedfolder add «VM name» —name «sharename» —hostpath «C:\test» . If there are multiple shared folders.. how does VirtualBox know which sharename to associate the folder vboxshare with? Or do you mean that sharename should be the same as vboxshare ?

Actually there is an easy way to do that:

  1. Install the extension pack for VirtualBox.
  2. Restart your virtual machine
  3. Install Guest Additions in your guest Ubuntu
  • You can mount the ISO which is on /media or press Left Control + D
 sudo adduser your_vm_username vboxsf 

THIS. I wasn’t in the user group. Seems like that should have been automated by the gest additions or at least stated clearly.

@Atcold Logging out and in again adds the group to the current user (session) but did not trigger auto-mount of the shared folder in my case. Only a reboot did.

Читайте также:  Сменить линукс на винду

First, please make sure you have installed the Guest Additions

Insert Guest Additions CD image.

  1. Start your VM
  2. Devices > Insert Guest Additions CD image.
  3. Mount the CD:
sudo mount /dev/cdrom /media/cdrom 
sudo apt-get install make gcc linux-headers-$(uname -r) 
sudo /media/cdrom/VBoxLinuxAdditions.run 

Second, add your user to the group ‘vboxsf’:

~$ echo $USER; ahmed ~$ sudo usermod -a -G vboxsf ahmed 

Reboot

Know that the label of your shared folder is lpi (for example):

Edit shared folder

Prepend sf_ to the label. Then, you will find your shared folder under /media/sf_lpi

Finally, you can also create a link to your home. For example:

ln -s /media/sf_lpi /home/ahmed/lpi 

Can I use a shared folder from an Ubuntu VM without a harddisk image, but with only a Live CD image? Basically I am trying to add two CD drives, one holding the Ubuntu Live CD, and the other one holding the VBGuestAdditions.iso, and start the machine, then install VBGuestAdditions in the loopback root, and then I would like to be able to access a shared folder.

Also, is there a way to see the shared-folder before mounting, such as by using a command like lsblk or something?

When I try to do «sudo mount -t vboxsf mysharename mysharemountpoint», I always get: «/sbin/mount.vboxsf: mounting failed with the error: No such device»

Add the shared folder to the virtual machine using vBox graphical interface Make sure to select automount and make permanent

Login to the virtual machine using a root account

Check vboxsf group exists

~$ grep vboxsf /etc/group vboxsf:x:125: 

Check user is not already in vboxsf group

~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare) 

Add user nilo to vboxsf group

~$ sudo usermod -a -G vboxsf nilo 
~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf) 

Reboot and login as nilo

Shared folder is now accesible in /media/sf_dropbox (dropbox is the name I gave to the share)

Share a folder between Host OS-> Windows and Guest OS ->Ubuntu(Virtual box)

Step 1 Install install Guest Additions from VirtualBox’s menu go to Devices->Install Guest Additions This will mount a virtual CD on your /media/cdrom. As root user Open this /media/cdrom added folder using Open with terminal option(Right click with mouse).

Step 2 Run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

$ sudo ./VBoxLinuxAdditions.run 

Step 3 Create a shared folder. From Virtual menu go to Devices->Shared Folders then add a new folder in the list, this folder should be the one in windows which you want to share with Ubuntu(Guest OS). Make this created folder auto-mount. Example -> Make a folder on Desktop with name Ubuntushare and add this folder.

Step 4 When done with you shared folder(s) specification, we mount folder from Ubuntu(Guest OS). Create a mountpoint, this a directory in Ubuntu that will share files with the shared folder from Windows. Run this to create a directory in Ubuntu

$ sudo mkdir ~/Desktop/windowsshare 

Step 5 With your mountpoint created you can now mount the shared folder. Run this command to share the folder:

$ sudo mount -t vboxsf Ubuntushare ~/Desktop/windowsshare 

Ubuntushare is the name of folder we add in VirtualBox Devices section this folder is in Windows(Host OS). ~/Desktop/windowsshare is the directory in Ubuntu(Guest OS)

CONGRATULATIONS-> Now you can share the files between Windows and Ubuntu. Try adding any file in windows(Host OS) Ubuntu share folder now check Ubuntu(Guest OS) windowsshare directory the file will be reflected.

Источник

Оцените статью
Adblock
detector