Resizing partitions

Why the fuck is there no one that can tell you how tf it works?

How to do it

Preperations

You need to be in a rescue system or have the disk unmounted. That is non negotiable!
Also make a snapshot/backup of you system!


Resizing

  1. e2fsck -f /dev/sdXY
  2. resize2fs /dev/sdXY XG
  3. fdisk /dev/sdX

In fdisk you need to:

  1. Delete the old partition (d)
  2. Recreate it (n)
    1. Use +XG to resize it to the GB amount you choose when using resize2fs
  3. Write it (w)

Now you should have a working partition that is resized to the amount you wanted.

How to online grow a ext4 partition

This tutorial uses Arch Linux so package names might vary

  1. Install cloud-guest-utils which includes growpart
  2. Backup your partition table so you can recover if needed
    sudo sfdisk -d /dev/sda > partition_bak.dmp
  3. Use growpart to grow the partition
    growpart /dev/sda 2
  4. Use resize2fs to grow your filesystem
    resize2fs /dev/sda2

Now you should have a ext4 partition that spans the entire rest of your drive.