TranslateProject/sources/tech/20220511 Share Files Between Guest and Host OS in GNOME Boxes.md

6.9 KiB
Raw Permalink Blame History

Share Files Between Guest and Host OS in GNOME Boxes

Using GNOME Boxes tool for virtual machines but cannot figure out how to share files between the host OS and the OS in VM? This tutorial will help you with that.

GNOME Boxes is a VirtualBox and VM Ware like virtualization tool focusing on desktop Linux. It provides a simple GUI to create and manage virtual operating systems.

Virtual machines are a good way to test another operating system or distribution (in Linux context).

One of the pain points youll experience with VMs is the trouble in copying-pasting and file sharing between the guest and host systems.

Imagine you saved a file in the virtual machines but now you need it in your actual host system outside the VM. The ability to share the files between the two systems makes the VM experience quite smooth.

Let me show you how to do file sharing with GNOME Boxes. It consists of three steps:

  • Installing the required package on the guest OS (VM) to enable file sharing
  • Knowing how to transfer files from the host OS to the guest OS (drag and drop)
  • Knowing how to transfer files from the guest OS to the host OS (through a shared folder)

Note: Guest OS is the operating system inside the VM. Host OS is the main operating system where you are running the GNOME Boxes.

Install the required package on guest OS

Your guest OS (Linux distribution in the VM) needs a SPICE package in order to share files with the host OS (the main operating system).

On Debian, Ubuntu and Fedora based distributions, this package is named spice-webdavd. You can use your distributions package manager to install it inside the guest OS (running in the virtual machine).

For Ubuntu and Debian based systems, use this command:

sudo apt install spice-webdavd

For Fedora based distributions, use this command:

sudo dnf install spice-webdavd

Restart the guest OS.

Remember that you need this package on all the guest operating systems. So every time you create a new VM, you have to take care of this package.

Transfer files from the host OS to the guest OS

This is the simpler of the two. You just have to drag the desired file to the guest OS running in the VM.

Youll see that when you are dragging the file to the VM, it starts showing a Ready to Recieve File option.

Drag and drop files to the guest OS from host OS

The transferred files are saved in the Downloads directory.

Alternatively, you can also send files from the GNOME Boxes menu. Just hit the hamburger menu and click on Send File option.

Sending files in GNOME Boxes

Transfer files from the guest OS to the host OS

This one is not as straightforward as dragging and dropping.

Here, you use the SPICE protocol to mount a folder of the host OS. You drop the files here and it is transferred to that folder on the host.

The package you installed earlier was required for this kind of operation.

Click on the hamburger menu and select the Preferences option.

Select GNOME Boxes Preferences

Here, go to the Devices & Shares tab. Look under the Shared Folder section. You should see a + button. Click on it, and it will give the default location of the Public folder on your host operating system. You can change it to any folder of your liking.

Sharing host OS’s folder in GNOME Boxes

With that set, open the File Explorer in the guest OS. Here, click on the Other Locations option (in GNOMEs Nautilus file explorer).

Mount Spice client folder

This will mount the Spice client folder.

mounting spice client folder GNOME Boxes

Enter this mounted folder and you should see the folder you had added via the Preference menu here. In the screenshot below, I have two shared folder (because I added another one later on).

mounted spice client folders

In the shared folders, you can create new folders or copy-paste the files. They will be immediately available in the host OS.

I shared two screenshots taken in the guest OS and put them in the mounted Spice client folder.

Sharing files from the guest OS to the host OS

It immediately appeared in the public folder of the host OS.

Shared files appear in the host OS

Of course, its a two-way sharing. If you put something in the shared folder on the host OS, it will be accessible in the mounted folder in the guest OS.

Note that you have added the host OSs folder on GNOME Boxes level. This means that if you have multiple VMs, all of them should be able to mount that folder.

To keep things organized, you may add multiple shared folders and name them in a way that you can recognize which VM uses them.

Did it work for you?

GNOME Boxes is a pretty good tool for trying various Linux distributions as virtual machines. You can also share the clipboard between the guest and host systems with the method described here. This means that if you copied some text in the host OS, you could paste it into the guest OS and vice versa.

This is pretty much what you need to know and do about sharing files between guest and host OS with GNOME Boxes.

Do let me know if you managed to make it work or if you still face issues. The comment section is all yours.


via: https://itsfoss.com/share-files-gnome-boxes/

作者:Abhishek Prakash 选题:lkxed 译者:译者ID 校对:校对者ID

本文由 LCTT 原创编译,Linux中国 荣誉推出