Skip to content

Instantly share code, notes, and snippets.

@absolutejam
Created September 7, 2022 10:00
Show Gist options
  • Save absolutejam/94e028fe267856556505fff5d65802f6 to your computer and use it in GitHub Desktop.
Save absolutejam/94e028fe267856556505fff5d65802f6 to your computer and use it in GitHub Desktop.
Resize a disk

Resizing a disk with LVM

  • Run as sudo

    sudo su
  • Resize the physical disk of the VM

    lsblk
  • Create a new partiion

    fdisk /dev/sda
    n

    Accept the defaults for the following prompts:

    • Partition number
    • First sector
    • Last sector
  • Get partitions

    lsblk /dev/sda
  • Create a physical volume

    pvcreate
  • Add the physical volume to logical volume

    lvs # find the logical volume
    lvextend ubuntu-vg /sda/sdaX
  • Extend the logical volume

    lgextend -l +100%FREE /dev/ubuntu-vg/ubuntu-lv
  • Resize the filesystem

    resize2fs /dev/ubuntu-vg/ubuntu-lv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment