VirtualBox: mounting shared folder fails during start-up, but succeed from shell - linux

Problem description:
When I boot my VirtualBox Guest OS, the mounting of the shared file-system - which is referenced in /etc/fstab - fails.
However, after login - mount -a succeeds.
Details:
The boot process gets stuck here ...
... and pressing s continues the boot process, which finishes.
In the shell, I verify that my shared directory is not mounted:
But now, from the shell, the mount of the shared file-system succeeds:
What should I do to make my mount succeed during start-up?
Environment:
VirtualBox: 4.3.12.r93733
Host OS: Windows 7
Guest OS: Linux ubuntu 3.13.0-32-generic #57~precise1-Ubuntu x86_64 GNU/Linux
/etc/fstab
Relevant lines in /var/log/boot.log

You don't have to mount it, VitrualBox will make it for you. For me,these steps worked on my System (VirtualBox 5.0.10 on Windows 7 and Kubuntu 14.04 guest system):
In VirtualBox, configure your shared folder for your machine under 'Shared Folder'. Pick up the directory on your host system (e.g. D:\shared) and set a name for your guest system (e.g. shared).
Boot the guest system. Now you should have a mounted folder under \media\sf_shared.
Thats all. VirtualBox manages this for you.

You need to install VirtualBox Guest Additions properly and use VirtualBox Manager to specify share folders. The issue happens because the mount point is in place with root permissions. The default mount location is in /media/sf_.
You can change mount point with VBoxControl command. To change the mount point from /media/sf_... to /home/user/sf_... use the command:
sudo VBoxControl guestproperty set /VirtualBox/GuestAdd/SharedFolders/MountDir /home/user/
To check if that's working:
sudo VBoxControl guestproperty get /VirtualBox/GuestAdd/SharedFolders/MountDir

Related

WSL file system permission mixed up with windows files

I'm using WSL2 (Windows Subsystem for linux), and I've been using it for a really long time, and I didn't have troubles with it.
Unfortunately, today, from my linux distribution (Ubuntu 20.04), I no longer have permissions to view some Windows files, to which I had previously access without trouble. I don't know what happened, I don't remember intalling any update manually.
However, interestingly, I can access them if I do sudo su and become root. Then, I can access everything, or I can use sudo cat. But I don't want anything of that, I want to be the default WSL user to do what I could before.
What I tried:
Adding my default user to admin group, root group and sudo group (no luck)
Addming username to sudoers
root ALL=(ALL:ALL) ALL
danon ALL=(ALL:ALL) ALL
Editing permissions in my Windows host machine to allow everyone to access it
Editing permissions in my Windwos host to change the owner of the file (and directories below it)
Use other WSL distros, Ubuntu 20.04 and Ubuntu 18.04
Add metadata option to /etc/wsl.conf
Restarting the distro
Restarting the wsl
Restarting the host system
I don't know what else to do. I don't want to do sudo su everytime I open my wsl, or call each method with sudo.
I would like either to access my files from WSL like I used to before, or maybe specifically make those files available to my default linux user.
Result of mount:
C:\ on /mnt/c type 9p (rw,noatime,dirsync,aname=drvfs;path=C:\;uid=1000;gid=1000;metadata;umask=22;fmask=11;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8)
D:\ on /mnt/d type 9p (rw,noatime,dirsync,aname=drvfs;path=D:\;uid=1000;gid=1000;metadata;umask=22;fmask=11;symlinkroot=/mnt/,mmap,access=client,msize=65536,trans=fd,rfd=8,wfd=8)

why azure file share is not mounting on centos versions under 7?

