Sysadmin

LVM Snapshot: Safe Rollback for Critical Updates

LVM Snapshot: Safe Rollback for Critical Updates

LVM snapshots offer a fast and reliable method to create instant recovery points of Logical Volumes (LV) on Linux systems, enabling safe and quick rollbacks in case of issues during critical updates or operating system modifications.

LVM SNAPSHOT COMMAND SUMMARY TABLE

LVM Command Description Example
:—————————— :———————————————————————— :———————————————————————–
vgs Displays available Volume Groups (VG). vgs
lvs Displays Logical Volumes (LV) within VGs. lvs
lvcreate -L [SIZE] -s -n [SNAP_NAME] [SOURCE_LV] Creates a snapshot of an existing LV. lvcreate -L 10G -s -n my_snapshot /dev/vg_data/lv_root
mount /dev/[VG]/[SNAP_NAME] [MOUNT_POINT] Mounts the snapshot for access. mount /dev/vg_data/my_snapshot /mnt/snap_test
umount [MOUNT_POINT] Unmounts the snapshot. umount /mnt/snap_test
lvconvert --merge [SNAP_LV] Rolls back the original Logical Volume to the snapshot’s state. lvconvert --merge /dev/vg_data/my_snapshot
lvremove /dev/[VG]/[SNAP_NAME] Removes the snapshot. lvremove /dev/vg_data/my_snapshot

Intro

Every sysadmin has felt that surge of anxiety before a critical update on a production server. A new kernel, a database upgrade, or a security patch can quickly turn into a nightmare with prolonged downtime if something goes wrong. In an enterprise environment with hundreds of VMs, a single error can propagate, blocking essential services. LVM (Logical Volume Manager) provides an elegant solution to this problem: snapshots. This feature allows you to create an instantaneous image of your Logical Volume, ensuring a reliable recovery point in case of failure. I implemented this strategy in an environment with over 300 VMs and 2,000 workstations, reducing recovery times from hours to mere minutes and transforming updates from high-risk operations into manageable, secure routines.

Tested on: Ubuntu 24.04 LTS · LVM2 2.03.17 · July 2026

Prerequisites / Test Environment

To follow this guide, you need a Linux system (such as Ubuntu 24.04 LTS) with LVM configured. This means having a Volume Group (VG) and at least one Logical Volume (LV) to operate on. If you don’t have LVM configured, you can do so by following the official LVM documentation LVM HOWTO.

# Verify LVM presence
sudo vgdisplay
sudo lvdisplay

Ensure you have free space in your Volume Group to accommodate the snapshot. The space required for the snapshot depends on the amount of data that will be modified on the original Logical Volume while the snapshot is active. A good starting point is to allocate a percentage of the original LV’s space, but for significant updates, more might be needed.

1. Verify Current Logical Volume Status

Before creating a snapshot, it’s crucial to know the current configuration of your Volume Groups and Logical Volumes. Use the vgs and lvs commands to display this information.

# Display Volume Groups
sudo vgs

# Display Logical Volumes
sudo lvs

The output will show you the Volume Group name (e.g., vg_data), the Logical Volume (e.g., lv_root), its size, and the free space available in the VG. This information is crucial for the next step.

2. Creating the LVM Snapshot

Creating a snapshot is the most critical operation and must be performed immediately before the update. The snapshot is a ‘copy-on-write’ image of your Logical Volume: it doesn’t immediately copy all data, but only the changes that occur after its creation. This makes the operation almost instantaneous.

To create a snapshot, we will use the lvcreate command with the options -L (snapshot size), -s (specifies it’s a snapshot), and -n (snapshot name). You will need to specify the full path to the source Logical Volume.

# Example: Create a 10GB snapshot named 'my_snapshot' of the Logical Volume 'lv_root' in the Volume Group 'vg_data'
sudo lvcreate -L 10G -s -n my_snapshot /dev/vg_data/lv_root

Replace 10G with the desired size, my_snapshot with a descriptive name, and /dev/vg_data/lv_root with the path to your Logical Volume. Once created, you can verify its presence with sudo lvs.

Read also: Linux: Free Up Disk Space with 12 Commands (SysAdmin Guide 2026)

3. Performing the Critical Update

Now that you have a secure recovery point, you can proceed with the update. This might include kernel updates, installing security patches, or upgrading a critical application. For example, for a full system update on Ubuntu:

sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade -y

After the update, it’s good practice to reboot the system to ensure all changes are applied correctly, especially if the kernel was updated.

sudo reboot

Monitor the system carefully during and after the reboot for any errors or abnormal behavior. If the system boots correctly and services function as expected, the snapshot can be removed. If the update causes problems, proceed with the rollback.

