Extending partitions with fsdisk
Introduction
When managing disk space on a Linux system, you may encounter situations where you need to extend a partition to accommodate more data. One common tool used for this purpose is fdisk, a command-line utility that allows you to create, delete, and modify partitions on a disk. In this article, we will discuss how to extend partitions using fdisk.
Checking Disk Space
Before extending a partition, it is important to check the current disk space usage on your system. You can use the df command to display the amount of disk space used and available on each mounted filesystem. This will help you determine which partition needs to be extended to accommodate more data.
Extending a Partition
To extend a partition using fdisk, follow these steps:
- Open a terminal window and run the fdisk command with the disk you want to modify (e.g., /dev/sda).
- Type ‘p’ to display the partition table and identify the partition you want to extend.
- Delete the existing partition by typing ‘d’, then recreate it with a larger size by typing ‘n’.
- Save your changes by typing ‘w’ to write the new partition table to the disk.
Resizing the Filesystem
After extending the partition with fdisk, you will need to resize the filesystem to take advantage of the additional space. This can be done using the resize2fs command for ext2, ext3, and ext4 filesystems, or the xfs_growfs command for XFS filesystems. Make sure to unmount the filesystem before resizing it to avoid data corruption.