Skip to content

Instantly share code, notes, and snippets.

@hantoine
Last active March 2, 2021 14:45
Show Gist options
  • Save hantoine/abb1fc0ad7955bb2095a05a165a6b907 to your computer and use it in GitHub Desktop.
Save hantoine/abb1fc0ad7955bb2095a05a165a6b907 to your computer and use it in GitHub Desktop.

Create a new encrypted partition

  1. Create the partition using GParted for example and take note of the partition path (/dev/sd*).
  2. Use the command sudo cryptsetup luksFormat <device path> to create the encrypted partition.

Create an LVM physical volume in the encrypted partition

  1. Using GParted, for example, "Open" the encrypted partition.
  2. Using the command lsblk, you should see the encrypted partition with a name ending with _crypt, take note of it.
  3. Create the LVM Physical volume using the command sudo pvcreate /dev/mapper/<encrypted partition name>.

Add the LVM physical volume to an existing volume group

  1. List the existing LVM volume groups with the command sudo vgs.
  2. List the existing LVM physical volume with the command sudo pvs.
  3. Add the physical volume to the volume group with the command vgextend <volume group name> /dev/mapper/<physical volume name>.

Extend an existing LVM logical volume with the new physical volume

  1. Use the command sudo lvextend <volume group>/<logical volume> /dev/mapper/<physical volume name>.
  2. Use the command sudo resize2fs /dev/<volume group>/<logical volume>.

See the mapping of logical volumes to physical volumes extents

Use the command sudo lvdisplay -m.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment