How To Create A Shared Directory Between Host And Guest In KVM?
KVM or kernel-based virtual machine is a virtualization module of Linux kernel. It requires hardware with virtualization extensions such as Intel-VT or AMD-V to provide hardware-assisted virtualization. By using VirtIO it provides paravirtualization support for various operating systems such as Linux, FreeBSD, Windows, etc.
While working on VMs sometimes you may need to use a file that is on the host OS. You can do this in various ways one of them is 9p virtio sharing. In this article, we will see how you can create a shared directory between guest and host OS using virt-manager.
Host operating system
Host refers to a bare-metal machine and the operating system that runs directly on it is called the host OS. It installs the required virtualization packages and provides an environment to run an OS in a virtual machine.
Guest operating system
An OS installed on a virtual machine that is created on the top of the host machine is called guest OS. You can run multiple virtual machines simultaneously on a host.
We will share files in
/home/lalit/Share on the host. In the guest, they will show up in
/home/lalit/Desktop/host_files. Now follow the steps given below to create a shared directory –
1. Create a directory that you want to share between both host and guest OS. Here I am creating this to
/home/lalit/Share on the host. To create a directory you can use the following command in the terminal –
2. Change the owner of this directory to libvirt-qemu by using the following command –
chown libvirt-qemu /home/lalit/Share
3. Now, In the virt-manager open a guest by double-clicking on it and then click on show virtual hardware details as it is given below –
4. Here, click on Add Hardware option which is highlighted in the below image –
5. This will open a new window to fill the required information. Keep driver default, select mode squash and browse and select the directory which you want to share and insert the target path (not a path) used to refer filesystem. Once done click on finish.
6. Next, it will ask you for the confirmation press yes –
7. Now open the terminal and create a directory where you will mount the created filesystem. Use the following command to create a new directory in guest OS terminal –
In my case, I will run,
8. Next thing is to reboot your guest OS to make changes effective. And then run the following command to mount the filesystem to host_files directory in the guest OS terminal –
mount -t 9p -o trans=virtio,version=9p2000.L /hostshare /home/lalit/host_files
The other possibility of creating a shared directory includes NFS or CISF/Sambha. Now I hope this article is helpful to you if you have a query you can write us in the comments below.
You might also like
Originally the term RAID defined as “Redundant Array of Inexpensive Disks” but now it is referred to as “Redundant Array of Independent Disk”. It is a data storage virtualization technology.
Contents1 Standard streams1.1 Input redirection – 1.2 Output redirection – 1.3 Append the output to an existing file-2 Pipe And Filters2.1 grep command-2.2 sort command-2.3 awk command- Standard streams In
This post was last updated on July 9th, 2020 at 04:57 pm Filename Date Size Title Description ifconfig.html 2005 Jul 07 – 10:06:46 3330 ext-rename.html 2005 Jun 22 – 11:17:09