Resize Partitions in CentOS: Non-destructive Guide

There are two ways to adjust partitions without data loss on CentOS: using the GParted tool or using the command-line tool fdisk.

  1. Utilizing the GParted tool:
  2. First, install the GParted tool with the command: sudo yum install gparted.
  3. Open the GParted tool: sudo gparted
  4. Choose the partition you want to adjust, right click and select the “Resize/Move” option, then drag the partition boundary to adjust its size.
  5. Click the “Apply” button to implement the changes.
  6. Utilize the fdisk command line tool:
  7. To begin, open the terminal and run the fdisk command: sudo fdisk /dev/sdX

    Here, /dev/sdX is the device name of the partition you want to adjust.

  8. Use the commands to delete the existing partition and create a larger one:
    d (delete existing partition)
    n (create new partition)
    w (save changes)
  9. Adjust the file system size using the resize2fs command: sudo resize2fs /dev/sdX

    Where /dev/sdX is the device name of the partition you want to resize.

Please be sure to back up important data before making any partition adjustments to avoid accidental data loss.

bannerAds