Expanding Ubuntu 22.04 Drive Via Terminal

  • Assumptions
    • You need to resize a drive without a GUI.
    • You have made some backup of your VM/Physical drive
  • Notes
    • I got locked out of my Ubuntu Desktop GUI for this tutorial and have to putty to the machine as shown in the image below.
  • List you disks
    • df -h
      • You will get a large output but you need to look for something similar to this
  • Find the partition that is out of space. (mine was /dev/sda3/)
    • sudo fdisk /dev/sda
  • Delete and remake the partition (YOU WILL NOT LOSE DATA), mine was partition 3
    • d
      • delete a partition
    • 3
      • Partition 3
    • n
      • Make a new partition
    • 3
      • Make it partition 3
    • PRESS ENTER TWICE
      • Specifying the starting and ending blocks. I want the default so I press enter for both questions.
    • Y
      • Yes, delete the signature
    • w
      • Write the changes.
    • Control + C
      • Exit fdisk
  • Resize the file system
    • sudo resize2fs /dev/sda3
  • Verify the changes were made
    • df -h
      • The new size of your file system will be shown.

Leave a Reply

Your email address will not be published. Required fields are marked *