Arch linux virtualbox общая папка

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:

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.

Читайте также:  Writing windows iso to usb linux

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.

Читайте также:  Kali linux ошибка установки программного обеспечения

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` 
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.

Источник

Не работает общая папка с Arch в VirtualBox

Начинаю осваивать арч. Установил на виртуалку. Хостовая машина с Manjaro.
В настройках виртуалбокс делаю общую папку между машинами. Но вот беда, как в виртулках с виндой или убунтами всякими — нигде не появляется в виртуальном арче эта самая общая папка 🙂

Читайте также:  Nvidia linux driver nouveau kernel driver

Подскажите пожалуйста, в чем секрет? 🙂

Понял, что изначально действовал некорректно. Я пиханул вирт. CD из хостовой ОС и с него ставил virtualbox-guest-utils.
Теперь из репозитория не могу установить актуальные:

conflicting files:
virtualbox-guest-utils: /etc/xdg/autostart/vboxclient.desktop already exists in filesystem
virtualbox-guest-utils: /usr/bin/VBoxClient already exists in filesystem
virtualbox-guest-utils: /usr/bin/VBoxClient-all already exists in filesystem
virtualbox-guest-utils: /usr/bin/VBoxControl already exists in filesystem
virtualbox-guest-utils: /usr/bin/VBoxService already exists in filesystem
virtualbox-guest-utils: /usr/bin/mount.vboxsf already exists in filesystem
virtualbox-guest-utils: /usr/lib/VBoxOGL.so already exists in filesystem
Как вычистить стырый пакет в такой ситуации? Или вообще не в том направлении думаю?

Проверить не принадлежат ли конфликтующие файлы какому нибудь пакету, если не принадлежат удалить их, или установить пакет с перезаписью

pacman -Qo путь до файла pacman -S пакет --overwrite=путь до конфликтующего файла(без/ вначале) #или все pacman -S virtualbox-guest-utils --overwrite=* 

Проверить не принадлежат ли конфликтующие файлы какому нибудь пакету, если не принадлежат удалить их, или установить пакет с перезаписью

pacman -Qo путь до файла pacman -S пакет --overwrite=путь до конфликтующего файла(без/ вначале) #или все pacman -S virtualbox-guest-utils --overwrite=* 

Спасибо за помощь. Логику понял. Все получилось 🙂 Надеюсь в подобных вопросах теперь буду самостоятельнее 🙂
Теперь выполнил все по вики. Пользователя в группу вбокса добавил. Но общая папка все равно автоматически не монтируется.

mount.vboxsf
mount: only root can use «—no-canonicalize» option
┌ 1 ~
└> % sudo mount.vboxsf
mount: : can’t find in /etc/fstab.

В группу своего юзера добавили, сервис запустили? И права на папки проверьте. В вики по ссылке выше все написано

В группу своего юзера добавили, сервис запустили? И права на папки проверьте. В вики по ссылке выше все написано Юзера в группу добавил, проверил, присвоилась.
Сервис запущен, при загрузке системы.

А что с правами папки? Не нашел в вики про это. На хост машине проверять? Какие должны быть?

(сорян, я даже с вики не осиливаю всё это, ну вот прям гуманитарий(()

Общая папка стала доступна, но только руту.

Права на чтение и запись к общей папке есть у группы vboxsf. Мой пользователь добавлен в эту группу.
Папку в thunar вижу. Зайдя в неё — типа 0 файлов.
А из под рута доступ есть и все файлы видно.

Я подозреваю, причина в том, что у моего пользователя почему-то нет доступа к /media.
Как это правильно исправить? Или я не в ту сторону мыслю?

© 2006-2023, Русскоязычное сообщество Arch Linux.
Название и логотип Arch Linux ™ являются признанными торговыми марками.
Linux ® — зарегистрированная торговая марка Linus Torvalds и LMI.

Источник

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