- Mounting virtualbox shared folder linux
- 4.3.1.В Manual Mounting
- 4.3.2.В Automatic Mounting
- Ubuntu Documentation
- Introduction
- Required: Virtualbox Guest Additions
- Creating a shared folder
- Prepare the folder
- Linux
- Windows
- Troubleshooting
- The name was not valid
- Ubuntu 10.04 host
- How to enable a Virtualbox shared folder for Linux guest systems
- INTRODUCTION
- VIDEO TUTORIAL
- Enable a shared folder in VirtualBox for Arch Linux guest
- Prepare the system
- Add the shared folder
- Enable a shared folder in VirtualBox for Debian guest
- Prepare the system and add a shared folder
- Install the GuestAddition CD Image
- Setting the permissions to the shared folder
- Enable a shared folder in VirtualBox for Linux Mint / Ubuntu guest
- CONCLUSION
Mounting virtualbox shared folder linux
With the shared folders feature of Oracle VM VirtualBox, you can access files of your host system from within the guest system. This is similar to how you would use network shares in Windows networks, except that shared folders do not require networking, only the Guest Additions. Shared folders are supported with Windows 2000 or later, Linux, and Oracle Solaris guests. Oracle VM VirtualBox includes experimental support for Mac OS X and OS/2 guests.
Shared folders physically reside on the host and are then shared with the guest, which uses a special file system driver in the Guest Additions to talk to the host. For Windows guests, shared folders are implemented as a pseudo-network redirector. For Linux and Oracle Solaris guests, the Guest Additions provide a virtual file system.
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.
There are several ways in which shared folders can be set up for a virtual machine:
In the window of a running VM, you select Shared Folders from the Devices menu, or click on the folder icon on the status bar in the bottom right corner.
If a VM is not currently running, you can configure shared folders in the virtual machine’s Settings dialog.
From the command line, you can create shared folders using VBoxManage , as follows:
There are two types of shares:
Permanent shares, that are saved with the VM settings.
Transient shares, that are added at runtime and disappear when the VM is powered off. These can be created using a checkbox in the VirtualBox Manager, or by using the —transient option of the VBoxManage sharedfolder add command.
Shared folders can either be read-write or read-only. This means that the guest is either allowed to both read and write, or just read files on the host. By default, shared folders are read-write. Read-only folders can be created using a checkbox in the VirtualBox Manager, or with the —readonly option of the VBoxManage sharedfolder add command.
Oracle VM VirtualBox shared folders also support symbolic links, also called symlinks , under the following conditions:
The host operating system must support symlinks. For example, a Mac OS X, Linux, or Oracle Solaris host is required.
Currently only Linux and Oracle Solaris Guest Additions support symlinks.
For security reasons the guest OS is not allowed to create symlinks by default. If you trust the guest OS to not abuse the functionality, you can enable creation of symlinks for a shared folder as follows:
4.3.1.В Manual Mounting
You can mount the shared folder from inside a VM, in the same way as you would mount an ordinary network share:
In a Windows guest, shared folders are browseable and therefore visible in Windows Explorer. To attach the host’s shared folder to your Windows guest, open Windows Explorer and look for the folder in My Networking Place s, Entire Network , Oracle VM VirtualBox Shared Folders . By right-clicking on a shared folder and selecting Map Network Drive from the menu that pops up, you can assign a drive letter to that shared folder.
Alternatively, on the Windows command line, use the following command:
While vboxsvr is a fixed name, note that vboxsrv would also work, replace x: with the drive letter that you want to use for the share, and sharename with the share name specified with VBoxManage .
In a Linux guest, use the following command:
To mount a shared folder during boot, add the following entry to /etc/fstab :
In a Oracle Solaris guest, use the following command:
Replace sharename , use a lowercase string, with the share name specified with VBoxManage or the VirtualBox Manager. Replace mountpoint with the path where you want the share to be mounted on the guest, such as /mnt/share . The usual mount rules apply. For example, create this directory first if it does not exist yet.
Here is an example of mounting the shared folder for the user jack on Oracle Solaris:
Beyond the standard options supplied by the mount command, the following are available:
This option sets the character set used for I/O operations. Note that on Linux guests, if the iocharset option is not specified, then the Guest Additions driver will attempt to use the character set specified by the CONFIG_NLS_DEFAULT kernel option. If this option is not set either, then UTF-8 is used.
This option specifies the character set used for the shared folder name. This is UTF-8 by default.
The generic mount options, documented in the mount manual page, apply also. Especially useful are the options uid , gid and mode , as they can allow access by normal users in read/write mode, depending on the settings, even if root has mounted the filesystem.
In an OS/2 guest, use the VBoxControl command to manage shared folders. For example:
As with Windows guests, shared folders can also be accessed via UNC using \\VBoxSF\ , \\VBoxSvr\ or \\VBoxSrv\ as the server name and the shared folder name as sharename .
4.3.2.В Automatic Mounting
Oracle VM VirtualBox provides the option to mount shared folders automatically. When automatic mounting is enabled for a shared folder, the Guest Additions service will mount it for you automatically. For Windows or OS/2, a preferred drive letter can also be specified. For Linux or Oracle Solaris, a mount point directory can also be specified.
If a drive letter or mount point is not specified, or is in use already, an alternative location is found by the Guest Additions service. The service searches for an alternative location depending on the guest OS, as follows:
Windows and OS/2 guests. Search for a free drive letter, starting at Z: . If all drive letters are assigned, the folder is not mounted.
Linux and Oracle Solaris guests. Folders are mounted under the /media directory. The folder name is normalized (no spaces, slashes or colons) and is prefixed with sf_ .
For example, if you have a shared folder called myfiles , it will appear as /media/sf_myfiles in the guest.
The guest properties /VirtualBox/GuestAdd/SharedFolders/MountDir and the more generic /VirtualBox/GuestAdd/SharedFolders/MountPrefix can be used to override the automatic mount directory and prefix. See Section 4.7, “Guest Properties”.
Access to an automatically mounted shared folder is granted to everyone in a Windows guest, including the guest user. For Linux and Oracle Solaris guests, access is restricted to members of the group vboxsf and the root user.
Copyright В© 2004, 2020 Oracle and/or its affiliates. All rights reserved. Legal Notices
Источник
Ubuntu Documentation
Introduction
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.)
Required: Virtualbox Guest Additions
Before sharing folders, you must install Guest Additions. For instructions on how to do this, see Guest Additions.
Creating a shared folder
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
Prepare the folder
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
Troubleshooting
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.
Ubuntu 10.04 host
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)
The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details
Источник
How to enable a Virtualbox shared folder for Linux guest systems
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.
Источник