How to expand the root directory in Ubuntu?

To increase the capacity of the Ubuntu root directory, you can follow these steps:

  1. In Ubuntu, use the command df -h to check the current disk usage and determine which disk the root directory is on.
  2. Use disk management tools like GParted to resize the disk. GParted is a graphical disk partitioning tool that can be installed through a software package manager or via the command line.
  3. Enter the command sudo resize2fs /dev/sdXY in the terminal, replacing /dev/sdXY with the partition where the root directory is located. This command will automatically adjust the file system size of the partition to fit the new disk size.
  4. Finally, use the command df -h to check if the root directory has been successfully expanded.

Note: Before expanding the disk, please be sure to backup important data to prevent data loss.

bannerAds