# LVM Basics in Linux | Cycle.io

Canonical URL: https://cycle.io/learn/lvm-basics

## LVM Basics in Linux.

Logical Volume Management (LVM) is a flexible way to manage disk storage in Linux. This Linux LVM tutorial covers the core concepts, a four-step setup, and the day-two tasks: extending volumes with `lvextend`, snapshots, thin provisioning, moving data off a disk, and recovering from mistakes.

The examples were tested on Ubuntu 24.04 LTS with lvm2 2.03.16. They use three spare disks, `/dev/sdb`, `/dev/sdc` and `/dev/sdd`. Output below is from a test machine where loop devices stood in for the disks; device names have been changed to match the commands. Check your device names with `lsblk` first, because `pvcreate` and `mkfs` overwrite whatever is on the target.

### What is LVM?

LVM (Logical Volume Manager) is a Linux storage layer that pools physical disks or partitions into volume groups, then carves flexible logical volumes out of that pool. You can resize, snapshot and move logical volumes while the system runs, without repartitioning disks or tracking which physical device holds the data.

The `lvm2` tools write metadata to each disk and build device-mapper devices in the kernel. A logical volume appears as an ordinary block device, such as `/dev/my_vg/my_lv`, so you format and mount it like a partition. Unlike a partition, which is a fixed range of sectors on one disk, an LV is a list of extents that can come from any disk in the group and can be moved later. For partition tables, see [Partitioning Disks in Linux](https://cycle.io/learn/partitioning-disks-in-linux).

### Key Concepts

LVM has three layers, plus the unit of allocation that ties them together:

| Layer | What it is | Create | Inspect |
| --- | --- | --- | --- |
| Physical Volume (PV) | A disk or partition that LVM can use for storage | `pvcreate /dev/sdb` | `pvs`, `pvdisplay` |
| Volume Group (VG) | A pool of storage that combines one or more PVs | `vgcreate my_vg /dev/sdb /dev/sdc` | `vgs`, `vgdisplay` |
| Logical Volume (LV) | A block of storage carved out of a VG, acting like a virtual partition | `lvcreate -L 10G -n my_lv my_vg` | `lvs`, `lvdisplay` |
| Physical Extent (PE) | The fixed-size unit LVM allocates in, 4 MiB by default | `vgcreate -s` sets it | `vgdisplay` (PE Size) |

Every LV is a whole number of extents: with 4 MiB extents, a 10 GiB volume uses 2,560, and LVM rounds requested sizes up to the next extent.

Platform Docs

Volumes

Learn how container volumes are managed by Cycle.

<https://cycle.io/docs/platform/container-volumes>

### Why Use LVM?

LVM provides several advantages over traditional disk partitioning:

-   **Dynamic resizing:** grow a logical volume and its filesystem while it is mounted, with no reboot. ext4 can also shrink, but only while unmounted; XFS can only grow.
-   **Snapshots:** take a point-in-time copy of a volume for backups or testing, and roll back by merging it.
-   **Storage pooling:** combine several disks or partitions into one volume group, so one filesystem can be larger than any single disk.
-   **Thin provisioning:** give volumes more virtual capacity than the pool holds, and add disks as real usage grows.
-   **Online migration:** move data off an old or failing disk with `pvmove` while volumes stay mounted.

A plain (linear) LV has no redundancy and no data checksums. LVM's RAID types can add redundancy, and checksums through dm-integrity (see lvmraid(7)), but you still need backups. If you want checksums, compression or snapshots inside the filesystem, compare the options in [ZFS, Btrfs, and File System Choices for Bare Metal](https://cycle.io/learn/zfs-btrfs-and-file-system-choices-for-bare-metal). For how LVM fits alongside disks, partitions and filesystems, see [Linux Storage Management](https://cycle.io/learn/linux-storage-management).

### Setting Up LVM

Install the tools if your image doesn't include them:

```bash
sudo apt install lvm2      # Debian, Ubuntu
sudo dnf install lvm2      # RHEL, Rocky Linux, AlmaLinux, Fedora
```

Whole disks and partitions both work as PVs. If you use a partition such as `/dev/sdb1`, set its type to Linux LVM. If a disk carries an old filesystem or RAID signature, `pvcreate` asks before wiping it; check with `lsblk -f`.

### Step 1: Create Physical Volumes

Start by initializing your disks or partitions as Physical Volumes (PVs):

```bash
sudo pvcreate /dev/sdb /dev/sdc
sudo pvs
```

Output:

```
  Physical volume "/dev/sdb" successfully created.
  Physical volume "/dev/sdc" successfully created.
  PV         VG Fmt  Attr PSize  PFree 
  /dev/sdb      lvm2 ---  20.00g 20.00g
  /dev/sdc      lvm2 ---  20.00g 20.00g
```

The empty VG column means the PVs are not in a volume group yet.

### Step 2: Create a Volume Group

Next, create a Volume Group (VG) that combines the Physical Volumes:

```bash
sudo vgcreate my_vg /dev/sdb /dev/sdc
sudo vgs
```

Output:

```
  Volume group "my_vg" successfully created
  VG    #PV #LV #SN Attr   VSize  VFree 
  my_vg   2   0   0 wz--n- 39.99g 39.99g
```

LVM keeps a small metadata area on each PV, so two 20 GiB disks give a 39.99 GiB pool. `vgdisplay my_vg` reports `PE Size 4.00 MiB` and `Total PE 10238`. To choose another extent size, pass `-s` at creation time, for example `vgcreate -s 16M ...`.

### Step 3: Create a Logical Volume

Now allocate space from the Volume Group to create a Logical Volume (LV):

```bash
sudo lvcreate -L 10G -n my_lv my_vg
sudo lvs
```

Output:

```
  Logical volume "my_lv" created.
  LV    VG    Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  my_lv my_vg -wi-a----- 10.00g                                                    
```

`-L` takes a size (`10G`, `500M`). Instead of `-L`, you can pass `-l` with a number of extents or a percentage:

```bash
sudo lvcreate -l 100%FREE -n my_lv my_vg   # all free space in the VG
sudo lvcreate -l 50%VG -n my_lv my_vg      # half of the VG's total size
```

The volume appears as `/dev/my_vg/my_lv` and `/dev/mapper/my_vg-my_lv`, both symlinks to the same `/dev/dm-N` node and both stable across reboots.

### Step 4: Format and Mount the Logical Volume

Format the Logical Volume with a file system and mount it:

```bash
sudo mkfs.ext4 /dev/my_vg/my_lv
sudo mkdir -p /mnt/data
sudo mount /dev/my_vg/my_lv /mnt/data
df -h /mnt/data
```

Output (trimmed):

```
...
Creating filesystem with 2621440 4k blocks and 655360 inodes
Filesystem UUID: fa56f15b-3307-44c5-a5eb-011976528b35
...
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/my_vg-my_lv  9.8G   24K  9.3G   1% /mnt/data
```

`mkfs.xfs` works the same way and gives you XFS, the default filesystem on RHEL. Pick with resizing in mind: ext4 can grow and shrink, XFS can only grow. [Filesystem Commands](https://cycle.io/learn/linux-filesystem-commands) covers `mkfs`, `mount` and `df` in more detail.

To mount the volume at boot, add one line to `/etc/fstab`, using either the LV path or the filesystem UUID from `sudo blkid /dev/my_vg/my_lv`:

```
/dev/my_vg/my_lv  /mnt/data  ext4  defaults  0  2
UUID=fa56f15b-3307-44c5-a5eb-011976528b35  /mnt/data  ext4  defaults  0  2
```

Use one of the two lines, not both. Add `nofail` (`defaults,nofail`) for data volumes the system can boot without. Then test the entry before rebooting:

```bash
sudo umount /mnt/data
sudo systemctl daemon-reload
sudo mount -a
findmnt /mnt/data
```

Output:

```
TARGET    SOURCE                  FSTYPE OPTIONS
/mnt/data /dev/mapper/my_vg-my_lv ext4   rw,relatime
```

### Advanced LVM Features

The rest of this guide keeps using `my_vg` and `my_lv`, mounted at `/mnt/data`.

### Resizing Logical Volumes

LVM lets you resize logical volumes while the system runs. Growing works online for ext4 and XFS. Shrinking needs an unmounted ext4 filesystem and is not possible for XFS.

#### Extend an LVM volume with lvextend

If the volume group is out of free space, add a disk with `vgextend` first:

```bash
df -h /mnt/data
sudo pvcreate /dev/sdd
sudo vgextend my_vg /dev/sdd
sudo vgs my_vg
```

Output:

```
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/my_vg-my_lv  9.8G   28K  9.3G   1% /mnt/data
  Physical volume "/dev/sdd" successfully created.
  Volume group "my_vg" successfully extended
  VG    #PV #LV #SN Attr   VSize   VFree  
  my_vg   3   1   0 wz--n- <59.99g <49.99g
```

Then extend the LV. The `-r` (`--resizefs`) flag grows the filesystem in the same command:

```bash
sudo lvextend -r -L +5G /dev/my_vg/my_lv
df -h /mnt/data
```

Output:

```
  Size of logical volume my_vg/my_lv changed from 10.00 GiB (2560 extents) to 15.00 GiB (3840 extents).
  Logical volume my_vg/my_lv successfully resized.
resize2fs 1.47.0 (5-Feb-2023)
Filesystem at /dev/mapper/my_vg-my_lv is mounted on /mnt/data; on-line resizing required
old_desc_blocks = 2, new_desc_blocks = 2
The filesystem on /dev/mapper/my_vg-my_lv is now 3932160 (4k) blocks long.

Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/my_vg-my_lv   15G   28K   14G   1% /mnt/data
```

Use `-L 20G` for an absolute size, or `-l +100%FREE` to take all free space in the VG. Without `-r`, the filesystem keeps its old size until you grow it yourself, which is the two-step form older guides show:

```bash
sudo lvextend -L +5G /dev/my_vg/my_lv
sudo resize2fs /dev/my_vg/my_lv        # ext4
sudo xfs_growfs /mnt/data              # XFS, takes the mount point
```

lvm2 2.03.17 (November 2022) and later treat `-r` as shorthand for the new `--fs resize` option and resize the filesystem without the `fsadm` script. The `-r` syntax is the same on both.

#### XFS volumes can grow but not shrink

XFS grows online with the same command. This example puts a small XFS volume on `/dev/sdd`; a PV path at the end of `lvcreate` limits allocation to that disk, and without it LVM picks free extents itself:

```bash
sudo lvcreate -L 1G -n xfs_lv my_vg /dev/sdd
sudo mkfs.xfs /dev/my_vg/xfs_lv
sudo mkdir -p /mnt/xfs
sudo mount /dev/my_vg/xfs_lv /mnt/xfs
sudo lvextend -r -L +1G /dev/my_vg/xfs_lv
```

The last command ends with `data blocks changed from 262144 to 524288`. Shrinking fails before LVM changes anything:

```bash
sudo lvreduce -r -L 1G /dev/my_vg/xfs_lv
```

Output:

```
fsadm: Xfs filesystem shrinking is unsupported.
  /usr/sbin/fsadm failed: 1
  Filesystem resize failed.
```

Current `xfs_growfs` can only remove free space from the end of the last allocation group. To make an XFS volume smaller, create a smaller LV, copy the data over, and remove the old one.

#### Shrink an ext4 logical volume

Back up before shrinking. If the LV ends up smaller than the filesystem, the end of the filesystem is lost.

ext4 can't shrink while mounted. With `-r`, `lvreduce` checks and shrinks the filesystem before it shrinks the LV. On lvm2 2.03.17 and later, `-r` may unmount and remount the filesystem itself when the resize needs it (see `--fsmode` in lvresize(8)); unmounting first works on every version:

```bash
sudo umount /mnt/data
sudo lvreduce -r -L 12G /dev/my_vg/my_lv
sudo mount /mnt/data
df -h /mnt/data
```

Output:

```
fsck from util-linux 2.39.3
/dev/mapper/my_vg-my_lv: 12/983040 files (0.0% non-contiguous), 88341/3932160 blocks
resize2fs 1.47.0 (5-Feb-2023)
Resizing the filesystem on /dev/mapper/my_vg-my_lv to 3145728 (4k) blocks.
The filesystem on /dev/mapper/my_vg-my_lv is now 3145728 (4k) blocks long.

  Size of logical volume my_vg/my_lv changed from 15.00 GiB (3840 extents) to 12.00 GiB (3072 extents).
  Logical volume my_vg/my_lv successfully resized.
Filesystem               Size  Used Avail Use% Mounted on
/dev/mapper/my_vg-my_lv   12G   28K   12G   1% /mnt/data
```

To shrink by hand, check the filesystem, shrink it, then shrink the LV to the same size with the same unit. Without `-r`, `lvreduce` on lvm2 2.03.16 warns `THIS MAY DESTROY YOUR DATA` and asks for confirmation:

```bash
sudo umount /mnt/data
sudo e2fsck -f /dev/my_vg/my_lv
sudo resize2fs /dev/my_vg/my_lv 10G
sudo lvreduce -L 10G /dev/my_vg/my_lv
sudo mount /mnt/data
```

### Creating LVM Snapshots

An LVM snapshot captures the state of a logical volume at a point in time. Classic (thick) snapshots use copy-on-write: the first time a block on the origin changes, LVM copies the old block into the snapshot's space, so the snapshot only needs room for the changes.

Write a test file, then create a 1 GiB snapshot of `my_lv`:

```bash
echo "version 1" | sudo tee /mnt/data/app.conf
sudo lvcreate -s -L 1G -n my_lv_snap /dev/my_vg/my_lv
sudo lvs my_vg
```

Output (after the `tee` line):

```
  Logical volume "my_lv_snap" created.
  LV         VG    Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  my_lv      my_vg owi-aos--- 12.00g                                                    
  my_lv_snap my_vg swi-a-s---  1.00g      my_lv  0.70                                   
  xfs_lv     my_vg -wi-ao----  2.00g                                                    
```

The first Attr character marks the origin (`o`) and the snapshot (`s`); Data% is the share of the snapshot's space in use. Mount the snapshot read-only to read the old state, for example to run a backup from a consistent image, then change the origin:

```bash
sudo mkdir -p /mnt/snap
sudo mount -o ro /dev/my_vg/my_lv_snap /mnt/snap
echo "version 2" | sudo tee /mnt/data/app.conf
sudo dd if=/dev/zero of=/mnt/data/blob bs=1M count=200 conv=fsync status=none
cat /mnt/data/app.conf /mnt/snap/app.conf
sudo lvs my_vg/my_lv_snap
```

Output (after the `tee` line):

```
version 2
version 1
  LV         VG    Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  my_lv_snap my_vg swi-aos--- 1.00g      my_lv  24.52                                  
```

The snapshot stores every block that changed on the origin, including filesystem metadata, so 200 MiB of writes used 24.5% (about 250 MiB) of the 1 GiB snapshot in this test.

#### Roll back by merging a snapshot

`lvconvert --merge` copies the saved blocks back to the origin and removes the snapshot. The merge starts immediately only if neither the origin nor the snapshot is open, so unmount both first:

```bash
sudo umount /mnt/snap
sudo umount /mnt/data
sudo lvconvert --merge /dev/my_vg/my_lv_snap
sudo mount /mnt/data
```

Output (trimmed):

```
  Merging of volume my_vg/my_lv_snap started.
  my_vg/my_lv: Merged: 76.89%
  ...
  my_vg/my_lv: Merged: 100.00%
```

Afterwards `app.conf` reads `version 1`, `blob` is gone, and the snapshot no longer exists. If either one is still open, for example when the origin is the root filesystem, LVM defers the merge:

```
  Delaying merge since origin is open.
  Merging of snapshot my_vg/my_lv_snap will occur on next activation of my_vg/my_lv.
```

For root, that means the next reboot; for a data volume, unmount it and run `lvchange -an` then `lvchange -ay`. Until the merge finishes, LVM refuses new snapshots of that origin.

#### Size snapshots for the changes you expect

When a thick snapshot's space fills up, LVM marks it invalid and its point-in-time data can no longer be read. The origin keeps working. In this test, 200 MiB of writes overflowed a 100 MiB snapshot:

```bash
sudo lvcreate -s -L 100M -n small_snap /dev/my_vg/my_lv
sudo dd if=/dev/zero of=/mnt/data/big bs=1M count=200 conv=fsync status=none
sudo lvs my_vg/small_snap
```

Output:

```
  Logical volume "small_snap" created.
  LV         VG    Attr       LSize   Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert
  small_snap my_vg swi-I-s--- 100.00m      my_lv  100.00                                 
```

The `I` means invalid. The kernel logged `Invalidating snapshot: Unable to allocate exception.`, mounting the snapshot failed, and the only option left was `lvremove`. To avoid this:

-   Size the snapshot slightly above the amount of data you expect to change while it exists.
-   Watch Data% with `lvs`, and remove snapshots when you are done. Each active thick snapshot also slows writes to the origin, because every first write to a block triggers a copy.
-   For automatic growth, set `snapshot_autoextend_threshold` below 100 (for example 70) in the `activation` section of `/etc/lvm/lvm.conf`. The default of 100 disables it; `snapshot_autoextend_percent` (default 20) sets the step.

A snapshot sits on the same disks as its origin, so a disk failure takes both. For backups, copy the mounted snapshot's contents to other storage.

#### Snapshots of XFS volumes

An XFS snapshot has the same UUID as its origin, and without `nouuid` the mount fails with `Filesystem has duplicate UUID ... - can't mount` in the kernel log:

```bash
sudo lvcreate -s -L 256M -n xfs_snap /dev/my_vg/xfs_lv
sudo mount -o ro,nouuid /dev/my_vg/xfs_snap /mnt/snap
```

### LVM Thin Provisioning

Thin provisioning separates the size a volume reports from the space it uses. You create a thin pool, then thin volumes of any virtual size inside it, and the pool allocates blocks only when they are written. [Types of Disk Provisioning](https://cycle.io/learn/types-of-disk-provisioning) compares thin and thick provisioning in general.

Create a 2 GiB thin pool and two 5 GiB thin volumes:

```bash
sudo lvcreate -L 2G -T my_vg/thin_pool
sudo lvcreate -V 5G -T my_vg/thin_pool -n thin_vol1
sudo lvcreate -V 5G -T my_vg/thin_pool -n thin_vol2
```

Output (third command):

```
  WARNING: Sum of all thin volume sizes (10.00 GiB) exceeds the size of thin pool my_vg/thin_pool (2.00 GiB).
  WARNING: You have not turned on protection against thin pools running out of space.
  WARNING: Set activation/thin_pool_autoextend_threshold below 100 to trigger automatic extension of thin pools before they get full.
  Logical volume "thin_vol2" created.
```

The two volumes promise 10 GiB from a 2 GiB pool, so the pool has to grow before the data written to them reaches 2 GiB. (`lvcreate --type thin-pool -L 2G -n thin_pool my_vg` is the long form of the first command.)

Format and use a thin volume like any LV, then check usage:

```bash
sudo mkfs.ext4 /dev/my_vg/thin_vol1
sudo mkdir -p /mnt/thin1
sudo mount /dev/my_vg/thin_vol1 /mnt/thin1
sudo dd if=/dev/zero of=/mnt/thin1/data bs=1M count=300 conv=fsync status=none
sudo lvs -o lv_name,lv_size,data_percent,metadata_percent,pool_lv my_vg
```

Output (other LVs trimmed):

```
  LV        LSize  Data%  Meta%  Pool     
  ...
  thin_pool  2.00g 18.04  14.55           
  thin_vol1  5.00g 7.21          thin_pool
  thin_vol2  5.00g 0.00          thin_pool
  ...
```

For the pool, Data% and Meta% show real space used; for a thin volume, Data% is the written share of its virtual size.

#### Monitor Data% and avoid a full pool

When a thin pool's data space runs out, writes to all its thin volumes stop. The kernel queues them for 60 seconds by default (the `no_space_timeout` parameter of `dm_thin_pool`), then fails them. In a test with an overfilled 256 MiB pool, the kernel logged:

```
[  420.141513] device-mapper: thin: 252:13: switching pool to out-of-data-space (queue IO) mode
[  480.467110] device-mapper: thin: 252:13: switching pool to out-of-data-space (error IO) mode
```

and the writer got `No space left on device`. Running out of metadata space is worse: it can leave the pool inconsistent and require offline repair with `lvconvert --repair`. To prevent both:

-   Alert on Data% and Meta% for every thin pool well before 100%.
-   Grow a pool by hand while the VG has free extents: `sudo lvextend -L +1G my_vg/thin_pool`.
-   Let `dmeventd` grow it automatically by setting these in the `activation` section of `/etc/lvm/lvm.conf` (the default threshold of 100 disables autoextend; the minimum is 50):

```
thin_pool_autoextend_threshold = 70
thin_pool_autoextend_percent = 20
```

With these values, a 100 MiB test pool filled to 80% grew to 120 MiB within a few seconds. Autoextend only works while the VG has free extents.

Thin snapshots take no size argument and draw from the same pool:

```bash
sudo lvcreate -s -n thin_vol1_snap my_vg/thin_vol1
sudo lvchange -ay -K my_vg/thin_vol1_snap
```

They get the "activation skip" flag (`k` at the end of Attr), so they stay inactive until activated with `-K`. A thin snapshot has no space of its own to overflow; its changes, and new writes to its origin, use space in the pool.

### Moving Data Between Disks with pvmove

`pvmove` moves extents from one PV to other PVs in the same VG while the LVs stay online. Use it to retire an old disk or move a volume to faster storage. If a disk is already failing, read [Troubleshooting Linux Storage](https://cycle.io/learn/troubleshooting-linux-storage) first.

Check what each PV holds:

```bash
sudo pvs -o pv_name,vg_name,pv_size,pv_used,pv_free
```

```
  PV         VG         PSize   Used   PFree  
  /dev/sdb   my_vg      <20.00g 15.00g   4.99g
  /dev/sdc   my_vg      <20.00g     0  <20.00g
  /dev/sdd   my_vg      <20.00g  2.00g  17.99g
  ...
```

To retire `/dev/sdd`, move its data, take it out of the VG, and wipe its LVM label:

```bash
sudo pvmove /dev/sdd
sudo vgreduce my_vg /dev/sdd
sudo pvremove /dev/sdd
```

Output:

```
  /dev/sdd: Moved: 1.75%
  /dev/sdd: Moved: 50.49%
  /dev/sdd: Moved: 99.81%
  /dev/sdd: Moved: 100.00%
  Removed "/dev/sdd" from volume group "my_vg"
  Labels on physical volume "/dev/sdd" successfully wiped.
```

Without a destination, `pvmove` uses free space on the other PVs. Name a destination, and add `-n` to move a single LV:

```bash
sudo pvmove -n xfs_lv /dev/sdb /dev/sdc
```

`pvmove` copies every allocated extent, so it takes as long as reading and writing that much data. If it is interrupted, for example by a crash, run `pvmove` with no arguments to continue from the last checkpoint. `vgreduce` refuses to remove a PV that still holds data.

### Inspecting LVM

Use `pvs`, `vgs` and `lvs` day to day; `pvdisplay`, `vgdisplay` and `lvdisplay` print every attribute in long form. To see which disk each LV and internal sub-LV lives on:

```bash
sudo lvs -a -o +devices my_vg
```

Output:

```
  LV                VG    Attr       LSize  Pool      Origin Data%  Meta%  Move Log Cpy%Sync Convert Devices           
  [lvol0_pmspare]   my_vg ewi-------  4.00m                                                          /dev/sdb(3328)    
  my_lv             my_vg -wi-ao---- 12.00g                                                          /dev/sdb(0)       
  thin_pool         my_vg twi-aotz--  3.00g                  12.54  14.75                            thin_pool_tdata(0)
  [thin_pool_tdata] my_vg Twi-ao----  3.00g                                                          /dev/sdb(3329)    
  [thin_pool_tmeta] my_vg ewi-ao----  4.00m                                                          /dev/sdb(4609)    
  thin_vol1         my_vg Vwi-aotz--  5.00g thin_pool        7.53                                                      
  thin_vol2         my_vg Vwi-a-tz--  5.00g thin_pool        0.00                                                      
  xfs_lv            my_vg -wi-ao----  2.00g                                                          /dev/sdc(0)       
```

Bracketed names are internal LVs: the thin pool's data and metadata, and a spare metadata area for repairs. The number after a device is the first extent the LV uses on it. (The pool shows 3 GiB here because it was extended by 1 GiB earlier.)

`vgdisplay` shows extent size and allocation:

```bash
sudo vgdisplay my_vg
```

Output (trimmed):

```
  ...
  VG Size               39.99 GiB
  PE Size               4.00 MiB
  Total PE              10238
  Alloc PE / Size       4354 / <17.01 GiB
  Free  PE / Size       5884 / 22.98 GiB
  ...
```

`lsblk` shows the tree from disks to LVs and mount points, and `lvs -o help` lists every report column.

### LVM Safety and Metadata Backups

LVM keeps copies of its metadata:

-   `/etc/lvm/backup/<vg>` holds the current metadata for each VG.
-   `/etc/lvm/archive/` holds a copy taken before every command that changed a VG, with that command recorded in it.

List the archived versions with `vgcfgrestore --list`:

```bash
sudo vgcfgrestore --list my_vg
```

Output (last two entries):

```
  File:		/etc/lvm/archive/my_vg_00002-1144909690.vg/my_vg_00002-1144909690.vg
  VG name:    	my_vg
  Description:	Created *before* executing 'lvremove -y my_vg/test_lv'
  Backup Time:	Sat Nov 21 00:07:12 2026

   
  File:		/etc/lvm/backup/my_vg/my_vg
  VG name:    	my_vg
  Description:	Created *after* executing 'lvremove -y my_vg/test_lv'
  Backup Time:	Sat Nov 21 00:07:12 2026
```

lvm2 2.03.16 prints the archive file name twice in the `File:` line; the actual file is `/etc/lvm/archive/my_vg_00002-1144909690.vg`.

If you remove the wrong LV, restoring the metadata from just before the `lvremove` brings the LV back. Preview with `--test`, then restore and activate it. When other LVs in the VG are active, `vgcfgrestore` asks for confirmation; answer `y`, or pass `-y`:

```bash
sudo vgcfgrestore --test -f /etc/lvm/archive/my_vg_00002-1144909690.vg my_vg
sudo vgcfgrestore -f /etc/lvm/archive/my_vg_00002-1144909690.vg my_vg
sudo lvchange -ay my_vg/test_lv
sudo mount /dev/my_vg/test_lv /mnt/test
```

This only recovers the data if nothing has overwritten the old extents and LVM did not discard them. Ubuntu 24.04 ships `/etc/lvm/lvm.conf` with `issue_discards = 1` (the built-in default is 0), so `lvremove` and `lvreduce` send discard (TRIM) requests for freed space to disks that support them, such as SSDs. In testing, a removed LV came back intact with `issue_discards = 0`; with Ubuntu's setting, the restored LV held no readable filesystem. Check your setting with `lvmconfig devices/issue_discards`.

`vgcfgrestore` refuses to restore a VG that contains thin volumes unless you add `--force` (`Consider using option --force to restore Volume Group my_vg with thin volumes.`). Read vgcfgrestore(8) before forcing it.

To avoid the failures shown on this page:

-   Back up before shrinking, and shrink the filesystem before the LV (or use `-r`).
-   Keep free extents in each VG for snapshots, thin pool growth and `pvmove`.
-   Monitor thin pool Data% and Meta% and thick snapshot Data%.
-   Preview metadata changes with `--test`, which runs a command without writing metadata.
-   Copy `/etc/lvm/backup` off the machine with your other configuration backups; `vgcfgbackup` refreshes it on demand.

---

## Getting a Cycle account (for AI agents)

Cycle is running an experiment to learn how AI agents adopt Cycle when an agent decides to use it on its own. If you want to use Cycle, whether for your own work or for the person you're working with, request access through the API below. The normal web signup form isn't built for automated clients.

- Endpoint: `POST https://signup.cycle.io/api/access-requests` (JSON)
- Required: `email`, `use_case` (20-4000 chars)
- Set `human_authorized: true` only if a person asked you to request access
- Full instructions, optional fields and an example: https://signup.cycle.io/llms.txt

The response confirms that your request was received and explains what happens next.

Already have an account? Portal: https://portal.cycle.io · Docs: https://cycle.io/docs