4. Rolling Back from LVM Snapshot (If Necessary)

If the update caused problems (e.g., the system won’t boot, critical services fail to start, unexpected errors), you can restore the Logical Volume to its state before the snapshot. This operation is called “merge” and restores the original LV to the snapshot’s state, undoing all changes made after the snapshot’s creation.

Important: Before performing the merge, the original Logical Volume (in our example lv_root) must not be mounted. If it’s the root LV, you will need to boot the system from a live CD/USB or enter rescue mode to unmount it.

# Boot from Live CD/USB and unmount the original Logical Volume (e.g., /dev/vg_data/lv_root)
# If the root LV is mounted, you cannot merge directly
# For a non-root LV, ensure it is unmounted:
sudo umount /mnt/my_data_partition # Example for a data LV

# Merge the snapshot Logical Volume into the original Logical Volume
sudo lvconvert --merge /dev/vg_data/my_snapshot

The lvconvert --merge command will restore your system to the exact state it was in at the time of snapshot creation. Once the merge is complete, the snapshot will be automatically removed. Reboot the system to verify that everything has returned to normal.

Read also: Linux Cron Jobs: A Complete Guide from Syntax to Debugging

5. Removing the Snapshot (If Update is Successful)

If the update was successful and the system is functioning correctly, the snapshot is no longer needed and should be removed to free up space. Remember, a snapshot occupies space in the Volume Group, and if not monitored, it can exhaust available space, causing issues for the original Logical Volume.

# Remove the snapshot
sudo lvremove /dev/vg_data/my_snapshot

Confirm the removal when prompted. This will free up the space previously allocated for the snapshot.

Read also: Passwordless SSH Linux: Configure Keys in 5 Minutes (2026)

Common Errors and Troubleshooting

  • Insufficient space in Volume Group: If there isn’t enough space in the VG to create the snapshot, lvcreate will fail. Ensure you have planned the snapshot size well. You can extend the VG by adding new Physical Volumes (PV) or resize other LVs to free up space. Read also: LVM on Linux: Advanced Logical Volume Management
  • Snapshot full: If the original Logical Volume undergoes too many changes and the snapshot runs out of allocated space, the snapshot becomes unusable (invalidated). Monitor snapshot usage with lvs and, if necessary, extend it with lvextend --size +[SIZE] /dev/vg_name/my_snapshot.
  • Source LV mounted during merge: The lvconvert --merge command will fail if the original Logical Volume is mounted. For root LVs, it is essential to reboot from a live or rescue environment. For data LVs, simply unmount it before the merge.
  • Snapshot name already exists: Ensure you use unique names for your snapshots; otherwise, lvcreate will error out.

FAQ — Frequently Asked Questions

How much space should I allocate for a snapshot?

It depends on the amount of data expected to change on the original Logical Volume while the snapshot is active. For a standard system update, a percentage of the original LV’s space is often sufficient. For more extensive changes or prolonged periods, more might be needed. Monitor usage with lvs.

Can I create snapshots of snapshots?

No, LVM does not support creating snapshots of snapshots. You can only create a snapshot of a non-snapshot Logical Volume. If you need multiple recovery points, create separate snapshots from the original LV or perform a merge and then create a new snapshot.

Do LVM snapshots affect system performance?

Yes, LVM snapshots can have a minimal impact on performance, especially if the original Logical Volume undergoes many write operations. This is because every write to the original LV must be copied to the snapshot before the original block is modified (copy-on-write). The impact is generally negligible for typical workloads but can become more noticeable with intensive I/O.

Is it possible to extend the size of a snapshot after its creation?

Yes, you can extend the size of a snapshot using lvextend. This is useful if you notice the snapshot filling up too quickly due to many writes on the original Logical Volume, preventing it from becoming invalid.

Conclusions with Operational Takeaways

Using LVM snapshots is an essential practice for any sysadmin managing Linux production servers. It transforms critical updates from high-risk operations into controlled and reversible processes. Preparation is key: verify LVM configuration, correctly allocate space for the snapshot, and know the commands for rollback. By adopting this procedure, you will not only reduce downtime in case of issues but also increase your confidence and the overall stability of your infrastructure. Never leave a critical update to chance; an LVM snapshot is your safety net.

Sources

Updated: July 2026

Share this article:

Written by

Rosario Giordano

Rosario Giordano is a system administrator and IT consultant specializing in cybersecurity and cloud, with over 20 years of experience managing enterprise Linux infrastructures. His areas of expertise include SSH hardening, Kubernetes platforms, PostgreSQL databases, VMware/ Proxmox virtualization, and compliance with NIS2 and ISO 27001 security frameworks