Monday, February 9, 2015

Vagrant - Resolving shared disk mounting issues

Prerequisites:
           Host:    Windows 7
           Guest:   Centos 7   ( + VirtualBoxGuestAdditions is installed)

Install VirtualBoxGuestAdditions:
@HostVirtualBox:
                Devices --> Insert Guest Additions CD image
            ## mounts C:\Program Files\Oracle\VirtualBox\VBoxGuestAdditions.iso
@GuestOS using SSH:
            $ mount /dev/cdrom /media; cd /media
            $ ./VBoxLinuxAdditions.run

==============================================================
Setup:


C:\> cd Program Files\Oracle\VirtualBox

Mount shared directory on guest:

C:\Program Files\Oracle\VirtualBox>VBoxManage sharedfolder add "devbox" --name "vbox-devbox" --hostpath "D:\tasks\vbox-devbox"

Start your guest headless:
C:\Program Files\Oracle\VirtualBox>VBoxManage startvm "devbox" --type headless


---------------------------------------------------------------------------------------------------------------
                                                 Errors
---------------------------------------------------------------------------------------------------------------

1. """"Error!!!""/sbin/mount.vboxsf: mounting failed with the error: No such device"""""

Solution: Run below commands on guest:

[root@localhost ~]# /etc/init.d/vboxadd setup
Removing existing VirtualBox non-DKMS kernel modules       [  OK  ]
Building the VirtualBox Guest Additions kernel modules
Building the main Guest Additions module                   [  OK  ]
Building the shared folder support module                  [  OK  ]
Building the OpenGL support module                         [  OK  ]
Doing non-kernel setup of the Guest Additions              [  OK  ]
Starting the VirtualBox Guest Additions                    [  OK  ]
[root@localhost ~]#
[root@localhost ~]# modprobe vboxsf
[root@localhost ~]#
[root@localhost ~]# vi /etc/modules-load.d/vboxsf.conf
vboxsf
[root@localhost ~]# vi /etc/fstab
vbox-devbox        /mnt          vboxsf  uid=root,gid=root,rw,dmode=700,fmode=600 0 0
[root@localhost ~]# mount -a