Перейти к содержимому

Как создать общую папку в virtualbox для linux

  • автор:

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

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

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

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

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

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

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

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

VBoxWindowsAdditions

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

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

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

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

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

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

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

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

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

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. Можете зайти в любой и скопировать нужный файл в гостевую Виндовс и обратно.

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

Introduction

This explains how to share files and folders (directories) between host and guest. (Files are shared over a network, in other words, you access remote files. For virtual machines, the network between host and guest is virtual since they are on the same real machine. But the steps you take are similar to setting up file sharing over real networks.)

Required: Virtualbox Guest Additions

Before sharing folders, you must install Guest Additions. For instructions on how to do this, see Guest Additions.

Creating a shared folder

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share
  • Boot the Guest operating system in VirtualBox.
  • Select Devices -> Shared Folders.
  • Choose the ‘Add’ button.
  • Select ~/share
  • Optionally select the ‘Make permanent’ option

Prepare the folder

Linux

With a shared folder named share, as above, the folder can be mounted as the directory ~/host with the command

sudo mount -t vboxsf -o uid=$UID,gid=$(id -g) share ~/host

Windows

On the Windows Guest, run

net use x: \\vboxsvr\share

Now anything placed in this folder should be visible from the host in the ~/share folder.

Troubleshooting

This can be done more generically with the following:

sharename="whatever.you.want.to.call.it"; sudo mkdir /mnt/$sharename sudo chmod 777 /mnt/$sharename sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename ln -s /mnt/$sharename $HOME/Desktop/$sharename

For the above command if you get the following error:

mount: unknown filesystem type 'vboxsf'

Then just change the vboxsf to vboxfs

If you want to have it mount automatically upon each boot, put the mount command in /etc/rc.local Debian distros (e.g. Ubuntu 10.04 and later) HOWTO Use Shared Folders

See Section 4.4 «Folder Sharing» in the VirtualBox documentation.

Note: if you want to mount the directory as owned and writable only by root, omit the -o uid=1000,gid=1000 option to the mount command

/sbin/mount.vboxsf: mounting failed with the error: Protocol error

The above error could be one of the following.

The name was not valid

Make sure you specified the right name on the bash commands. If the guest machine is expecting «share» (as we did in the Prepare Host section) and you wrote

sharename="donotshare" sudo mkdir /mnt/$sharename sudo chmod 777 /mnt/$sharename sudo mount -t vboxsf -o uid=1000,gid=1000 $sharename /mnt/$sharename ln -s /mnt/$sharename $HOME/Desktop/$sharename

it will not work.

Ubuntu 10.04 host

Note: Running on Ubuntu 10.04 host and Mint 14 as virtual system, the system would not accept a ~/share. It complained that it was not an absolute address. I entered /home/jim/share and it worked fine.

  • Create a folder on the Host computer (ubuntu) that you would like to share, for example ~/share
  • Boot the Guest operating system in VirtualBox.
  • Select Devices -> Shared Folders.
  • Choose the ‘Add’ button.
  • Select ‘/home//share‘ for Folder Path
  • Select ‘share’ for Folder Name
  • Optionally select the ‘Make permanent’ option

VirtualBox/SharedFolders (последним исправлял пользователь dyn005202 2014-09-26 15:49:59)

The material on this wiki is available under a free license, see Copyright / License for details
You can contribute to this wiki, see Wiki Guide for details

Как подключить общую папку в Virtualbox

Читайте нашу статью: из неё вы узнаете, как создать общую папку и перенести файлы на виртуальную машину Virtualbox.

VirtualBox ― это бесплатный гипервизор. Он позволяет создать виртуальную машину, на которой можно тестировать новое ПО или операционную систему.

В зависимости от того, на какую виртуальную машину установлена операционная система, она имеет своё обозначение:

  • гостевая ОС ― операционная система, которую установили на виртуальную машину;
  • хостовая ОС ― операционная система, которую установили на физический компьютер.

Виртуальная машина “питается” ресурсами физической машины (то есть компьютера), но файлы гостевой ОС всегда изолированы от хостовой. Поэтому переносить файлы с хостовой ОС на гостевую и наоборот нельзя. Но как быть, если нужно скопировать файл в виртуальную машину VirtualBox с реального компьютера?

Это ограничение можно обойти с помощью специальных дополнений и создания общей папки в хостовой ОС. Как это сделать ― расскажем ниже.

Как подключить общую папку к гостевой Ubuntu

1. Создайте папку в хостовой ОС.

2. Откройте Virtualbox.

3. Кликните по виртуальной машине. Затем выберите Настроить:

4. Перейдите в раздел Общие папки и нажмите на значок папки с плюсом:

5. Выберите папку, которую вы хотите добавить в гостевую ОС. Отметьте галочкой пункт Авто-подключение и нажмите OK:

