LOGO

LVM on Ubuntu: Partition Resizing & Snapshots - A Guide

March 17, 2015
LVM on Ubuntu: Partition Resizing & Snapshots - A Guide

Leveraging Logical Volume Management with Ubuntu

The Ubuntu installation process provides a straightforward option for utilizing Logical Volume Management (LVM) through a simple checkbox. This feature, when enabled, unlocks capabilities such as snapshot creation and simplified hard disk partition resizing.

Understanding LVM

LVM functions as a flexible storage solution. It shares similarities with technologies like RAID arrays and Windows Storage Spaces in certain aspects.

Although particularly advantageous in server environments, the benefits of LVM extend to desktop personal computers as well.

Key Advantages of Using LVM

  • Snapshot Creation: LVM allows you to create point-in-time copies of your volumes.
  • Flexible Resizing: Partition sizes can be adjusted more readily compared to traditional partitioning schemes.
  • Enhanced Storage Management: LVM provides a more abstract and manageable layer over physical disks.

By employing LVM during Ubuntu installation, users gain increased control and adaptability over their storage configuration.

The ease of implementation, via a single checkbox, makes this powerful feature accessible to both novice and experienced users.

Leveraging LVM with a Fresh Ubuntu Setup: A Consideration

The initial decision revolves around the desirability of implementing LVM alongside your new Ubuntu installation. While Ubuntu simplifies activation through a straightforward installer option, it remains disabled by default. As highlighted during installation, LVM facilitates dynamic partition adjustments, snapshot creation, and the consolidation of multiple physical disks into a unified logical volume.

Crucially, these operations can be performed while the system is operational. This contrasts sharply with conventional partitioning methods, which necessitate system shutdown and booting from external media for resizing or modification.

Benefits and Potential Drawbacks

For many standard Ubuntu desktop users, the underlying presence of LVM may go unnoticed. However, its capabilities become invaluable for those anticipating more sophisticated system administration tasks.

It's important to acknowledge that LVM introduces a layer of complexity. This added intricacy could potentially complicate data recovery scenarios, particularly for users less familiar with its intricacies.

Performance impact is generally negligible; LVM is deeply integrated within the Linux kernel, minimizing overhead.

how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots-1.jpg

Logical Volume Management Explained

Logical Volume Management (LVM) offers a flexible approach to disk management. It introduces an abstraction layer between the physical storage devices and the partitions recognized by the operating system.

Consider a system equipped with two 1 TB hard drives. Traditionally, these would necessitate at least two partitions, each capped at 1 TB.

LVM alters this paradigm. Upon initialization, the physical disks are treated as distinct "physical volumes." These volumes then serve as the foundation for creating "logical volumes."

For instance, the two 1 TB disks can be consolidated into a single, unified 2 TB volume. The operating system perceives this as a single entity, while LVM manages the underlying complexities.

A collection of physical and logical volumes is termed a "volume group." Most systems utilize a single volume group for streamlined management.

Benefits of LVM

This abstraction layer facilitates several key advantages. These include the ability to resize partitions dynamically, merge multiple disks into a single logical unit, and create file system snapshots without requiring downtime or unmounting.

Snapshots allow for point-in-time copies of data, useful for backups and testing.

However, combining multiple disks into one volume carries risks. Like RAID 0 configurations, failure of a single disk within the combined volume can lead to complete data loss.

Therefore, robust backup strategies are essential when employing this approach. Data redundancy is paramount to mitigate potential data loss scenarios.

  • Regular backups are crucial.
  • Consider implementing a comprehensive disaster recovery plan.
  • Evaluate the risks before combining disks.

Without adequate backups, consolidating disks can create a single point of failure, jeopardizing valuable data.

Graphical Utilities for Managing Your LVM Volumes

Related: How to Manage and Use LVM (Logical Volume Management) in Ubuntu

Typically, LVM volumes are administered using Linux command-line tools. While these commands function perfectly well on Ubuntu, a more user-friendly, graphical approach is also available. If you are a Linux user familiar with tools like GParted or similar partition managers, be aware that GParted lacks support for LVM disks.

Instead, the Disks utility, which comes pre-installed with Ubuntu, can be utilized. Also known as GNOME Disk Utility or Palimpsest, it can be launched by locating its icon in the application launcher, searching for "Disks," and pressing Enter. Unlike GParted, this utility displays your LVM partitions under the "Other Devices" section, allowing for formatting and adjustments as needed. It also functions effectively from a live CD or USB drive.

how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots-2.jpg

However, the Disks utility doesn't offer functionality for leveraging LVM’s more advanced capabilities. Options for managing volume groups, extending partitions, or creating snapshots are absent. While these tasks can be performed via the terminal, an alternative graphical solution exists. You can open the Ubuntu Software Center, search for LVM, and install the Logical Volume Management tool. Alternatively, the sudo apt-get install system-config-lvm command can be executed in a terminal window.

Once installed, the Logical Volume Management utility can be accessed through the application launcher. This graphical configuration tool was originally developed by Red Hat. Although somewhat dated in appearance, it remains the sole graphical method for these operations without resorting to command-line interfaces.

For example, to incorporate a new physical volume into your volume group, you would open the tool, select the new disk under "Uninitialized Entries," and click the "Initialize Entry" button. Subsequently, the new physical volume will appear under "Unallocated Volumes," where you can use the "Add to existing Volume Group" button to integrate it into the "ubuntu-vg" volume group, which Ubuntu creates during installation.

how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots-3.jpg

The volume group view provides a visual representation of your physical and logical volumes. In this instance, we observe two physical partitions spanning two distinct hard drives. A swap partition and a root partition are present, mirroring Ubuntu’s default partitioning scheme. The addition of a second physical partition from another drive has created a significant amount of unused space.

how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots-4.jpg

To expand a logical partition into the available physical space, select it under "Logical View," click "Edit Properties," and adjust the size to increase the partition's capacity. Shrinking the partition is also possible from this interface.

how-to-use-lvm-on-ubuntu-for-easy-partition-resizing-and-snapshots-5.jpg

Additional options within system-config-lvm enable the setup of snapshots and mirroring. These features may not be necessary for typical desktop use, but they are available through this graphical interface. Keep in mind that all these operations can also be accomplished using terminal commands.

Linux Commands

Files

tar · pv · cat · tac · chmod · grep · diff · sed · ar · man · pushd · popd · fsck · testdisk · seq · fd · pandoc · cd · $PATH · awk · join · jq · fold · uniq · journalctl · tail · stat · ls · fstab · echo · less · chgrp · chown · rev · look · strings · type · rename · zip · unzip · mount · umount · install · fdisk · mkfs · rm · rmdir · rsync · df · gpg · vi · nano · mkdir · du · ln · patch · convert · rclone · shred · srm · scp · gzip · chattr · cut · find · umask · wc · tr

Processes

alias · screen · top · nice · renice · progress · strace · systemd · tmux · chsh · history · at · batch · free · which · dmesg · chfn · usermod · ps · chroot · xargs · tty · pinky · lsof · vmstat · timeout · wall · yes · kill · sleep · sudo · su · time · groupadd · usermod · groups · lshw · shutdown · reboot · halt · poweroff · passwd · lscpu · crontab · date · bg · fg · pidof · nohup · pmap

Networking

netstat · ping · traceroute · ip · ss · whois · fail2ban · bmon · dig · finger · nmap · ftp · curl · wget · who · whoami · w · iptables · ssh-keygen · ufw · arping · firewalld

RELATED: Best Linux Laptops for Developers and Enthusiasts

#LVM#Ubuntu#partition resizing#snapshots#logical volume management#storage management