Ubuntu increase disk size

To increase the size of the /dev/sda2 partition from 20 GB to 100 GB, you need to resize both the partition and the filesystem. Here are the steps to achieve this:

Steps to Resize the Partition and Filesystem

  1. Backup Your Data:

    • Always ensure you have a complete backup of your data before making any changes to disk partitions.
  2. Use parted to Resize the Partition:

    • Open a terminal and use the parted command to resize the partition:
      sudo parted /dev/sda
      
    • Within the parted interactive shell, resize the second partition (/dev/sda2) to use the full disk space:
      (parted) resizepart 2 100%
      
    • Confirm the operation if prompted. This command will extend the partition to the maximum available size on the disk.
  3. Exit parted:

    • Type quit to exit the parted utility.
  4. Resize the Filesystem:

    • After resizing the partition, you need to resize the filesystem to occupy the newly allocated space. For an ext4 filesystem, use:
      sudo resize2fs /dev/sda2
      
    • This command will adjust the filesystem to fill the entire partition.
  5. Verify the Changes:

    • Use the df -h command to check that the filesystem now uses the full disk space:
      df -h /dev/sda2
      

By following these steps, you can successfully increase the size of the /dev/sda2 partition to utilize the full 100 GB of disk space on your Ubuntu system. Always ensure you have a backup of your data before proceeding with disk operations, as they can be risky.