Virtualbox linux share files

How to access a shared folder in VirtualBox?

I followed the steps for sharing folders between Windows 7 and Ubuntu in VirtualBox. Despite that the folder appears with a X sign and gives me the following message when a try to open it:

On the system page, you have assigned more than 50% of your computer’s memory (2.93 GB) to the virtual machine.

10 Answers 10

Access to shared folders in Virtual Box

Command line

By default, VirtualBox shared folders are created with read/write permission for the guest. This can be done from the command line on the host with:

VBoxManage sharedfolder add "VM name" --name sharename --hostpath "C:\test" 

By adding the option —readonly we can restrict these for read-only access. Use the —transient option if you only want the shares to appear in the present session but not persistent for following sessions. There are some limitations for shared folders (see this question for details). If prerequisites are met we may mount these shared folders manually by running the following commands in the guest:

mkdir /home//vboxshare sudo mount -t vboxsf -o uid=1000,gid=1000 sharename /home//vboxshare 

Of course, we can also use different mount options to mount as read/only or mount with read access only to root.

Auto-Mount through Virtual Box Manager

In case we enabled auto-mounting on creating a shared folder from the Virtual Box Manager those shared folders will automatically be mounted in the guest with mount point /media/sf_ . To have access to these folders users in the guest need to be a member of the group vboxsf .

sudo usermod -aG vboxsf $USER 

The guest will need to restart to have the new group added.

Source and further reading: Virtual Box User Manual

i set a shared folder in the GUI and also set the Auto-Mount. restarted the VM, went to /media but still nothing there

This command, suggested by another answer here, seems clearer and has better output: sudo adduser your_username vboxsf

@JordanBrough: totally correct — all ways lead to Rome. You can even use a graphical frontend users-admin . The command was edited in by another user.

Thanks for your answer.. in the command you mentioned above sudo mount -t vboxsf -o uid=1000,gid=1000 share /home//vboxshare , I don’t see a mention of the sharename , which is used when creating the shared folder using VBoxManage sharedfolder add «VM name» —name «sharename» —hostpath «C:\test» . If there are multiple shared folders.. how does VirtualBox know which sharename to associate the folder vboxshare with? Or do you mean that sharename should be the same as vboxshare ?

Читайте также:  Linux переход на новую строку

Actually there is an easy way to do that:

  1. Install the extension pack for VirtualBox.
  2. Restart your virtual machine
  3. Install Guest Additions in your guest Ubuntu
  • You can mount the ISO which is on /media or press Left Control + D
 sudo adduser your_vm_username vboxsf 

THIS. I wasn’t in the user group. Seems like that should have been automated by the gest additions or at least stated clearly.

@Atcold Logging out and in again adds the group to the current user (session) but did not trigger auto-mount of the shared folder in my case. Only a reboot did.

First, please make sure you have installed the Guest Additions

Insert Guest Additions CD image.

  1. Start your VM
  2. Devices > Insert Guest Additions CD image.
  3. Mount the CD:
sudo mount /dev/cdrom /media/cdrom 
sudo apt-get install make gcc linux-headers-$(uname -r) 
sudo /media/cdrom/VBoxLinuxAdditions.run 

Second, add your user to the group ‘vboxsf’:

~$ echo $USER; ahmed ~$ sudo usermod -a -G vboxsf ahmed 

Reboot

Know that the label of your shared folder is lpi (for example):

Edit shared folder

Prepend sf_ to the label. Then, you will find your shared folder under /media/sf_lpi

Finally, you can also create a link to your home. For example:

ln -s /media/sf_lpi /home/ahmed/lpi 

Can I use a shared folder from an Ubuntu VM without a harddisk image, but with only a Live CD image? Basically I am trying to add two CD drives, one holding the Ubuntu Live CD, and the other one holding the VBGuestAdditions.iso, and start the machine, then install VBGuestAdditions in the loopback root, and then I would like to be able to access a shared folder.

Also, is there a way to see the shared-folder before mounting, such as by using a command like lsblk or something?

When I try to do «sudo mount -t vboxsf mysharename mysharemountpoint», I always get: «/sbin/mount.vboxsf: mounting failed with the error: No such device»

Add the shared folder to the virtual machine using vBox graphical interface Make sure to select automount and make permanent

Login to the virtual machine using a root account

