Skip to content
ProHomeLab
RU

Proxmox

How to Merge local-lvm and local into a Single Storage in Proxmox

Stilicho2011Updated 3 min read69 views

Also available in: RU

Part 10 of 10 in the series Proxmox
  1. Setting Up SSL Certificates in Proxmox with the Built-in ACME
  2. Setting Up Templates and Linked Clones in Proxmox VE
  3. Installing and Configuring a Cloud-Init Image in Proxmox
  4. Upgrading from Proxmox VE 8 to Proxmox VE 9 - A Step-by-Step Guide
  5. Proxmox SDN Guide - VXLAN, VLAN, and Virtual Networks Setup
  6. How to Set Up a Firewall in Proxmox VE - Step-by-Step Guide
  7. Why I Don't Need Ceph Storage in Proxmox for My Home Server
  8. Proxmox Cluster - Setup, QDevice, and Mixed Hardware in Nodes
  9. Storage for HA in a Proxmox Cluster
  10. How to Merge local-lvm and local into a Single Storage in Proxmox
Contents

Why merge local-lvm and local?

After installing Proxmox VE, two local storages are created by default:

  • local - the /var/lib/vz folder, intended for ISO images, templates, and backups.

local storage

  • local-lvm - an LVM pool where the disks of virtual machines and containers are stored.

local-lvm storage

At first glance this is convenient, but this separation has downsides:

  • The size of local-lvm is fixed, and it's hard to free up space for ISOs or backups.
  • Files in local-lvm are not directly visible in the file system.
  • Expanding or migrating the pool is problematic.

That's why many administrators prefer to merge local-lvm and local into a single file-based storage, where everything is stored as regular files.


Available approaches

There are two approaches:

  1. Remove the LVM pool and use all the space for ext4 (or ZFS).
  2. Migrate the disks from local-lvm to local, then remove the LVM pool.

We'll go with the first option, since it's simpler if you're installing Proxmox from scratch - it's safer, and you won't lose data.


Step 1. Remove the LVM storage from the Storage list in the Datacenter section of our Proxmox

Go to the Datacenter menu, select Storage, select the local-lvm storage we don't need, and click the remove button.

Removing local-lvm

As a result, we're left with only the local storage. However, the problem is that the "supposedly" freed disk space isn't actually freed yet.

Step 2. Freeing up space

Go into the shell of our node and start the magic session.

First, let's actually remove the logical volume with the command

yaml
lvremove /dev/pve/data

Removing local-lvm

and confirm the action.

Step 3. Increasing the size of the logical volume

Now let's use the following command to increase the size of the logical volume (LVM) so it takes up all the available unallocated space on the physical volume (PV).

yaml
lvresize -l +100%FREE /dev/pve/root

increasing lvm

What does the command above mean, you ask me, my curious little friend. Good question.

What happens step by step

  • lvresize is a utility for resizing a Logical Volume in LVM.
  • -l +100%FREE is a flag that says: "Add all the remaining free space from the volume group (VG) to this logical volume."

That is, if our pve group has, say, 50 GB of unused space left, this command will add all of it to /dev/pve/root.

/dev/pve/root is the path to the logical volume where the main file system is installed (usually /).

And finally, today's last command

Step 4. Expanding our file system

yaml
resize2fs /dev/mapper/pve-root

expands our ext4 file system inside the specified partition.

expanding local

Now let's check what we've done.

test test2

As you can see, now all disk space is used within a single local storage.

But there's one more, final and mandatory, touch needed.

Step 5. The final touch

We need to tell the system that the local storage should now be used for all data types, including the type that was previously only used by local-lvm.

Storage

Post scriptum

If you enjoyed this article or found this knowledge useful, consider supporting the channel on Boosty via the link in the contacts.