How to share folders with your ubuntu virtual machine (guest)
Joseph Russell
Published Mar 29, 2026
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:
The folder content could not be displayed
When I choose Shared Folder from the VirtualBox Device menu, the following warning is displayed:
On the system page, you have assigned more than 50% of your computer’s memory (2.93 GB) to the virtual machine.
How can I successfully share folders between Windows and Ubuntu using VirtualBox?
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:
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:
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 .
The guest will need to restart to have the new group added.
Source and further reading: Virtual Box User Manual
Actually there is an easy way to do that:
- Install the extension pack for VirtualBox.
- Restart your virtual machine
- Install Guest Additions in your guest Ubuntu
- You can mount the ISO which is on /media or press Left Control + D
Try to access /media/sf_your_shared_folder_name . If you still don’t have access, that means you don’t belong to the vboxsf group. Run this command in the virtual machine:
Log out and log in again to apply changes of adduser . If you still can not access the folder, try rebooting.
If you still can not see the shared folder, you have to mount it. You can activate automount for the shared folder in the options of VirtualBox Manager.
First, please make sure you have installed the Guest Additions
Devices > Insert Guest Additions CD image.
Install the necessary packages:
Second, add your user to the group ‘vboxsf’:
Reboot
Know that the label of your shared folder is lpi (for example):
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:
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
Check user is not already in vboxsf group
Add user nilo to vboxsf group
Check again user groups
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.
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
Step 5 With your mountpoint created you can now mount the shared folder. Run this command to share the folder:
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.
Sometimes you need to share data files between your host computer and your Ubuntu virtualbox. In this tutorial, you will learn how to achieve this so that you will be able to access folders or files on your host computer from your Ubuntu virtualbox.
Installing guest additions
Before starting the sharting process, it is mandatory to install your so called virtualbox guest additions. This will allow you to use some cool features such copy and paste, folder sharing and mouse integration.
We have written a small article on how to do this in case your virtualbox runs on Ubuntu . If however your virtualbox runs on Windows, you may want to check this articl e.
Enabling shared folders
Now that you have installed the guest additions, select your Ubuntu virtual machine as shown below :
And then click on Settings on the menu bar. The popup below will show up. Select the Shared Folders item.
On the right hand side, click on the icon with the Add sign. The dialog box below will be displayed.
Once you click on the Folder Path drop-down list, select the ‘Other’ item.
You will be able to select a folder to be shared with your virtualbox. See snapshot below.
Once the folder is chosen, its full path will be inserted. Tick the checkbox Auto-mount. Click on OK to finish.
The selected folder will be displayed in the Transient Folders List as shown below. Click OK to close the window.
Now run your Ubuntu virtualbox and open up a terminal session.
Run the command below as root :
sudo apt install virtualbox-guest-utils
Once completed, exit the terminal.
Now open your file explorer :
Virtualbox shared folders
You will see your shared folder but with the string “sf_” added at the beginning.
If you click on the shared folder you will most likely see the error message below :
Virtualbox shared folder Ubuntu
In order to access the shared folders, you would need to add your user to a group called vboxsf (there are users and groups). Open up your terminal and run the command below :
sudo adduser [username] vboxsf
Now enter the command :
And access again your shared folder. You will be able to create/delete/change files .
Virtualbox shared folders Linux
If you like the content, we would appreciate your support by buying us a coffee. Thank you so much for your visit and support.
Lowell is the founder and CEO of How-To Geek. He’s been running the show since creating the site back in 2006. Over the last decade, Lowell has personally written more than 1000 articles which have been viewed by over 250 million people. Prior to starting How-To Geek, Lowell spent 15 years working in IT doing consulting, cybersecurity, database management, and programming work. Read more.
VMware Workstation provides a great ability to create shared folders so that your virtual machine can easily access data on your host pc. This saves a lot of time, especially when you are installing software that would otherwise take a long time to download.
For this to work, you will need to make sure that you have the vmware tools installed and running.
You can check to see if the vmware shared folders module is running by running this command:
If you get nothing then the mdoule is not loaded. You will need to load it with this command:
If that gives you another error, then you don’t have the vmware tools installed, and you will want to make sure to install them before proceeding.
In VMware Workstation, go to the VM \ Settings window and then click on the Options tab. From here you can modify the shared folders.
Click the Add button, and you will be presented with a wizard. Click next, and you should see this screen:
The name field will become part of the mounted path in Ubuntu, so name it something short and to the point. For instance, this shared folder will be mounted on /mnt/hgfs/mydrive/
Select the host folder that you want to share and then click the Next button
If you are worried about the guest operating system messing with your files, you can select the read-only checkbox. I personally did so simply because I was worried about accessing in-use files.
You shouldn’t even have to restart your virtual machine. The folders should immediately show up under /mnt/hgfs
That’s all there is to it. Remember, if you have problems it’s probably because your vmware tools are not installed.
Tested on: Ubuntu Dapper, Ubuntu Edgy Eft
Update: If you have problems you might also want to check your firewall settings, which could be disabling communications between the virtual machine and your host computer. Thanks to burkhard in the comments for noticing this.
Lori Kaufman is a technology expert with 25 years of experience. She’s been a senior technical writer, worked as a programmer, and has even run her own multi-location business. Read more.
VirtualBox is a program that allows you to run multiple operating systems (guests) on one computer (the host computer). You may need to transfer files between the host and the guest. It’s easy to set up in Windows guests, but tricky in Ubuntu guests.
We’ll show you how to set up an Ubuntu guest machine so you can access folders on the host machine from within the guest machine. You must enable shared folders to do this, which are available by installing VirtualBox guest additions software (see our article for instructions on how to do this).
Once you’ve installed the guest additions, enable shared folders by adding a folder from your host machine in the settings for the guest machine. To do this, first make sure the guest machine is powered off. Then, select the guest machine in the list on the left of the VirtualBox Manager and click Settings on the toolbar.
On the Settings dialog box, click Shared Folders in the list of options on the left. On the Shared Folders screen, click the folder button with the plus sign to add a folder.
On the Add Share dialog box, select Other from the Folder Path drop-down list.
The Browse For Folder dialog box displays. Navigate to the folder you want to share between the host and the guest, select it, and click OK.
The path to the selected folder is inserted in the Folder Path edit box. The name of the folder automatically becomes the Folder Name, but you can change this name if you want. If you don’t want to be able to change items in this folder in the guest machine, select the Read-only check box. To have the selected folder automatically mounted in the guest machine when you boot it, select the Auto-mount check box. Click OK once you’ve finished choosing your settings for the shared folder.
The selected folder displays in the Folders List. Click OK to close the dialog box.
Now, make sure the guest machine is still selected in the VirtualBox Manager and click Start to boot it.
Once the guest machine is booted, open Nautilus (File Manager) by clicking the file cabinet on the Unity bar on the left side of the desktop.
In the Devices list on the left, click Computer and then double-click the Media folder on the right. You’ll see a folder named similarly to the folder you selected to share on your host machine with “sf_” added to the beginning of the name.
If you double-click on that folder, the following dialog box displays. This is because there is one more task to perform before you can access the shared folder.
In addition to users in Ubuntu, there are also groups. When VirtualBox installed the Ubuntu operating system, it added a group called “vboxsf”. Before you can access any shared folders, you must add yourself to the vboxsf group. To do this, press Ctrl + Alt + T to open a Terminal window. Type the following at the prompt, replacing “[username]” with your username, and press Enter.
Type your password when prompted and press Enter again. Messages display as you are being added to the group and “Done.” displays when the process has been successfully completed.
To close the Terminal window, type “exit” (without the quotes) at the prompt and press Enter.
To verify you are in the vboxsf group, you can type “id [username]” (without the quotes, and replacing “[username]” with your username) at the prompt and press Enter. All the groups of which the specified user is a member display.
Now, when you access the shared folder in the Media folder as described above, you should see any files in that exist in that folder on the host machine.
You can edit these files directly in this folder if you DID NOT select the “Read-only” option when selecting the folder in the Settings. You can also copy files into and out of this folder. If the folder was set to “Read-only”, you can only copy files from this folder and cannot copy files into it.
This brief tutorial shows students and new users how to share folders from VirtualBox host computer to Ubuntu 20.04 | 18.04 guest machines.
When using VirtualBox you can share folders from the host computer to guest machines. Guest machines can be Windows, Linux or MacOS.
This is made possible by VirtualBox host folder sharing feature. Folder sharing exposes the host computer files and folders to the virtual machines.
In order for this to work, you must by running the latest version of VirtualBox virtualization software with the current version of guest additions tools. You’ll have to enable bidirectional sharing from the host software, and the steps below show you how to do that.
To get started with sharing folders from VirtualBox host to guest machines, follow the steps below:
Step 1: Install VirtualBox Guest Additions
VirtualBox comes with guest machines tool called guest additions. Whenever you create a new guest machine, you must install the guest additions tool.
The tool provides tight integration between the host and virtual machine operating systems, improvement to the VM graphics performance, shared folder between the host and guest machines, copying and pasting of text, images and files between the host and guest machine as well as mouse improvement.
To install the tool in Ubuntu, follow the steps below. First run the commands below update Ubuntu guest machine.
When you’re done, run the commands below to install the latest kernel header and dkms package to support VirtualBox.
After installing the packages above, restart your machine and continue below.
To install VirtualBox Guest Additions software on Ubuntu virtual machine operating systems, select the Devices from VirtualBox host application menu and click Insert Guest Additions CD image…
This should mount a virtual CD/DVD drive inside the Ubuntu guest machine. When that happens, you should get a prompt to run the software. Click Run to begin the installation.
You will have to type your password to install the software. If your account is not an administrative account, the installation will fail.
The Guest Additions suite of utilities is the official tools for VirtualBox virtual guest machines.
Restart the guest machine and you’re set.
To enable copying and pasting between the guest machine and the host, go to the guest machines settings page (General –> Advanced) and enable it as shown below
Step 2: Share the Host Folders
Now that the guest tool is installed in step 1, run the commands below to enable your account to access the host folder in Ubuntu.
The command to do that is below:
After running the command above from Ubuntu guest, to Ubuntu guest machine settings from the host software and share the folder from the host machine.
Select the guest machine you want to share with and go to the Settings tab and pick the Shared Folders from the list. From there, click the Plus ( + ) at the top to add a folder you want to share.
Browse to the folder on the host machine and select it. If you want the folder to automatically mount everytime the guest machine starts, choose that option.
Click OK to save your changes and close out.
Turn on the guest machine or reboot if you’re already logged in. The next time you login, the shared folder on the host should be mounted.
If you don’t see it mounted, go to the /media/sf_ FOLDERNAME
Conclusion:
This post showed you how to share VirtualBox host folders with guest machines, including Ubuntu. If you find any error above, please use the comment form below to report.
Update 28 July 2019: An updated version of this guide for Ubuntu Server 18.04 LTS is now available. Feel free to check it out.
Update 23 May 2020: This guide is ALREADY OUTDATED and might no longer work with new versions of Ubuntu and VirtualBox. Please consider switching to the updated guide instead. I will no longer respond to the replies to this gist. Thank you.
Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS
This guide will walk you through steps on how to setup a VirtualBox shared folder inside your Ubuntu Server guest. Tested on Ubuntu Server 16.04.3 LTS (Xenial Xerus)
Right-click your VM, then click Settings
Go to Shared Folders section
Add a new shared folder
On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
In the Folder Name field, type shared
Uncheck Read-only and Auto-mount, and check Make Permanent
Once your VM is up and running, go to Devices menu -> Insert Guest Additions CD image menu
Use the following command to mount the CD:
- Install dependencies for VirtualBox guest additions:
- Run installation script for the guest additions:
- Reboot VM
- Create “shared” directory in your home
- Mount the shared folder from the host to your
/shared directory
- The host folder should now be accessible inside the VM.
Make the mount folder persistent
This directory mount we just made is temporary and it will disappear on next reboot. To make this permanent, we’ll set it so that it will mount our
/shared directory on system startup
- Edit fstab file in /etc directory
- Add the following line to fstab (separated by tabs) and press Ctrl+O to Save.
- Edit modules
- Add the following line to /etc/modules and save
- Reboot the vm and log-in again
- Go to your home directory and check to see if the file is highlighted in green.
If it is then congratulations! You successfully linked the directory within your vm with your host folder.
How to point apache’s web directory to our folder in the host.
- Remove apache’s old html directory (WARNING! Backup your data if necessary)
- Add a symbolic link in its place
fursserg commented Jun 15, 2018
Some systems may need option comment=systemd.automount in their fstab entry (source).
ssy341 commented Dec 7, 2018 •
hi,
this guide is a right way,Many thanks! I found so many ways, but all can’t work except this.
below code can mount folder as root user
but we hope mount folder as ubuntu user or other, try this:
natrod commented Feb 5, 2019
Great writeup, however if you plan on sharing your apache’s web directory through this method, i assume you would face permission issues since you would not be unable to change the group of the contents inside the shared folder. Do correct me if I’m wrong here please.
binary-person commented Feb 14, 2019 •
Nice job, only the mounting of the cdrom is a bit wrong. First, you should create a /media/cdrom if the user doesn’t have it already sudo mkdir /media/cdrom . The command should be sudo mount -t iso9660 /dev/cdrom /media/cdrom not sudo mount /dev/cdrom /media/cdrom (Reference: ). Nice job otherwise!
estorgio commented Mar 5, 2019 •
Hi everyone. I’m really surprised that my gist was getting some user engagement (comments, stars, forks, etc). To be honest I wrote this just for my own reference and I didn’t expect it would rank well on Google and get some traffic.
Took me this long to notice since I usually don’t get notifications when somebody comments on my gist.
@fursserg @ssy341
While I was making this I used a fresh new install of Ubuntu Server 16.04.3 LTS with default VM settings on VirtualBox (with Windows 7 SP1 as host) so if you’re using a different setup from mine then chances are you might get some different results.
@natrod
As far as I can remember I didn’t encountered any issues with Apache with regards to file permissions. It could be an issue if you’re using linux as host. I used Win 7 while I was testing this so that could be a factor.
@scheng123
Thank you very much for the tip. I was just about to upgrade my guest to Ubuntu 18.04 LTS and I found out that CD-ROM mounting no longer works as expected. Maybe I should make a new version of this guide for Ubuntu 18.04 LTS when I have the time.
- Page History
- Login to edit
This explains how to share files and folders (directories) between host and guest. (Files are shared over a network, in other words, you access remote files. For virtual machines, the network between host and guest is virtual since they are on the same real machine. But the steps you take are similar to setting up file sharing over real networks.)
Before sharing folders, you must install Guest Additions. For instructions on how to do this, see Guest Additions.
Create a folder on the Host computer (ubuntu) that you would like to share, for example
Boot the Guest operating system in VirtualBox.
Select Devices -> Shared Folders.
Choose the ‘Add’ button.
/share
Linux
With a shared folder named share, as above, the folder can be mounted as the directory
/host with the command
Windows
On the Windows Guest, run
Now anything placed in this folder should be visible from the host in the
This can be done more generically with the following:
For the above command if you get the following error:
Then just change the vboxsf to vboxfs
If you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local Debian distros (e.g. Ubuntu 10.04 and later) HOWTO Use Shared Folders
See Section 4.4 “Folder Sharing” in the VirtualBox documentation.
Note: if you want to mount the directory as owned and writable only by root, omit the -o uid=1000,gid=1000 option to the mount command
The above error could be one of the following.
The name was not valid
Make sure you specified the right name on the bash commands. If the guest machine is expecting “share” (as we did in the Prepare Host section) and you wrote
it will not work.
Note: Running on Ubuntu 10.04 host and Mint 14 as virtual system, the system would not accept a
/share. It complained that it was not an absolute address. I entered /home/jim/share and it worked fine.
Create a folder on the Host computer (ubuntu) that you would like to share, for example
Boot the Guest operating system in VirtualBox.
Select Devices -> Shared Folders.
Choose the ‘Add’ button.
Select ‘ /home/ /share‘ for Folder Path
VirtualBox/SharedFolders (последним исправлял пользователь a-everard 2014-09-26 15:49:59)
How to create a shared folder between host Operating System and Guest Operating system?
This is the scenario that you run Windows as your host operating system and Ubuntu in a VirtualBox, and that you want to access a specific Windows folder from Ubuntu.
In short-
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.
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
Step 5
With your mountpoint created you can now mount the shared folder.
Run this command to share the folder:
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.
This article is contributed by SHAURYA UPPAL. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to [email protected] See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
This quick tutorial shows how to share a folder in Virtualbox Ubuntu host and get access within Windows virtual machine.
One of the top things after installed a virtual machine via VirtualBox is how to transfer files between host OS and guest OS. And this can be done via Shared Folder feature.
1. In Virtualbox (6.0.8 in the case), open Settings of the Windows Guest OS. Then do:
- Navigate to Shared Folders in left pane.
- Click ‘Adds new shared folder’ button in the right.
- In next pop-up dialog do:
- Folder Path, choose a folder in the Host OS to share with.
- Folder Name, auto generated after chosen folder.
- Enable ‘Auto-mount‘.
- Enable ‘Read-only’ if you DON’T want to add/edit the folder files in Guest.
- Mount point:, leave it empty.
2. Boot up the Guest OS (Windows 7 in the case), and then go to menu Devices -> Insert Guest Additions CD image.
If you don’t see the Guest window menu, press right-Ctrl + C on keyboard.
3. Open Computer, you’ll see CD Driver marked as ‘VirtualBox Guest’.
4. Go to the CD Driver and click install the exe file to bring up guest addition install wizard.
5. Follow the install wizard until done.
6. Finally reboot the Windows guest OS, and shared folder should be there in ‘Computer’
How do I access files in VirtualBox Ubuntu?
Open Ubuntu virtual machine settings. Select Shared Folders > Add new shared folder. Add the path of your Windows folder you need to access on your Ubuntu VM and click OK. Reboot your Ubuntu virtual machine and you will find your shared folder under /media/sf_MySharedFolder .
How do I access host files in VirtualBox?
To do this, first make sure the guest machine is powered off. Then, select the guest machine in the list on the left of the VirtualBox Manager and click Settings on the toolbar. On the Settings dialog box, click Shared Folders in the list of options on the left.
How do I share a folder between Ubuntu and Windows VirtualBox?
Creating a shared folder
- Create a folder on the Host computer (ubuntu) that you would like to share, for example
/share.
/share.
How do you access folders on your host machine from an Ubuntu virtual machine in VMware?
How to share folders between Windows and Ubuntu using VMware Player
- Create a folder in your Windows file system that you want to use as the share. …
- Power down the VM shutting down Ubuntu.
- Select your VM in VMware Player and click Edit virtual machine settings.
- In the Options tab click Shared Folders in the left hand pane.
How do I mount a folder in VirtualBox?
- Open VirtualBox.
- Right-click your VM, then click Settings.
- Go to Shared Folders section.
- Add a new shared folder.
- On Add Share prompt, select the Folder Path in your host that you want to be accessible inside your VM.
- In the Folder Name field, type shared.
- Uncheck Read-only and Auto-mount, and check Make Permanent.
How do I download a local file to a virtual machine?
To do this, simply open the file browser on the host to where you would like to drop the files and drag the files from the virtual machine into the file browser of the host. File transfers should be pretty quick; if the virtual machine seems stuck when transferring, simply cancel the transfer and try again.
How do I move my host file to VirtualBox?
Launch VirtualBox and open Devices > Shared Folders > Shared Folders Settings. Click +, then in Folder Path, click the arrow and select Other. Browse (the host OS) for the folder you’re using as a share, highlight it, then Select Folder.
How copy hosts file to virtual machine?
When you drag a file or folder from host to virtual machine or from virtual machine to host, Workstation copies the file or folder to the location where you drop it. This means, for example, that if you drop a file on the desktop icon of a word processor, the word processor opens with a copy of the original file.
How do I share a folder between Ubuntu and Windows?
Now, navigate to the folder that you want to share with Ubuntu, right-click on it and select “Properties”. On the “Sharing” tab, click the “Advanced Sharing” button. Check (select) the “Share this folder” option, and then click the “Permissions” button to proceed. Now, it’s time to set the permissions.
How do I share a folder between Linux and Windows?
Option Two: Create a Share on Linux and Access It from Windows
- Step One: Create the Share on Linux. To set up a shared folder on a Linux that Windows to access, start with installing Samba (software that provides access to SMB/CIFS protocols used by Windows). …
- Step Two: Access the Linux Share from Windows. Terms of Use.
How do I share a folder between VirtualBox and Windows?
To share a host folder with a virtual machine in Oracle VM VirtualBox, you must specify the path of the folder and choose a share name that the guest can use to access the shared folder. This happens on the host. In the guest you can then use the share name to connect to it and access files.
How do I mount a folder in VMware?
To share a directory/folder from the host to a VMware VM, open the VM, make sure the VM is not powered on and go to VM > Settings. Then, go to the Options tab and click on Shared Folders. By default, Shared Folders is Disabled. To enable Shared Folders, select Always enabled.
How do I transfer files from Linux to Windows virtual machine?
2. How to Transfer Files From Linux to Windows Using FTP
- Open File > Site Manager.
- Create a New Site.
- Set the Protocol to SFTP.
- Add the target IP address in Host.
- Specify a username and password.
- Set the Logon Type to Normal.
- Click Connect when ready.
How do I transfer files from Ubuntu to Windows virtual machine?
OK, here are my detailed steps using Alvin Sim’s Option 1.
- Before starting your Guest.
- Go to VirtualBox Manager.
- Select your interested Guest.
- Go to Guest Settings.
- In Guest Settings, scroll the left side-menu, and go to Shared Folders.
- In Shared Folders, add your interested folder in the Host machine.
Ubuntu is the alternate Linux operating system that I use in VirtualBox hypervisor on my windows 10 host machine. Because of which I can switch between the Ubuntu guest and windows host anytime I want. One important thing when you work with Linux VM in VirtualBox, how do I transfer files between the operating system and what is the simplest way.
In our last blog, I have covered how you can install Ubuntu operating system on VirtualBox. And In this one, I will show you how you can create a folder in windows and share them with Ubuntu vm in VirtualBox.
How do I create a shared folder between Windows and virtual machines?
There are different ways you can create a folder in a windows machine and share it with the virtual machines. The first option is to create a folder in the windows machine and share permission to the user, and from Ubuntu, you try to access the shared folder using the smb protocol via the host and guest networking. So your host machine must have reachability to the guest VM. I have covered this in more detail here.
The second and easiest way is to share the folder with the help of VirtualBox guest addition. In that, you create a folder and share the folder via VirtualBox settings. You should be able to see them in the guest operating system. We are going to do just that in the lab as a step-by-step guide.
Steps to configure Virtualbox shared folder.
- Install VirtualBox guest additions.
- Create a folder in windows.
- Connect the shared folder to the VirtualBox.
- Test the VirtualBox shared folder access.
1. Install VirtualBox guest additions.
You can think of VirtualBox guest additions as a VirtualBox driver for the guest machine. After the installation, you will observe the overall guest operating system performance is improved. The guest addition is an ISO file located in the VirtualBox installation location. And most of the operating systems out there are supported with guest additions.
You will end up with many performance issues if you don’t have VirtualBox guest additions are not installed on the Guest VM’s. For that reason, you must install VirtualBox guest additions right after you deploy the guest VM.
Follow the instruction below to install the guest additions on a ubuntu-desktop.
- Power on the VM.
- In the VirtualBox Devices drop-down, click on Insert Guest Additions CD image..
- You should see the CD drive was automatically mounted, and you would get a prompt that says Vbox_Gas_6.x.x contains software intended to be automatically started. Would you like to run it?
You can click on Run on that prompt.
- It will prompt you for authentication, enter the password for your ubuntu account
- You should see the guest additions have been installed on the terminal screen, and you may hit enter to exit out of the terminal.
- Let’s go ahead and reboot the VM now.
We have now successfully installed the virtual box guest addition on the ubuntu VM. To confirm the installation, you can run the command lsmod | grep vboxguest
2. Create a folder in windows.
We now have to create a folder in the windows machine that we can use between the guest VM and the windows host.
I created a folder called Ubuntu share on my windows machine in my C drive. You can create the folder anywhere you want.
3. Connect the shared folder to the VirtualBox.
Shut down the Ubuntu VM, and right-click on it, and click on settings. You should get settings pop up in that choose Shared folders.
Click on the plus icon to add the shared folder that we created in our last step.
In the folder path, choose the shared folder that we have created.
You may provide a user-friendly name for the share.
You can decide whether this folder is read-only or read-write, I want this folder as read-write hence I unchecked the option Read-only.
Check the option Automount, which will automatically mount the share to the guest when the system reboots.
Mount point: You can choose the location for the mount point. I recommend leaving this blank so the guest will pick up the best path for mounting the folder.
Click on Ok and Ok on the VirtualBox settings.
At any time, if you changed your mind and wanted to adjust the existing shared folder, you can come back to the shared folder option in VirtualBox and click on the gear icon to edit the settings.
4. Test the VirtualBox shared folder access.
You may go ahead and start the VM now. Once the VM has been started, you should be able to see the shared folder under files. As you can see, the folder is empty at the moment. Let’s go ahead and create a folder in it now.
I created a test folder in the Ubuntu share folder.
You may now go back to the windows folder and make sure you can see the folder in the windows share.
As you can see, the folder has been shown. You can now start sharing files back and forth from windows to Ubuntu and vice versa.
Can I share entire hard disk drive to Guest VM in VirtualBox?
If you wanted to share the entire hard disk drive, maybe the whole C drive instead of a specific shared folder with a Guest Virtual machine, Ubuntu in our case, which is also possible. All we have to do is instead of attaching the newly created folder. You can connect the entire C drive itself, and it should work fine.
As you can see below, I have attached the C drive instead of a specific folder.
And C drive showed up in the Ubuntu file manager app.
The conclusion is, you can not only share just a folder with the guest VM. You can even share the entire hard disk with it, giving the guest virtual machine access to the whole hard disk. And one thing to keep in mind is that you must always install the VirtualBox guest additions before proceeding with any of the above steps.
After installing a Linux distro into a VirtualBox virtual machine, you may be wondering how to share files between the host operating syste and the virtual machine itself. One of the easiest and most convenient ways to provide this function is by setting up a VirtualBox shared folder.
Essentially this means that a folder on your host machine can be mounted on the virtual machine, where both systems will be able to access files or drop them in the folder. It doesn’t matter what host operating system you’re using, as the instructions will be the same across Linux, Windows, etc.
In this guide, we’ll go through the step by step instructions to configure a shared VirtualBox folder. We’ll also show you how to mount the shared folder on your Linux system, allowing you to easily share files back and forth.
In this tutorial you will learn:
- How to configure a shared VirtualBox folder on Linux
- How to mount a VirtualBox shared folder
| Category | Requirements, Conventions or Software Version Used |
|---|---|
| System | Any Linux distro |
| Software | VirtualBox, VirtualBox Guest Additions |
| Other | Privileged access to your Linux system as root or via the sudo command. |
| Conventions | # – requires given linux commands to be executed with root privileges either directly as a root user or by use of sudo command $ – requires given linux commands to be executed as a regular non-privileged user |
Prerequisites for VirtualBox shared folder
Before we get started, there are a couple of prerequisites to consider. First, we’re assuming in this guide that your guest operating system (the one installed in the virtual machine) is Linux. The host operating system is mostly irrelevant, but in this guide, our host system is Ubuntu. You can follow along just fine even if you are running a different distro.
The second thing to keep in mind is that you must have VirtualBox Guest Additions installed in the virtual machine. This is pretty trivial to install, and you can check out our guide on installing VirtualBox Guest Additions if you need some help.
Configure VirtualBox shared folder
Follow the step by step instructions below to configure a VirtualBox shared folder.
- Before your start your guest operating system, you need to change its settings. Specifically, we need to define the location of the shared folder first. Open the VM Settings and go to Shared Folders on your host operating system.
Path: /home/linuxconfig/share
Name: share
Mount point: /mnt/share
Now that mount directory is ready we can mount VirtualBox shared folder.
Note that “share” is the name you have defined when creating a VirtualBox shared folder in the previous steps. Now simply navigate to your home directory and your /home/linuxconfig/share folder and you should see your shared across.
Mount VirtualBox Shared Folder permanently
Once you restart your guest operating system to get access to your VirtualBox shared folder again you need to mount it again with the above command. To make this mount permanent add the following line into your /etc/fstab file, while changing the directory path to reflect your own configuration:
Note that uid=1000,gid=1000 will make you an owner of all files within the VirtualBox shared folder. Moreover, you can use mount options for more settings such as read-only and so on.
Closing Thoughts
In this guide, we saw how to configure a VirtualBox shared folder, which makes it easy and convenient to share files between a host operating system and virtual machine. We also saw how to automatically mount the shared folder, or manually mount it and to make the mount persistent across reboots. You’ve just extended the functionality of your VirtualBox virtual machine in a few short steps.
In this article, we will show you how to install VirtualBox Guest Additions and share folders between the host OS and the guest OS.
Prerequisites
- Host OS with VirtualBox installed
- Guest OS installed in the virtual machine
For this demonstration, we are using Windows10 as the host OS and Ubuntu 20.04 LTS as the guest OS. To enable sharing between guest and host OS, we will install VirtualBox Guest Additions on the guest OS and then share and mount a folder from the host OS to the guest OS. Let’s get started.
Install VirtualBox Guest Additions on the guest system
To enable file sharing between host and guest, you must install Guest Additions in the guest OS. To do so, the following steps must be taken:
1. Open VirtualBox in your host system and start a guest operating system.
2. On the top menu bar of VirtualBox, click Devices, then select Insert Guest Additions CD image to insert a virtual CD inside the guest system.
3. The following message will appear. Click Run to install Guest Additions on the guest machine.
4. Installation will begin, and once completed, you will be asked to press Enter to close the window. Press Enter to finish the installation.
Once VirtualBox Guest Additions has been installed on the Guest OS, you can share folders between the host system and the guest system.
Share folders between host and guest
Now, we will share a folder between the host and guest systems. You can share multiple folders between the guest OS and the host OS. For folder sharing, either create a new folder or use an existing folder. Follow the steps below to share a file or folder between the host and guest systems.
1. From the top menu bar of VirtualBox, go to Shared Folders > Shared Folders Settings.
2. You will see the following settings window in your guest system. Click the + button to open the Add Share dialog box.
3. In the Add Share dialog box, select the shared folder using the Folder Path drop-down, and choose a folder from your host OS. Then, type a name for your shared folder, and check the Auto-mount box. The Auto-mount option will automatically mount the shared folder on the next boot.
Now, click OK to close the Add Share dialog. You will now see the shared folder in the Settings window. Click OK to close the window.
4. By default, only root and members of vboxsf are allowed to access the shared folder. To assign permissions to your user account, issue the following command in the terminal, replacing with the actual username:
5. If you open File Manager or Explorer in your guest OS, then you will see the shared folder sf_shared_folder mounted there, where sf_shared_folder is the name of your shared folder.
The shared folder can also be accessed from the command line. Open the command line using Ctrl+Alt+T, and then navigate to /media directory using the following command in the terminal:
Here, if you run the cd command, you will see your shared folder listed under the /media directory.
Now, navigate to the shared folder using the cd command as follows:
Make sure to replace sf_shared_folder with the name of your shared folder.
In the shared folder, you can place any file you want to share with your host OS. Similarly, you can access any file shared by your host OS.
Conclusion
This article showed you how to set up folder sharing between a host system and a guest system in VirtualBox. You need to follow the above procedure for your guest machines only once. After that, the shared folder of the host will be automatically mounted in the guest OS on every boot for file sharing.
About the author
Karim Buzdar
Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. He blogs at LinuxWays.
This is a guide on How to Share folders with your Ubuntu Virtual Machine (guest) VMware Workstation provides a great ability to create shared folders so that your virtual machine can easily access data on your host pc. This saves a lot of time, especially when you are installing software that would otherwise take a long time to download.
For this to work, you will need to make sure that you have the vmware tools installed and running.
You can check to see if the vmware shared folders module is running by running this command:
If you get nothing then the mdoule is not loaded. You will need to load it with this command:
If that gives you another error, then you don’t have the vmware tools installed, and you will want to make sure to install them before proceeding.
In VMware Workstation, go to the VM \ Settings window and then click on the Options tab. From here you can modify the shared folders. Share folders with your Ubuntu
Click the Add button, and you will be presented with a wizard. Click next, and you should see this screen:
The name field will become part of the mounted path in Ubuntu, so name it something short and to the point. For instance, this shared folder will be mounted on /mnt/hgfs/mydrive/
Select the host folder that you want to share and then click the Next button
If you are worried about the guest operating system messing with your files, you can select the read-only checkbox. I personally did so simply because I was worried about accessing in-use files.
You shouldn’t even have to restart your virtual machine. The folders should immediately show up under /mnt/hgfs
That’s all there is to it. Remember, if you have problems it’s probably because your vmware tools are not installed.
Tested on: Ubuntu Dapper, Ubuntu Edgy Eft
Update: If you have problems you might also want to check your firewall settings, which could be disabling communications between the virtual machine and your host computer. Thanks to burkhard in the comments for noticing this.
VirtualBox is a very useful tool to install operating systems inside the main system. However, configuring the Virtualbox to share files between your main system and the system you installed in a VirtualBox is not trivial. So, I will show you how to enable a shared folder in Virtualbox for Debian, Linux Mint/Ubuntu, and Arch Linux as guest systems. I will also show a universal way that should work for any Linux guest distribution.
INTRODUCTION
There are several essential steps you need to follow, to enable a shared folder between the real machine (host) and the virtual machine (guest):
- Install guest additions for your guest system.
- Create a shared folder.
- Change the user permission for the shared folder.
In this tutorial, my host system is Arch Linux, but the host system does not matter in this case because we will do all the setting in the guest systems. So, I will show you the settings for Arch Linux, Linux Mint and Debian as guest systems. If you use some other distributions as a guest, look at the instructions for Debian. It is a universal way to enable a shared folder and it should work for all distributions.
VIDEO TUTORIAL
Enable a shared folder in VirtualBox for Arch Linux guest
Prepare the system
First, make sure your Arch Linux guest system is up to date. Open a terminal and update it:
Next, install kernel headers. I use the Linux kernel LTS, so I have to install the linux-lts-headers package. If you use the standard kernel, install linux-headers .
Then, install the virtualbox-guest-utils package. It will make you choose a package: either virtualbox-guest-modules-arch or virtualbox-guest-dkms . The Arch Linux wiki recommends choosing the virtualbox-guest-modules-arch package if you use the Linux kernel and virtualbox-guest-dkms for others kernels like LTS. Again, I use the linux-lts kernel so I needed to install the virtualbox-guest-dkms package.
After that, enable the VirtualBox kernel modules:
Add the shared folder
In VirtualBox, go to the Devices menu -> Shared Folders menu -> Shared folders settings.
In the window that opens, on the right side, you will find the button to add a new shared folder. Click on it.
And select the folder you want to share between systems. For example, I usually share my Public folder. Make it permanent and activate auto-mounting by clicking on the options.
Then, you need to reboot the guest system. Once the guest system has rebooted, you can find the shared folder in the /media folder.
The problem is, however, that only the root user can access the folder. To gain access to this folder as a regular user, open the terminal in your guest system and add your user to the vboxsf group.
`whoami` stand there to automatically paste your username. You can also type your username directly.
Next, give that user a permission to access the media folder.
Finally, log out, and log in again. Open the file manager and you should be able to access the shared folder as a regular user.
So, this is the whole process to enable a shared folder in VirtualBox using Arch Linux. You can start placing files there.
Enable a shared folder in VirtualBox for Debian guest
Installing guest addition in Debian is a little different from in Arch Linux. For Debian, I will show you a more universal way that you can apply to any other distro including Arch Linux. However, the way I showed before is preferable for Arch Linux.
Prepare the system and add a shared folder
In Debian guest, open a terminal and install the build-essential, dkms, and linux-headers packages.
After that, you can add a shared folder. It is the same procedure as before. Go to the Devices menu -> Shared folders -> click on the Shared folder settings option.
Again, click on the button at the right to add the shared folder. Set the folder options you want and click on the Ok button.
After the packages are installed and the shared folder is added, reboot the system.
Install the GuestAddition CD Image
When your guest system has started. Go to the Devices menu and click on the Insert Guest addition image option.
Then, open a file manager, navigate to VBOXADDITION CD, right click in that directory and click on the open Terminal here option.
In the terminal, run the following command to install the VirtualBoxLinuxAddtions:
Make sure it is installed without errors. If some errors occur, read the message, most likely the instruction for a fix will be provided. If the install is successful, you need to reboot the system.
Setting the permissions to the shared folder
If you go to the /media folder in the file manager and check if a shared folder is mounted, most likely you will not be able to access it as a regular user.
To enable the access to this folder for a regular user, do the same what we did for Arch Linux, add your user to the vboxsf group.
And change the permission of the media folder.
Log out, log in and you should be able to access the shared folder.
This method to enable a shared folder in VirtualBox for Debian is universal and it should work for any other distributions.
Enable a shared folder in VirtualBox for Linux Mint / Ubuntu guest
Linux Mint and Ubuntu usually come with VirtualBox guest addition pre-installed by default. If not, you can install it using a software manager like Synaptic.
Open the software manager, search and install virtualbox-guest-X11 , virtualbox-guest-utils , and virtualbox-guest-dkms .
Then do the same steps I showed for Arch Linux and Debian. First, add a shared folder.
Reboot the system. Then, add your user to the vboxsf group.
Change the permissions.
Finally, log out and log in, and you should have the shared folder working.
CONCLUSION
Now, you can use your VirtuaBox systems more extensively by sharing files between your host and guest systems.
If you use any other distro than Ubuntu-based ones, Arch Linux or Debian, try the way I show for Debian and let me know how it worked.
I recommend for the next read to learn how to clean Arch Linux.
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:
And checked that the package was installed with command:
But when I rebooted and tried to mount the shared folder with:
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:
but the group was not created too.
What am I missing, what is the way to make it work?
This article provides the steps to share a folder on your Mac to Ubuntu through Virtualbox. It also discusses troubleshooting I encountered. Here we go!
- Launch Virtualbox
- Click your Ubuntu virtual machine > Settings > Shared Folders
- Click the “ add new shared folder” button on the right side of the window
- Folder Path: click the drop-down arrow>other…>select the folder you want to share > open
- Folder Name: The folder name will be automatically updated once you choose the Folder Path
- Check “ Auto-mount” > OK
For example, I choose to share a folder named “java” on my Mac Desktop:
7. Start Ubuntu virtual machine
8. Open terminal by right click on the desktop > Open in Terminal
9. Create a new folder you want to receive shared files or skip this step if you want to share to existing folder. For example, I created a folder in the Documents folder named “mac_shared” by type the following in the terminal ( Note: “jk” is my user name, you should change to yours when you do this step):
10. Make sure you are on your home-directory in case you are not (for me, that is /home/jk) by typing
then use the following to mount your shared folder
sudo mount -t vboxsf java /home/ jk/Documents/mac_shared
Enter your password if requested.
Note: java is the name of your shared folder from Mac; /home/jk/Documents/mac_shared is the directory of the folder on Ubuntu.
11. After all these steps you should be able to see files from Mac on Ubuntu
It’s all about network.
With the “shared folders” feature of Virtual Box, you can access files of your host system from within the guest system. This is similar how you would use network shares in Windows networks — except that shared folders do not need require networking, only the Guest Additions. Shared Folders are supported with Windows (2000 or newer), Linux and Solaris guests.
Shared folders must physically reside on the host and are then shared with the guest, which uses a special file system driver in the Guest Addition to talk to the host.
To share a host folder with a virtual machine in Virtual Box, you must specify the path of that folder and choose for it a “share name” that the guest can use to access it. Hence, first create the shared folder on the host; then, within the guest, connect to it.
Required: Virtual Box Guest Additions
Guest Additions provide additional capability to a guest virtual machine, including file sharing. But there are some other consequences you may face;
If your Guest is Windows
If your Virtual Machine running a window version then that will be a easy task to do it. Let see how…
Step 1 . Go to your Virtual Box home screen, Click on Devices> Install Guest Additions..
Step 2 . New window will pop-up like this click Next and reboot your Virtual Machine. That’s it.
If your Guest is Linux
There may be other consequences you may face, we will discussed it step by step.
Follow the above steps, go to home screen click on Device> Install Guest Additions. It will mount a drive on your Virtual Machine CD-ROM.
If Guest Additions showing on CD-ROM then run the following script in terminal.
If you are running a Linux guest, open a terminal and type:
cd /cdrom or cd /media/
then run:
sudo sh ./VBoxLinuxAdditions.run
If Guest Additions not showing on CD-ROM then you have to download Guest Addition Manually. There are two choices:
Choice 1 . Download Guest Addition from Virtual Box official Website down below is the link to download. Mount the image to CD-ROM of your Virtual Machine. It will showing like in image.
Choice 2 , Open the terminal of Guest running on Virtual Machine, type the following..
sudo apt-get install virtualbox-guest-additions-iso
Whether you finish with choice 1 or choice 2 after that Guest Additions will shown on CD-ROM of Virtual Machine. Run the script as above as you see Guest Addition in CD-ROM.
cd /cdrom or cd /media/
then run:
sudo sh ./VBoxLinuxAdditions.run
Create Shared Folder
After you had a Guest Addition, now you need to create shared folder in both Guest and Host.
Step 1 . Create a folder anywhere in your Host system where you want and named it what you want. I’ve created one called VboxShare in my home directory.
Step 4 . Job Done the shared folder appears on you guest machine as /media/sf_Vboxshare.
Step 5 . There is only one more step add any user in your guest system that needs access to the folder to the group vboxsf: Open the terminal and type..
sudo adduser $USER vboxsf
Log out and back in, everything should work fine now.
Create a shared folder is easy in VirtualBox, but it by default shows cross mark and lock emblems on it with permission issue.
When trying different operating systems via Virtualbox, we often need to transfer data between the host OS and virtual machines. So it introduced the shared folders feature. And here’s how to tutorial for beginners.
Note this tutorial is tested and works in VirtualBox virtual machines such as Ubuntu 20.04, Ubuntu 21.10, Elementary OS 6, Zorin OS 6, Debian 11, Linux Mint 20, and Fedora 34. Theoretically, it should work on all Linux guest OSes.
Install VirtualBox Guest Additions:
Before creating a shared folder, you need to first install the Guest Additions in the Virtual Machine to make the function work.
1.) Firstly, start the Guest OS. After login, go to VM menu “Devices -> Insert Guest Additions CD image…“.
2.) A dialog should pop-up asks whether to run the installer script or not. Click “Run” and then type user password in next authentication window. A terminal window will open and start installing the Guest Additions.
If you clicked “Cancel” by mistake or the dialog does not appear, go to “VBox_GAs_x.x.xx” in the left pane of file manager. Then right-click on blank area and select ‘Open in Terminal’. Finally run the command below to install the additions manually:
For installing issues, you may alternatively download the ISO image for your VBox edition from the link below. Then click to mount it, and run the installer script manually.
Add user permission:
Without this step, the shared folder will display with a lock and cross mark emblems. You need to sudo permission to be able to open it, or do copy and paste actions.
To fix issue, simply add your username to the “vboxsf” group which is created automatically after installing the Guest Additions.
Firstly, open terminal in Guest OS from the start menu, and run command to add current user to “vboxsf” group:
On Debian and Ubuntu based systems, you can also use this command instead:
After that, the command will should list your user as member of the vboxsf group:
Finally, restart the Virtual Machine to apply the change.
Create share folder in VirtualBox:
Now open Settings for the Virtual Machine, and navigate to “Shared Folders” from the left pane. There click the little folder icon in the right to start creating a new share.
- Folder Path: Choose “Other …” from the drop-down box and then select a folder on host machine you want to share with.
- Folder Name will generate automatically after selected folder path.
- Enable “Read-only” will NOT allow the Guest OS to change anything in this folder.
- “Auto-mount” is recommended for beginners.
- Mount point: folder path in Guest OS. You need to type it manually. And it’s usually “/home/USER_NAME/Documents/FOLDER_NAME”. Replace USER_NAME and FOLDER_NAME. VBox will generate the FOLDER_NAME automatically if not exist.
I am using Ubuntu on Virtual Box and I have a folder which is shared between the host (Windows) and the VM (Ubuntu). When I open any file in the share folder in Ubuntu, I can not change it as its owner is set to root.
How can I change the ownership to myself?
Here is the output of ls -l :
The output of df is:
The options in VM is automount and the readoly is not checked.
Tried to use /media/sf_Ubuntu , but getting permission error:
Please note that I am in the group vboxsf :
9 Answers 9
The regular way of getting access to the files now, is to allow VirtualBox to automount the shared folder (which will make it show up under /media/sf_directory_name ) and then to add your regular Ubuntu user to the vboxsf group (as root # ).
By default, without manual action, the mounts look like this,
so the vboxsf group has full access. By adding your user to that group, you gain full access. So you wouldn’t worry about changing their permissions (which don’t make sense on the Windows host), you just give yourself access.
In this specific case, this is the automounted Shared Folder,
and it is that directory that should be used to access to the Shared Folder, by putting the local user into the vboxsf group. If you want a ‘better’ link under your user’s home directory, you could always create a symbolic link.
If you manually mount the shared folder, then you need to use the relevant options on the mount command to set the folder with the right ownership (i.e. the gid, uid and umask options to mount ). This is because the Host OS doesn’t support the same permission system as Linux, so VirtualBox has no way of knowing who should own the files.
However, I strongly recommend just configuring the shared folder to be auto-mounted (it’s a setting on the Shared Folder configuration in VirtualBox itself).
For the avoidance of doubt, I do not believe you can change permissions normally anyway, on that filesystem if it’s mounted in the regular way,
In a previous tutorial, I showed you how to install Virtualbox guest additions on Debian. This tutorial will explain how to enable file sharing between host and virtualbox guest OS. In order to do this, you have to install guest additions in the guest OS first, so if you haven’t done yet, check out that post and go back here when you are done.
Enable File Sharing between Host and Virtualbox Guest
In the Virtualbox Manager window, right-click on your guest machine and select Settings.
In the left pane, select Shared Folders. Then click on the add button to add a shared folder.
Then in the Folder Path field, select a folder on your host machine.
You can check Read-only to let your guest have read access but no write permission to the shared folder on the host machine. Check Auto-mount to auto-mount the shared folder when the guest OS boots up. After that, click OK button.
Now start the Linux guest machine. In /media/ directory of the Linux guest, you will find a new directory called sf_shared_folder if the shared folder name on the host is shared_folder . By default, only root and members of the vboxsf group have read and write access to this directory. So what we need to now is add your user to vboxsf group. Open up a terminal in the guest machine and enter the following command. Replace with your real username.
Log out of the current session and log back in. Now you can access the /media/sf_shared_folder directory.
You can create a soft link that points to /media/sf_shared_folder.
The above command will create a shared_folder directory under the user’s home. File created in shared_folder actually resides in /media/sf_shared_folder.
How to enable copy and paste clipboard between host and guest
Another thing you may want to do is enable copy and paste clipboard between host and guest. To accomplish that, open the settings window of your virtual machine. Go to General > Advanced. Change the value of Shared Clipboard and Drap’n’Drop to Bidirectional. Then click the OK button.
This part requires Guest Additions to be installed in Ubuntu, so make sure you have completed Part 3 before starting Part 4.
In your home directory on your local machine (my home directory on my Mac is /Users/mdamiani), or in another location of your choice (just make sure to remember it), create another directory called systems. This will be the directory shared between your local machine and Ubuntu, and will include the work you will be doing in this class. To mount this folder in Ubuntu, follow these steps:
- Open Virtual Box. Make sure Ubuntu is powered off.
- Click on “Setting”, then “Shared Folders”. To the right of the Name/Path entry, you should see a folder icon with the + sign superimposed. Click on it:
In the window that opens, click on the arrow at the right of the Folder Path entry to browse for the folder you want to share.
For Folder Name, enter a name to describe this folder (it could be anything, just make sure to remember it). I will call it MacSystems.
Also check the “Auto-mount” option if you want the shared folder to mount automatically upon each boot. Click OK (twice):
Start Ubuntu. Fire up a terminal and create an empty folder named systems in your home directory. If you already have a folder with this name, rename it oldsystems and then create a new, empty directory named systems. Then type the command to mount this directory, substituting the folder name (in red) with the one you picked. This sequence of commands is shown below:
Check the ownership and access rights for your systems directory:
We have a problem: notice that the user and group owner of the systems directory is the root, and users to not have write permissions to this directory. Let’s fix this.
Unmount the systems directory and then mount it again, but this time specify the user and the group owner of the directory to be yourself:
Check again the ownership and access rights for your systems directory. This time the user and group owner of this directory should match your Ubuntu username:
You can also check the file systems that have been mounted on your virtual machine using the “disk filesystem” command You should see your systems directory listed:
That’s it! You have just mounted in Ubuntu the systems folder hosted on your local machine. You may now access (read and write) this folder in both Ubuntu and your host machine.
Note that your systems directory in Ubuntu is simply a mount point for your systems directory on your host machine, and the files you see in your Ubuntu systems directory are actually stored on your host machine.
If you had material in your oldsystems directory that you wish to copy in your systems directory, do it now:
If you are using VirtualBox frequently, you will have found yourself in the situation of having to move files from the Host machine (the main system) to the Guest machine (the emulated system).
To do this, if you use Windows as Guest (in the VM), there are no problems.
In this case it will be enough to create a shared folder with auto- mounting, and have installed the VirtualBox Guest Additions.
In this way each time you start the Guest, you will find the folder mounted ‘on the network’, which refers to that of the physical system.
In case you have to use Linux as Guest system, things get complicated, and you need an additional step, let’s go through it.
Step 1 – Install Virtual Box Guest Additions
Inside the Linux virtual machine (Ubuntu)
Open a terminal and acquire root rights with:
Upload the list of packages
Install the VirtualBox Guest Additions
Reboot the system (the VM), and then turn it off for the next step.
Step 2 – Create the shared folder
From the Host system, create the shared folder and select it from the virtual machine settings:
Step 3 – Give access permissions
To open the newly shared folder, you should give the following order command (on Ubuntu, emulated system):
This gives access privileges to the current user in the virtualbox group.
Obviously instead of [username] you have to insert your user in the system:
if for example on the left of the prompt in the terminal you find written [email protected] VirtualBox :
To verify if you have been added run (only for verification, not necessary):
In the l ist , there should also be 999( vboxsf ).
You can now access the shared folder, in the Guest system, to the path:
Inside you can find all the mounted folders. Those of VirtualBox will have the prefix “sf_” before the name.
This procedure could also allow the (experimental) use of Bidirectional Drag and Drop.
Ubuntu Tips | Ubuntu Howtos | Ubuntu Tutorials
This tutorial shows how to share folder between virtualbox Ubuntu host and Windows guest,or Windows host and Ubuntu guest.
First of all,make sure you have installed guest additions(from virtual machine windows,click to Machines->Install guest additions).
Ubuntu host and Windows/Vista guest:
1.First,create the shared folder in ubuntu host,assuming the folder is /home/user_name/vbshare:
2.Boot up Windows guest and go to Devices->Shared Folders
Click the button at right to create a share.
In Folder Path navigate to the folder you created in step one and select it.Check “Make Permanent”.
3.For Windows guest,navigate to Start->Run and type:
In dos console,use this command:
For Vista guest,open your Windows Explorer, click on the Map Network Drive.Type following in Folder area and check “Reconnect at logon”.
4.Open My computer,you will see the shared folder:
Windows Host and Ubuntu guest:
1.Create an folder,assuming it is:
2.Same to the step 2 above.
3.In ubuntu guest,open terminal(Applications->Accessories->Terminal).Using following command mount the folder:
Virtual Box Shared Folder Configurations
Today I will show you how to setup your shared folders feature in virtuabox from a windows computer to a linux ubuntu virtual machine guest. this is the procedure to setup your shared folders in virtualbox.
Install Guest Additions
The first thing you MUST do is install ‘Guest Additions‘, if you dont know how to do this, just go to the Devices menu and select ” Insert Guest Additions CD Image ” – Then reboot the machine and follow these instructions step by step:
0. Install Guest Additions
1. Go to the virtual machine you want to share folders with
2. Click on the Settings icon
3. Click on the add share icon
4. Populate the following configuration settings:
> Folder Path: Provide the PATH location in your host machine. for example: C:\Users\myuser\shared
> Folder Name: shared
> [ ] Read-only (leave unchecked)
> [x] Auto-mount (check this so everytime you boot up your guest ubuntu machine it mounts the folder)
> Mount Point: (leave it blank, if you leave it blank, the system will automatically add the shared folder in your ubuntu desktop)
6. Now look in your Ubuntu Desktop and you will see a icon called “shared” – you will see the files containe din the windows folder you provided in step four. for example: C:\Users\myuser\shared
NOTE: I ran into a permissions problem with the shared folders feature in the ubuntu linux guest machine. To solve this problem, simply run this command in the terminal command:
$ sudo adduser $USER vboxsf
I ran into a situation where I still could not see my shared folder. To fix it, I had to run this command:
sudo apt install virtualbox – guest – utils virtualbox – guest – dkms
After running this command, it worked. I can see my shared folder from my windows computer.