Monday, 27 August 2012

Share Folder between Mac OS and Ubuntu in VirtualBox

Last night, I want to share the unp(UNIX network programming) source code between my host Mac OS and Ubuntu in the Virtual Box.
So I summarize some steps:

 Mac OS : Mountain Lion
 Virtual Box: 4.1.20
 Ubuntu: 12.04

1.      setup the share folder in the Mac OS.
         Choose in the VirtualBox's men:  settings -> Shared Folders.
        

2.  Add the new shared folder button
     Choose the Folder Path e.g /User/reg/xxxx
     and You should give the name for it, which will be used in the mount in the Ubuntu
     Select Make permanent  -  if you would like to persist this shared folder definition





3.Now work in the Ubuntu in the Virtual Box
 
 a.   Create the folder to be shared folder mount the Mac OS Shared folder.
   e.g  ~/share
 

  b.   get you id
       
       id
    
  c. Mount the shared folder
     
    sudo mount -t vboxsf -o uid=USER_ID Mac_OS_Shared_Folder_Name Ubuntu_Shared_Name 

  
   e.g.


    sudo mount -t vboxsf -o uid=1000 share ~/share 
 
 IF you meant any issues about vboxsf 
 e.g.
    mount.xboxsf failed no such device

make sure you installed the Virtual Box's Guest Additions
  
The steps about install Guest Additions

   Choose the Virtual Box VM
   Devices ----> Install Guest Additions

   Now the Virtual Box will help you install it,
   if not, you can enter the directory in the Ubuntu  /media/VBOXADDITIONS_xxx
   run the VBoxLinuxAdditions.run


  Now make sure the vboxsf module is right
  No error to run the modprobe vboxsf

4. Now you can use the shared folder.



Others about the  UNP
if you run the ./daytimecocli 127.0.0.1

connect error: Connection refused

you May not start the daytime server

1.    Install the xinetd
       apt-get install xinetd

 2.  modify the /etc/xinetd.d/daytime,
      change the two disable yes -------> disable no

3. Now you can /etc/init.d/daytime restart