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.
- Utilizing the GParted tool:
- First, install the GParted tool with the command: sudo yum install gparted.
- Open the GParted tool: sudo gparted
- Choose the partition you want to adjust, right click and select the “Resize/Move” option, then drag the partition boundary to adjust its size.
- Click the “Apply” button to implement the changes.
- Utilize the fdisk command line tool:
- 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.
- Use the commands to delete the existing partition and create a larger one:
d (delete existing partition)
n (create new partition)
w (save changes) - 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.