From 0bd9676a2e855d1d99d29d69bc0b177f82a4acf7 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Thu, 2 Feb 2023 22:43:44 +0100 Subject: [PATCH] Added howto for extending a logical volume --- knowledge base/resize a logical volume.md | 34 +++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 knowledge base/resize a logical volume.md diff --git a/knowledge base/resize a logical volume.md b/knowledge base/resize a logical volume.md new file mode 100644 index 0000000..73c213d --- /dev/null +++ b/knowledge base/resize a logical volume.md @@ -0,0 +1,34 @@ +# Resize a Logical Volume + +## TL;DR + +```sh +# Disk partition: /dev/sda2 +# Logical volume: rootvg-rootlv + +# Extend the partition. +# Optional; required only when there isn't enough space left on the disk. +sudo growpart '/dev/sda' '2' + +# Extend the physical volume. +# Optional; required only when there isn't enough space left in the volume. +sudo pvresize '/dev/sda2' + +# Extend the file system to the desired size. +sudo lvextend -rL '48G' '/dev/mapper/rootvg-rootlv' +``` + +```yaml +#cloud-config + +# 'growpart' only extends partitions to fill the available free space. +# At the time of writing there is no way to limit the expansion. +growpart: + mode: auto + devices: + - / + +runcmd: + - pvresize '/dev/sda2' + - lvextend -rL '48G' '/dev/mapper/rootvg-rootlv' +```