Check vboxsf group exists

~$ grep vboxsf /etc/group vboxsf:x:125: 

Check user is not already in vboxsf group

~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare) 

Add user nilo to vboxsf group

~$ sudo usermod -a -G vboxsf nilo 
~$ id nilo uid=1000(nilo) gid=1000(nilo) groups=1000(nilo),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),109(lpadmin),124(sambashare),125(vboxsf) 

Reboot and login as nilo

Shared folder is now accesible in /media/sf_dropbox (dropbox is the name I gave to the share)

Share a folder between Host OS-> Windows and Guest OS ->Ubuntu(Virtual box)

Step 1 Install install Guest Additions from VirtualBox’s menu go to Devices->Install Guest Additions This will mount a virtual CD on your /media/cdrom. As root user Open this /media/cdrom added folder using Open with terminal option(Right click with mouse).

Step 2 Run the program VBoxLinuxAdditions.run. When the program completes reboot your VirtualBox.

$ sudo ./VBoxLinuxAdditions.run 

Step 3 Create a shared folder. From Virtual menu go to Devices->Shared Folders then add a new folder in the list, this folder should be the one in windows which you want to share with Ubuntu(Guest OS). Make this created folder auto-mount. Example -> Make a folder on Desktop with name Ubuntushare and add this folder.

Читайте также:  Linux for android programming

Step 4 When done with you shared folder(s) specification, we mount folder from Ubuntu(Guest OS). Create a mountpoint, this a directory in Ubuntu that will share files with the shared folder from Windows. Run this to create a directory in Ubuntu

$ sudo mkdir ~/Desktop/windowsshare 

Step 5 With your mountpoint created you can now mount the shared folder. Run this command to share the folder:

$ sudo mount -t vboxsf Ubuntushare ~/Desktop/windowsshare 

Ubuntushare is the name of folder we add in VirtualBox Devices section this folder is in Windows(Host OS). ~/Desktop/windowsshare is the directory in Ubuntu(Guest OS)

CONGRATULATIONS-> Now you can share the files between Windows and Ubuntu. Try adding any file in windows(Host OS) Ubuntu share folder now check Ubuntu(Guest OS) windowsshare directory the file will be reflected.

Источник

Как в VirtualBox сделать общую папку

VirtualBox — программа, предназначенная для создания виртуальной машины. Пользоваться утилитой можно совершенно бесплатно. С ее помощью получится быстро создать виртуальную ОС. Внутри можно будет проводить любые действия без рисков повредить основную систему. Чтобы полноценно пользоваться виртуальной машиной, необходимо найти способ передачи фалов. Для этого нужно создать общую папку в ВиртуалБокс, которая станет доступна в двух ОС и поможет выполнять файловый обмен.

Как настроить общую папку VirtualBox для Windows

Настройка общей папки отличается в зависимости от установленной на виртуальной машине операционной системы. Рассмотрим способ, когда две ОС — это Windows:

1. Чтобы общая папка стала доступна для основной и гостевой системы, установите дополнения. Откройте меню «Устройства». Кликните на надпись «Подключить образ диска Дополнений гостевой ОС».

Подключить образ диска в ВиртуалБокс

2. На виртуальной машине увидите оптический дисковод, на котором размещено программное обеспечение ВиртуалБокс.

3. После открытия дисковода вы увидите установочные файлы, которые подходят для различных ОС. Для Windows выберите программу «VBoxWindowsAdditions».

VBoxWindowsAdditions

4. Для установки нажмите на надпись «Next». После окончания процесса выполните перезагрузку ПК.

5. После того, как установились дополнения, можете создать общую папку. Для этого включите виртуальную машину, а затем перейдите в основном окне ВиртуалБокс к настройкам.

6. Перейдите к разделу «Общие папки». Создайте новую, а затем подключите опцию «Автоподключение». Затем обязательно сохраните настройки и запустите виртуальную машину.

Настройки общей папки в ВиртуалБокс

7. На виртуальной машине вы увидите сетевой диск, указывающий на общую папку из основной операционной системы.

При помощи получившегося сетевого диска вы сможете перенести файлы из Windows и обратно на виртуальную машину.

Создание общей папки в VirtualBox для Linux

Если основная ОС — это Виндовс, а виртуальной машины — Linux, то для создания общей папки следуйте инструкции:

