Linux extend file system after resize disk volume

When you resize a disk volume on a Linux system, the file system on that volume may not automatically adjust to the new size. To extend the file system to use the new space, you can use the resize2fs command. Here are the general steps to extend a file system after resizing a disk volume:

  1. First, check the current size of the file system using the command df -h. This will show the current size of the file system and the amount of available space.
  2. Unmount the file system if it is currently mounted. You can use the command umount /dev/<device> to unmount the file system. Replace <device> with the name of the device that contains the file system you want to resize.
  3. Use the command fdisk /dev/<device> to enter the fdisk utility. Use the p command to view the partition table and make sure that the partition you want to resize is the last one.
  4. Use the d command to delete the partition you want to resize.
  5. Use the n command to create a new partition, and use the same starting sector as the deleted partition.
  6. Use the w command to write the changes to the partition table.
  7. Use the command e2fsck -f /dev/<device> to check the file system for errors.
  8. Use the command resize2fs /dev/<device> to resize the file system. This will extend the file system to use the new space.
  9. Use the df -h command to verify that the file system has been extended to the new size.
  10. Finally, remount the file system using the command mount /dev/<device> /path/to/mountpoint

Please note that these are general steps and you should refer to the official documentation and also make sure to have a backup before starting with any of these steps as a precautionary measure.

Leave a Comment