wiki.allensmith.net

Personal "Rough Notes" & Useful Links

User Tools


14.04 LTS: Using LVM Capabilities

LVM Names

If a Logical Volume Manager name contains a dash, then the /dev/mapper/ version of that name will replace any single dash with a double dash.

As Example:
If the Logical Volume Group is some-volume-group & the Logical Volume is volume :

/dev/some-volume-group/volume
/dev/mapper/some--volume--group-volume

… are the 2 different ways in which that Logical Volume would exist in /dev .

This is why when I set names for a Logical Volume Group, and the Logical Volumes in that, I try to choose names that are short and to the point, made up of only letters and numbers.

Listing LVM Information

  • sudo blkid will show the UUID for both Drive Partitions and LVM Volumes.
  • sudo fdisk -l will list any Drive Partitions that contain a “Linux LVM”.
    • This will also provide some low-level information about the size of LVM Volumes.
    • Expect a “doesn't contain a valid partition table” message for any LVM Volume.
  • To List what an LVM Contains use sudo lvscan , sudo lvs or sudo lvdisplay
  • The Graphical Utility, “GNOME Disks” (a.k.a. Disks) can also display information for Drive Partitions and LVM Volumes.

Resize LVM Volume & Filesystem

If anything were to go wrong while resizing Logical Volumes, then data loss is possible. So make certain to backup anything you cannot afford to loose– before trying to resize anything.

Resize Ubuntu Studio LVM /swap

By default, installing Ubuntu will create a Swap Partition (/swap) that is the same size as the Physical Memory in the PC while Ubuntu is installing. Then the rest of the available drive space will be used for the Root Partition (/). When LVM has been used to install the operating system, it is possible to resize these partitions– to shrink the Root Partition by a few GB, then allocate that drive space to the Swap Partition.

Supposedly it is possible to expand an LVM Volume while it is in use. On the other hand, I expect that trying to shrink an LVM Volume while it is in use would amount to “just begging for trouble”. So in all cases, I try to “play it safe” by using Live Boot media when I want to resize anything.

Any Live Boot version of Ubuntu I have tried seems to want to use the existing Swap Partition– if it can find one. And Ubuntu 12.04 (or Mint 13) is the last Desktop version that did not include LVM support by default. Thus to resize /swap, I boot from 12.04LTS based media, then install the LVM2 support.

  • Live Boot to the Desktop using 12.04 LTS based media (USB / DVD / CD / etc.)
  • From a Terminal Window use the following commands:
$ sudo apt-get update
$ sudo -i
# apt-get install lvm2
# lvscan
For a standard install of Ubuntu Studio 14.04, the results are as follows:
inactive '/dev/ubuntu-studio-vg/root' [xx.xxGiB] inherit
inactive '/dev/ubuntu-studio-vg/swap_1' [x.xxGB] inherit

The next command will first shrink the filesystem, then shrink the Logical Volume, which is the only safe method to do this.

# lvreduce --resizefs --size -2GB /dev/ubuntu-studio-vg/root
# lvexpand --size +2GB /dev/ubuntu-studio-vg/swap_1
# mkswap /dev/ubuntu-studio-vg/swap_1

The last command above remakes /swap – which permits it to use the full size of the larger Logical Volume.

#exit
$ sudo reboot