1. Подключите образ диска, зайдя через меню в «Устройства», а затем выберите «Подключить образ диска».

Читайте также:  Linux display no protocol specified

2. Произойдет автоматическое монтирование подключенного диска. Система выдаст запрос с предложением открытия в диспетчере фалов. Предложение отклонять не надо, так как необходимо увидеть путь, куда примонтировался диск.

3. Диск смонтировался в каталог «/media/user/vbox¬_gas_6.1.4». У вас на компьютере адрес может быть другим. Находите файл «VboxLinuxAdditins.run», который выполните с правами root для установки дополнения гостевой ОС. Запустите терминал и исполните команду «/media/user/vbox¬_gas_6.1.4/ VboxLinuxAdditins.run». На вашем ПК путь может быть другим. Перезагрузите компьютер.

Обшие папки Линукс в Виртуал Бокс

4. Настройте общую папку ВиртуалБокс. Выключите виртуальную машину, а затем откройте ее настройки. В появившемся окне добавьте новую общую папку. Укажите к ней путь на ПК. Поставьте галочку возле надписи «Автоподключение».

5. Запустите виртуальную машину. Новая общая папка автоматически примонтируется в «/media/sf_foldername». Открыть вы ее сразу не сможете, так как отсутствует доступ. Для получения права добавьте пользователя в группу «vboxsf». Для этого запустите терминал, а затем выполните команду «sudo usermod-aG vboxsf user». Вместо «user» вписывайте имя добавленного вами пользователя.

Обшие папки Линукс в VirtualBox

6. После выполненных действий в диспетчере файлов появится с открытым доступом папка «/media/sf_temp».

Папка sf_temp в ВиртуалБокс

При помощи этой папки получится перемещать файл между основной ОС и виртуальной машиной ВиртуалБокс.

Как сделать общей папкой диск С и D

Можно сделать диски С и D доступными для двух ОС:

1. Откройте «Устройства», затем «Общий буфер обмена». Выберите «Двунаправленный».

2. Затем кликните на «Устройства», нажмите на «Общие папки». Выберите надпись «Настроить общие папки».

3. Увидите информационное окно. Согласитесь с представленной информацией, нажав на кнопку «Ок».

4. Добавьте новую общую папку.

5. Выберите путь под названием «Другой».

6. В появившемся окне при помощи мыши выделите диск С. Нажмите на надпись «Выбор папки».

7. Поставьте галочку возле надписи «Создать постоянную папку». Подтвердите действие, нажав на «Ок».

8. Добавьте еще одну общую папку.

9. Выберите путь «Другой».

Добавить общую папку в Виртуал Бокс

10. В появившемся окне выделите диск D. Кликните на надпись «Выбор папки».

11. Поставьте галочку возле надписи «Создать постоянную папку». Подтвердите действие, кликнув на «Ок».

12. Произошло расширение дисков основной ОС для гостевой Виндовс 10.

13. Теперь установите Дополнения к гостевой ОС. Нажмите на «Устройства», затем «Подключить образ диска».

14. Кликните на кнопку «Выполнить».

Открой образ диска Виртуал Бокс

15. Нажмите на надпись «Next».

16. Подтвердите действие, нажав на «Install».

17. После загрузки нажмите на «Установить».

Установка Виртуал Бокс

18. Подтвердите действие, нажав на «Finish».

19. Произойдет автоматическая перезагрузка ПК.

20. Откройте проводник. Кликните на «Сеть».

21. Подтвердите нажатием на «Ок».

Ошибки сети в Виртуал Бокс

22. Увидите сообщение о том, что сетевое обнаружение отключено.

23. Нажмите на левую кнопку мыши и выберите «Включить сетевое обнаружение».

Включить сетевое обнаружение

24. Согласитесь с включением обнаружения сети.

Включить сетевое обнаружение и общий доступ к папкам

25. Закройте проводник и откройте его снова.

26. Выберите «Сеть».

27. Зайдите в VBOXSVR.

28. Увидите диски С и D. Можете зайти в любой и скопировать нужный файл в гостевую Виндовс и обратно.

Теперь вы сможете перемещать файлы между основной ОС и виртуальной машиной ВиртуалБокс!

Источник

Оцените статью
Adblock
detector