Reputation: 1056
I followed million tutorials and guides on how to do it but no luck... Something is missing, hope you guys can help me out.
My OS: macOS Sierra
Virtualbox OS: Ubuntu 16.04
VM Network Adapter: Bridged Adapter
These are my steps:
Connect to vm via ssh
Install samba
$ sudo apt install samba
Create a directory to be shared
$ sudo mkdir /media/testshare
Add new share to smb.conf
$ sudo vim /etc/samba/smb.conf
[testshare]
comment = My Shared Folder
path = /media/testshare
browseable = yes
readonly = no
guest ok = yes
Restart samba
Add a samba password
$ sudo smbpasswd -a {username}
Try to connect from mac: In Finder, Command+K
to open "Connect to Server" and in Server Address: smb://192.168.0.104
I tried smb://192.168.0.104/testshare
, smb://192.168.0.104/media/testshare
I have no idea how to make it work. Help!
EDIT:
Might help, this is what I get when I run
$ sudo netstat -tulpn | egrep "samba|smbd|nmbd|winbind"
:
* I know that the ip is different now (192.168.0.104 => 192.168.0.109), its a new vm, don't pay attention to that.
Upvotes: 0
Views: 4049
Reputation: 2704
Host OS: macOS El Capitan
VM (guest) OS: Ubuntu Server 16.04.5 LTS
VirtualBox v5.2.18
Both host OS and guest OS must have same user (further in the text: username).
1.1. Locate the VirtualBox Guest Additions,
$ cd /Applications/VirtualBox.app/Contents/MacOS/
$ cp VBoxGuestAdditions.iso ~/Downloads/
1.2. Start the VM
1.3. Click the CD icon in the bottom right task bar
1.4. Select "Choose disk image..."" and search for the VBoxGuestAdditions.iso
1.5. In the guest terminal type (you can also do this from the host terminal if you SSH into it):
$ sudo su
$ apt update
$ apt upgrade
$ apt-get install dkms build-essential linux-headers-generic gcc make
$ mount /dev/cdrom /mnt
$ cd /mnt
$ sh ./VBoxLinuxAdditions.run
$ reboot
2.1. Create rules in VM:
Settings > Shared Folders
Add new port forwarding rule
green button in the top right of the window.Auto-mount
and Make Permanent
options2.2. To mount shared folder on /opt
you must create shared_folder_dir
subfolder and set appropriate permissions to it:
$ sudo mkdir -p /opt/shared_folder_dir
$ sudo chmod ug+w -Rv /opt/shared_folder_dir
$ sudo chown username:username -Rv /opt/shared_folder_dir
2.3. Add username to the vboxsf group:
$ sudo adduser username vboxsf
$ sudo usermod -a -G vboxsf username
2.4. Reboot VM to apply changes:
$ sudo reboot
host_folder
into /opt/shared_folder_dir
:3.1. Change VM's /etc/rc.local:
$ sudo nano /etc/rc.local
and place following right above exit 0
:
# 'folder_name' = given in the shared folders configuration
# 'path/to/shared/folders' = guest path to access the shared folders from
# 'id' = prints uid/gid
# sudo mount -t vboxsf -o uid={uid},gid={gid} {shared_folder_name} {path/to/shared/folder}
sleep 5
sudo mount -t vboxsf -o uid=1000,gid=1000 host_folder /opt/shared_folder_dir
exit 0
<<< EOF >>>
Note: I've added
sleep 5
to execute mount operation after VirtualBox Guest Additions has started. You can check that byjournalctl -b
command.
3.2. Reboot VM to apply changes:
$ sudo reboot
Upvotes: 3