- Virtualbox linux mount drive
- 4.3.1.В Manual Mounting
- 4.3.2.В Automatic Mounting
- estorgio / Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS.md
- This comment has been minimized.
- fursserg commented Jun 15, 2018
- This comment has been minimized.
- ssy341 commented Dec 7, 2018 •
- This comment has been minimized.
- natrod commented Feb 5, 2019
- This comment has been minimized.
- binary-person commented Feb 14, 2019 •
- This comment has been minimized.
- estorgio commented Mar 5, 2019 •
- This comment has been minimized.
- timothy commented May 21, 2019
- This comment has been minimized.
- sagrawal-idrc commented May 31, 2019 •
- This comment has been minimized.
- nuistzhou commented Jun 18, 2019
- This comment has been minimized.
- sliawatimena commented Jul 25, 2019
- 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
Virtualbox linux mount drive
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
Источник
estorgio / Mounting VirtualBox shared folders on Ubuntu Server 16.04 LTS.md
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
This comment has been minimized.
Copy link Quote reply
fursserg commented Jun 15, 2018
Some systems may need option comment=systemd.automount in their fstab entry (source).
This comment has been minimized.
Copy link Quote reply
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:
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
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: https://docs.oracle.com/cd/E10926_01/doc/owb.101/b12150/appbcdmount.htm). Nice job otherwise!
This comment has been minimized.
Copy link Quote reply
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.
This comment has been minimized.
Copy link Quote reply
timothy commented May 21, 2019
I am using VertualBox 6 and Ubuntu 18.04. I do not see a checkbox that says «Make Permanent» as stated in step 7. On step 10 I get «mount: /media/cdrom: mount point does not exist.» error, and on step 15 I get «/sbin/mount.vboxsf: mounting failed with the error: Protocol error» error. Let me know if anyone knows what went wrong. Thanks!
This comment has been minimized.
Copy link Quote reply
sagrawal-idrc commented May 31, 2019 •
Host: Windows Server 2012 R2
Guest: Ubuntu Server 18.04 LTS
I had to additionally install following to get the shared folder mounted:
sudo apt-get install virtualbox-guest-utils virtualbox-guest-dkms
After rebooting, the shared folder appears under /media ; vboxadd-service.service still fails for me though.
This comment has been minimized.
Copy link Quote reply
nuistzhou commented Jun 18, 2019
Well, according to the chosen answer here, you could just skip steps 9 — 13 if the guest OS is Ubuntu, this works well when host OS is either Windows or Mac OS.
This comment has been minimized.
Copy link Quote reply
sliawatimena commented Jul 25, 2019
Host: Ubuntu 18.04 LTS
Guest: Windows 10 Pro
VirtualBox 6.0.10
After I issue this command twice
$ sudo apt-get install virtualbox-guest-utils virtualbox-guest-dkms
I got make it permanent tick box. However in my Windows E: is a cdrom drive, not a harddisk as expected.
How to correct this? Thank you very much in advance.
Источник
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
Источник