Is there any way to create Azure File Share mounts on CentOS versions lower as 7?
Azure documentation recommends centos 7+ for it.
I have tried the same for CentOS 7 and Ubuntu 16.04.Its working fine.
But for CentOS version under 7 it is not working.
But for CentOS version under 7 it is not working.
It is a by design behavior, because Azure files share requires SMB 2 dialect which supported by newer CIFS module in RHEL 7.
Pasting the note from Redhat Support Forum:
"For RHEL when you use the mount command your are using the kernel
driver for cifs. The features for cifs commections are tied to the
kernel module providing this. You can see details for this with module
"man mount.cifs" The RHEL6 kernel is only capabable of mounting older
1.0 smb protocol mounts. RHEL7 however can mount smb2 version of the protocal since the kernel is using a newer cifs module. On RHEL7 in
"man mount.cifs" you will see the options to specify vers= 1.0, 2.0,
2.1, or 3.0."
If you want to mount Azure files share to Centos 6, as a workaround we can update your kernel to 3.1.0 or 4.6, install the last version of cifs-utils, but it is not recommended.
As per my knowledge,you are missing the mount-point directory in the Linux VM to mount the SMB share to.
In Linux VM: You need to create a local directory at /mnt/mymountdirectory, use the following example to create a local directory:
sudo mkdir -p /mnt/mymountdirectory
Then Mount the SMB share to the local directory by providing your own storage account username and storage account key for the mount credentials as follows:
sudo mount -t cifs //myStorageAccount.file.core.windows.net/mystorageshare /mnt/mymountdirectory -o vers=3.0,username=mystorageaccount,password=mystorageaccountkey,dir_mode=0777,file_mode=0777
For more details, refer “Use Azure Files with Linux”.
And also, you may refer MSDN thread, which addressing your query.

Is there a way to share host (ubuntu) file system with guest (centos 7)?

I am trying to use virsh and domain xml to launch a Centos 7 guest from ubuntu 16.04 LTS host.
The "filesystem" node that i am using in domain xml is as below:
<filesystem type='mount' accessmode='passthrough'>
<driver type='path' wrpolicy='immediate'/>
<source dir='/opt/test'/>
<target dir='testlabel'/>
</filesystem>
With the above config, "testlabel" is not visible in the guest and hence i am not able to mount it. Is there anything that i am missing?
I tried to have 9p modules in guest but they don't seem to be available in centos 7.
I do not want to use network based file sharing like NFS or glusterfs either.
RHEL-7 (and thus CentOS-7) explicitly does not support the 9p filesystem. It is disabled in guest kernel builds and also disabled in QEMU builds for RHEL hosts. The reason is that 9p support in QEMU has been largely unmaintained upstream and the QEMU community doesn't have confidence its is security or performance.
If you want to share filesystem locations, pretty much your only choice is to use a traditional network filesystem, whether NFS, SAMBA, or something tunnelled like SSHFS.
Work is ongoing upstream to support a new technology called virtio-vsock, which will allow running NFS-over-vsock, bypassing the need for networking - think of it as akin to NFS over UNIX sockets. This is not ready for use yet though, so not possible for an Ubuntu/RHEL-7 pair.
Use for the guest (CentOS 7) the kernel from the CentOSPlus repository Wiki CentOSPlus. The CentOSPlus kernel has the 9p file system support build in. You can install the "kernel-plus" kernel with
yum --enablerepo=centosplus install kernel-plus
Start the guest with the "kernel-plus" kernel and
mount -t 9p -o trans=virtio {sharetarget} {mountpoint}
works. I use it this way on CentOS 7 guest systems.

Vagrant takes a long time to mount default shared folder

vagrant 1.9
virtualbox 5.1.12
base box: https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box
Current Laptop: Windows7 on Dell Latitude E7270 with 250gb ssd on bitlocker.
So with that out of the way, I was previously using vagrant with the same version of vagrant, virtualbox and base box on a different computer with a mechanical hdd without bitlocker. Everything is ok until I upgraded my laptop.
In vagrant if we do vagrant init in a folder and launch vagrant it will mount the folder with the VagrantFile to the /vagrant on the guest machine. On the current laptop it takes a loong time for vagrant to mount this shared folder.
Do you think its bitlocket that might be causing this issue?
Thanks

How can I mount a folder from an ubuntu virtual machine on ubuntu?

I tried sshfs, but the local directory where I want to mount a folder from the VM does not open after running the command.
Install the Guest Additions on the virtual machine. These can be dowloaded from within the virtual machine from the Devices > Install Guest Additions menu.
Add the folder you wish to share to the Shared Folders, this option can also be found in the Devices menu.
The folder can now be mounted with
sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) folder ~/host
For more info, or troubleshooting, check out this Ubuntu Help article.

Resources