How to transfer files from Windows to Ubuntu on Virtualbox?

There are 2 ways, which I normally use

Option 1: Before booting up Ubuntu, inside Virtualbox Ubuntu VM settings, specify a share folder. Then after logged in to Ubuntu, create a new directory for example /media/vboxshared and mount that drive using the command sudo mount -t vboxsf SHARENAME /media/vboxshared. Enter your password when it prompts for the password.

Option 2: Before booting up Ubuntu, add a new Network adapter and select 'Bridged Adapter'. Then after logged in to Ubuntu, run the command ifconfig -a | more to get the ip address of that new network adapter. In Windows, use WinSCP or FileZilla to transfer the file to Ubuntu


Thank you for Alvin Sim's answer. Though it is clear, I still spend some time to do everything correct. OK, here are my detailed steps using Alvin Sim's Option 1.

  1. Before starting your Guest
  2. Go to VirtualBox Manager
  3. Select your interested Guest
  4. Go to Guest Settings
  5. In Guest Settings, scroll the left side-menu, and go to Shared Folders
  6. In Shared Folders, add your interested folder in the Host machine
  7. After adding your Host folder path, you will see an updated Folders List in Shared Folders. Remember your newly folder Name shown in this list. Say it is HOST_SHARE.
  8. Click OK and save your changes.
  9. Start your Guest machine
  10. In Guest machine, create a new folder, e.g. GUEST_SHARE
  11. In Guest terminal, type

    sudo mount -t vboxsf HOST_SHARE GUEST_SHARE`
    

    If you see the error mount: wrong fs type, bad option, bad superblock on …, this means you first need to install virtualbox-guest-utils.

    sudo apt-get install virtualbox-guest-utils
    

    Then run the mount command again

  12. You shall find your stuffs in this GUEST_SHARE folder.


sudo mount -t vboxsf SHARENAME /media/vboxshared 
  1. create your shared folder at your PC. for example "c:\SharedBoth"
  2. make sure you have selected your shared folder c:\SharedBoth at virtualbox menu "settings" - "shared folders" - "add" -"permanent/automount", before you start the ubuntu virtual machine.
  3. start the ubuntu terminal, type in command above,
    sudo mount -t vboxsf SharedBoth /media
  4. then check if folder sf_SharedBoth created in media folder Before you do the step 3, you need to make sure you have installed "guest additions"