6. Один раз кликните на виртуальную машину и выберите Запустить:

7. В разделе “Устройства” нажмите Подключить образ диска Дополнений гостевой ОС:

8. Загрузите образ:

9. Подключите образ:

10. Запустите приложение с виртуального диска:

11. Подтвердите запуск. Для этого введите пароль пользователя:

Затем дождитесь окончания установки.

12. Выдайте доступ к папке из гостевой ОС. Для этого откройте Терминал и выполните команду:

sudo adduser ubuntu vboxsf

Вместо ubuntu укажите имя вашего виртуального компьютера.

13. Перезагрузите гостевую ОС.

Если возникла ошибка

При установке дополнений может возникнуть ошибка. Её текст следующий:

Unable to insert the virtual optical disk into the machine

Чтобы решить проблему установки:

1. Откройте Virtualbox.

2. Кликните по виртуальной машине. Затем выберите Настроить:

3. Перейдите в раздел Носители. Нажмите на образ диска и выберите Удалить устройство:

4. Подтвердите своё решение:

5. Кликните по значку диска с плюсом:

6. Выберите Оставить пустым:

7. Сохраните изменения:

Готово, общая папка отображается в гостевой системе. В неё можно загрузить файлы:

Как подключить общую папку к гостевой Windows

1. Создайте папку в хостовой ОС.

2. Откройте Virtualbox.

3. Кликните по виртуальной машине. Затем выберите Настроить:

4. Перейдите в раздел Общие папки и нажмите на значок папки с плюсом:

5. Выберите папку, которую вы хотите добавить в гостевую ОС. Отметьте галочкой пункт Авто-подключение и нажмите OK:

6. Один раз кликните на виртуальную машину и выберите Запустить:

7. В разделе “Устройства” нажмите Подключить образ диска Дополнений гостевой ОС:

8. В разделе “Проводник” выберите Этот компьютер. Разверните блок Устройства и диски и перейдите в VirtualBox Guest Additions:

9. Запустите приложение Vbox WindowsAdditions:

10. Подтвердите запуск:

11. На экране появится стартовое окно установки. Нажмите Next:

12. Чтобы выбрать папку для установки дополнения, кликните Browse. Затем нажмите Next:

13. Далее отобразится список компонентов установки. Нажмите Install:

Затем дождитесь окончания установки.

14. Перезагрузите гостевую ОС:

Готово, общая папка отображается в гостевой системе в разделе Этот компьютер. В неё можно загрузить файлы:

Популярные статьи

  • Как указать (изменить) DNS-серверы для домена
  • Я зарегистрировал домен, что дальше
  • Как добавить запись типа A, AAAA, CNAME, MX, TXT, SRV для своего домена
  • Что такое редирект: виды и возможности настройки
  • Как создать почту со своим доменом

How to enable a Virtualbox shared folder for Linux guest systems

VirtualBox is a very useful tool to install operating systems inside the main system. However, configuring the Virtualbox to share files between your main system and the system you installed in a VirtualBox is not trivial. So, I will show you how to enable a shared folder in Virtualbox for Debian, Linux Mint/Ubuntu, and Arch Linux as guest systems. I will also show a universal way that should work for any Linux guest distribution.

INTRODUCTION

There are several essential steps you need to follow, to enable a shared folder between the real machine (host) and the virtual machine (guest):

  1. Install guest additions for your guest system.
  2. Create a shared folder.
  3. Change the user permission for the shared folder.

In this tutorial, my host system is Arch Linux, but the host system does not matter in this case because we will do all the setting in the guest systems. So, I will show you the settings for Arch Linux, Linux Mint and Debian as guest systems. If you use some other distributions as a guest, look at the instructions for Debian. It is a universal way to enable a shared folder and it should work for all distributions.

VIDEO TUTORIAL

Enable a shared folder in VirtualBox for Arch Linux guest

Prepare the system

First, make sure your Arch Linux guest system is up to date. Open a terminal and update it:

sudo pacman -Suy 

Next, install kernel headers. I use the Linux kernel LTS, so I have to install the linux-lts-headers package. If you use the standard kernel, install linux-headers .

sudo pacman -S linux-lts-headers 

Then, install the virtualbox-guest-utils package. It will make you choose a package: either virtualbox-guest-modules-arch or virtualbox-guest-dkms . The Arch Linux wiki recommends choosing the virtualbox-guest-modules-arch package if you use the Linux kernel and virtualbox-guest-dkms for others kernels like LTS. Again, I use the linux-lts kernel so I needed to install the virtualbox-guest-dkms package.

sudo pacman -S virtualbox-guest-utils 

Install the virtualbox guest package on Arch Linux

After that, enable the VirtualBox kernel modules:

sudo systemctl enable vboxservice 

Add the shared folder

In VirtualBox, go to the Devices menu -> Shared Folders menu -> Shared folders settings.

