Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save tyagiakhilesh/f4f569b503857b6cb99b53437d05b368 to your computer and use it in GitHub Desktop.
Save tyagiakhilesh/f4f569b503857b6cb99b53437d05b368 to your computer and use it in GitHub Desktop.
Extend partition on a disk

This is for centos8 This is source

General summary of steps

alter your partition table so sda2 ends at end of disk
reread the partition table (will require a reboot)
resize your LVM pv using pvresize

Inspect current partioning

$ sudo fdisk /dev/sdb

Welcome to fdisk (util-linux 2.32.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

The old ext4 signature will be removed by a write command.

Device does not contain a recognized partition table.
Created a new DOS disklabel with disk identifier 0xf635d49c.

Command (m for help): p
Disk /dev/sdb: 200 GiB, 214748364800 bytes, 419430400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xf635d49c

This only worked for me

sudo resize2fs /dev/sdb

What worked for me in production

https://www.slashroot.in/how-increase-size-root-volume-google-cloud-platform-gcp 
df -h // check current state of machine
lsblk // see if new disk size is visible
growpart /dev/sdb 1 // grow the volume
resize2fs /dev/sdb1 // resize the filesytem
e2fsck -f /dev/sdb1 // run this if above command tells you to do it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment