VOOZH about

URL: https://www.tecmint.com/manage-kvm-storage-volumes-and-pools/

โ‡ฑ How to Manage KVM Storage Volumes and Pools for Virtual Machines - Part 3


Skip to content

In this part 3 of our tutorial, we are discussing how to create and manage KVM Storage volumes and Pools using virt-manager GUI tool.

In general, we use storage devices with different file systems everyday. We have also some storage technologies/techniques like ISCSI, SAN, NAS and so on.

There is no huge different in the basic concepts for our virtual environment, we just use the basic concept to deploy awesome and scale-able virtual storage platform.

With KVM environment , you can use block devices or files as local storage devices within guest operating systems.

We use the physical storage devices to create virtual machineโ€™s volumes. We could describe volumes as a virtual machineโ€™s virtual disk. Volumes cloud be block devices or files as we have mentioned previously.

๐Ÿ‘ Create KVM Stroage Volumes and Pools
Create KVM Storage Volumes and Pools

As a performance consideration, the block devices have the higher hand. Also block files still have the higher hand in the areas of system management and storage capacity use. At any way for scenarios where disk performance from the guest operating system is not critical, its prefer to use disk image files.

Storage volumes also is a part of Storage Pool, actually you canโ€™t create storage volumes before having at least one storage pool.

There is no new prerequisite, just the same one we have discussed in previous parts. If something new I will mention it. So, letโ€™s dive on.

Stage One: Creating Storage Pools in KVM

1. Firstly, letโ€™s display the available pools in our environment by the way we did it before from Details section after right clicking on (localhost) in the main window. This window will appear

๐Ÿ‘ Check Available KVM Pools
Check Available KVM Pools

As a default, there is one storage pool which called โ€œDefaultโ€ uses the rootfs partition to store vmโ€™s volumes under /var/lib/libvirt/images path.

In many cases, its not recommended to use this pool, just to make this free space for your system. At any way letโ€™s create our first storage pool by clicking on โ€˜+โ€˜ button from the same window.

๐Ÿ‘ Create KVM Storage Pool
Create KVM Storage Pool

Next, you may provide the name of your new storage pool and select the type of the storage which will be used to deploy the storage pools. KVM supports nine types:

    1. -dir โ€“ Uses Filesystem Directory to store storage volumes.
    2. -disk โ€“ Uses Physical Hard Disks to store storage volumes.
    3. -fs โ€“ Uses Pre-Formatted Partitions to store storage volumes.
    4. -netfs โ€“ Uses Network-shared storage like NFS to store storage volumes.
    5. -gluster โ€“ Depends on Gluster filesystems storage.
    6. -iscsi โ€“ Uses Network-shared ISCSI storage to store storage volumes.
    7. -scsi โ€“ Uses local SCSI storage to store storage volumes.
    8. -lvm โ€“ Depends on LVM Volume groups to store storage volumes.
    9. -mpath โ€“

At the moment, multipathing Volume creation is not supported.

You may be familiar with a lot of them, but we will discuss one or two of them for this tutorial. Lets start with the popular one, (dir) type.

(Dir) type is very popular used as it doesnโ€™t require many modification in current storage schema you have.

๐Ÿ‘ Name KVM Storage Pool
Name Storage Pool

3. There is no restriction where the storage pool will be created, but it is very recommended to create โ€˜SPool1โ€˜ directory on separate partition. One important thing also is to give the right permissions and ownership for this directory.

I will use /dev/sda3 as my partition, you may have a different one. Make sure you have mounted it properly.

# mount -t ext4 /dev/sda3 /mnt/personal-data/

4. After mounting the partition under โ€˜/mnt/personal-data/โ€˜ directory, then provide the path of mount point to that storage directory (i.e. /mnt/personal-data/SPool1).

๐Ÿ‘ KVM Storage Pool Location
Storage Pool Location

5. After finishing, you will find new storage pool โ€œSPool1โ€ appeared in the list.

๐Ÿ‘ Add KVM Storage Pool
New Storage Pool

Before going to the stage two to create volumes, Letโ€™s discuss another type of our Storage Pool called fs.

The (FS) type is depends on Preformatted partitions and it is useful for whom want to specify complete partition for virtual machine disks/storage.

6. We will create another storage pool using per-formatted partition that is the ((fs) Pre-Formatted Block Device) type. You need to prepare another new partition with desired file system.

You could use โ€œfdiskโ€ or โ€œpartedโ€ to create new partition and use โ€œmkfsโ€ for formatting with new file-system. For this section, (sda6) will be our new partition.

# mkfs.ext4 /dev/sda6

Also create a new directory (i.e. SPool2), it acts as a mount point for the selected partition.