Access into the Shared folder settings in Virtualbox

In the window that opens, on the right side, you will find the button to add a new shared folder. Click on it.

Adding a shared folder on Virtualbox

And select the folder you want to share between systems. For example, I usually share my Public folder. Make it permanent and activate auto-mounting by clicking on the options.

Define the options of the shared folder in Virtualbox

Then, you need to reboot the guest system. Once the guest system has rebooted, you can find the shared folder in the /media folder.

The shared folder is mounted but you can not access it:

The problem is, however, that only the root user can access the folder. To gain access to this folder as a regular user, open the terminal in your guest system and add your user to the vboxsf group.

sudo usermod -a -G vboxsf `whoami` 

`whoami` stand there to automatically paste your username. You can also type your username directly.

Next, give that user a permission to access the media folder.

sudo chown -R `whoami`:users /media/sf_Public/ 

Finally, log out, and log in again. Open the file manager and you should be able to access the shared folder as a regular user.

The shared folder is ready to use through the file manager

So, this is the whole process to enable a shared folder in VirtualBox using Arch Linux. You can start placing files there.

Enable a shared folder in VirtualBox for Debian guest

Installing guest addition in Debian is a little different from in Arch Linux. For Debian, I will show you a more universal way that you can apply to any other distro including Arch Linux. However, the way I showed before is preferable for Arch Linux.

Prepare the system and add a shared folder

In Debian guest, open a terminal and install the build-essential, dkms, and linux-headers packages.

sudo apt install build-essential dkms linux-headers-$(uname -r) 

Install some required package to enable a shared folder in Virtualbox using Debian

After that, you can add a shared folder. It is the same procedure as before. Go to the Devices menu -> Shared folders -> click on the Shared folder settings option.

Adding the shared folder in Virtualbox

Again, click on the button at the right to add the shared folder. Set the folder options you want and click on the Ok button.

Set the folder options in Virtualbox

After the packages are installed and the shared folder is added, reboot the system.

Install the GuestAddition CD Image

When your guest system has started. Go to the Devices menu and click on the Insert Guest addition image option.

Install the guest addition CD in in Virtualbox guest

Then, open a file manager, navigate to VBOXADDITION CD, right click in that directory and click on the open Terminal here option.

Open a terminal in the vbox addtion CD location

In the terminal, run the following command to install the VirtualBoxLinuxAddtions:

sudo sh VBoxLinuxAdditions.run 

Installing the vboxlinuxaddition script through the terminal in Virtualbox guest

Make sure it is installed without errors. If some errors occur, read the message, most likely the instruction for a fix will be provided. If the install is successful, you need to reboot the system.

Setting the permissions to the shared folder

If you go to the /media folder in the file manager and check if a shared folder is mounted, most likely you will not be able to access it as a regular user.

The shared folder is not accessible: Permission denied

To enable the access to this folder for a regular user, do the same what we did for Arch Linux, add your user to the vboxsf group.

sudo usermod -a -G vboxsf `whoami` 

And change the permission of the media folder.

sudo chown -R `whoami`:users /media/ 

Terminal commands to change the owner of a shared folder in VirtualBox with Debian guest

Log out, log in and you should be able to access the shared folder.

The folder is ready to use in Debian guest file manager

This method to enable a shared folder in VirtualBox for Debian is universal and it should work for any other distributions.

Enable a shared folder in VirtualBox for Linux Mint / Ubuntu guest

Linux Mint and Ubuntu usually come with VirtualBox guest addition pre-installed by default. If not, you can install it using a software manager like Synaptic.

Open the software manager, search and install virtualbox-guest-X11 , virtualbox-guest-utils , and virtualbox-guest-dkms .

Install the virtuabox guest addition packages through Synpatic in Linux Mint

Then do the same steps I showed for Arch Linux and Debian. First, add a shared folder.

Adding the shared folder in Virtualbox

Reboot the system. Then, add your user to the vboxsf group.

sudo usermod -a -G vboxsf `whoami` 

Change the permissions.

sudo chown -R `whoami`:users /media/ 

Set the permissions to the shared folder in Virtualbox

Finally, log out and log in, and you should have the shared folder working.

The folder is ready to use it in Linux Mint file manger

CONCLUSION

Now, you can use your VirtuaBox systems more extensively by sharing files between your host and guest systems.

If you use any other distro than Ubuntu-based ones, Arch Linux or Debian, try the way I show for Debian and let me know how it worked.

I recommend for the next read to learn how to clean Arch Linux.

Average Linux UserFollow I am the founder of the Average Linux User project, which is a hobby I work on at night. During the day I am a scientist who uses computers to analyze genetic data.

Добавить комментарий

Ваш адрес email не будет опубликован. Обязательные поля помечены *

https://kodirovanie.kapelnicza-ot-zapoya-sankt-peterburg.ru/