7. After selecting (fs) type from the drop-menu, next provide the name of the new pool as shown

๐Ÿ‘ Add Second Storage Pool to KVM
Add Second Storage Pool to KVM

8. In the next window, you need to provide the path of your partition โ€˜/dev/sda6โ€˜ in our case โ€“ in the โ€œSource Pathโ€ field and the path of the directory which acts as a mount point /mnt/personal-data/SPool2 in the โ€œTarget Pathโ€ field.

๐Ÿ‘ Add Second Storage Path
Add Second Storage Path

9. Finally, there is a third storage pool added in the main storage list.

๐Ÿ‘ Second Storage Details
Second Storage Details

So, we will discuss deploying another storage types in our next part using CLI tools, for now letโ€™s move to create volumes.

Stage Two: Create Storage Volumes

As we discussed before, you could consider the storage volumes as a virtual disks for virtual machines. We also still have many formats for this volumes.

In general, this formats allow you to use your volumes with QEMU, VMware, Oracle VirtualBox and Hyper-V.

10. Select the storage pool which you want to storage volume be part of โ€˜New Volumeโ€˜. Press on โ€˜New Volumeโ€™ button to start.

11. Next, provide the name of the new volume and select the format of it. Donโ€™t forget to set proper size also.

๐Ÿ‘ Create New Volumes in KVM
Create New Volumes in KVM

12. Now your volume is ready to attached with virtual machines

๐Ÿ‘ Add Volume to KVM Virtual Machine
Add Volume to KVM Virtual Machine

Conclusion

Now youโ€™ve learned the difference between Storage Pools and Volumes and how to create and manage them under KVM environment using virt-manager GUI tool. Also we discussed the types of Pools and the importance of volumeโ€™s formats. Itโ€™s your turn to make your hands more dirty.

Reference Links

KVM HomePage
KVM Documentation

If this article helped, share it with someone on your team.
TecMint Weekly Newsletter
Get the Learn Linux 7 Days Crash Course free when you join 34,000+ Linux professionals reading every Thursday.
Check your email for a magic link to get started.
Something went wrong. Please try again.
โ˜•
TecMint has been free for 14 years. Help keep it that way.
Google AI Overviews and tools like ChatGPT have cut into search traffic for independent tech sites like TecMint. Running this site costs over $2,000 every month for hosting, infrastructure, and paying authors to keep the content accurate and tested.

If this article helped you solve a problem, consider buying a coffee. It helps keep TecMint free, supports the authors, and keeps the project going.
โ˜• Buy Me a Coffee
Mohammad Dosoukey
Mohammad is Linux system administrator at his university in Egypt . He is a person who fond of Virtualization, Cloud and System administration. He is also RHCE and VCP5-DCV .

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

4 Comments

Leave a Reply
  1. The iscsi direct target is not working in centos 8 KVM using cockpit, can anyone help on this?

    Reply
  2. I need to add 1 extra virtual HDD, the first HDD I installed the CentOS. I need it for testing fdisk, how can I add in VM?

    Reply
  3. When I create a dir type storage pool, it spits out the following error.

    Error creating pool: Could not build storage pool: failed to create directory โ€˜/media/matrix/sdb9/poolโ€™: File exists

    The target path of the pool is /media/matrix/sdb9/pool/. No matter what directory I choose as the target path, it always shows this error.

    Any idea?

    Reply
  4. Hi, In Stage 1, Step 3 you say that โ€œOne important thing also is to give the right permissions and ownership for this directory.โ€ What exactly are the permissions I need to apply to the directory? When I choose the directory for the pool, VMM changes the ownership to root.

    Iโ€™m trying to create the storage pool on an additional drive with partition type Linux LVM, formatted as EXT4 filesystem. I get to the step where I use VMM to create a new pool in a directory in that drive. I then created a volume in qcow2 format in that pool. When I try to create my virtual machine, and select this image, I get an error that reads: โ€œThe emulator may not have search permissions for the path โ€˜/media/it/BAY2/Spool1/NetSUS.imgโ€™.โ€

    It asks if I want to correct this now? and I choose โ€œYes.โ€ I then get the following error: โ€œErrors were encountered changing permissions for the following directories: /media/it : [Errno 1] Operation not permitted: โ€˜/media/it'โ€

    How do I fix this?

    Meanwhile, Iโ€™ll try to create this VM in the default Pool.

    Reply

Got Something to Say? Join the Discussion... Cancel reply

Free Course
Get a free Linux course before you go.
Subscribe to TecMint Weekly and get the Learn Linux 7 Days Crash Course free. Read by 34,000+ Linux professionals every Thursday.
Check your email for a magic link to get started.