how to extend partition size on linux by unallocated space
- User
how to extend partition size on linux by unallocated space
- Assistant
To extend a partition on Linux using unallocated space, you can follow these steps:
-
Identify the partition that you want to extend. You can use the
fdiskorlsblkcommand to list all your partitions and identify the one you want to extend. -
Turn off any processes that may be using the partition to be extended.
-
It is recommended to create a backup of your data in case something goes wrong during the partition resizing process.
-
Open a terminal and use the
resize2fscommand to resize the file system on the partition to match the new size of the partition. Replace/dev/sdXYwith the actual partition you want to resize:sudo resize2fs /dev/sdXY -
Use the
fdiskcommand to delete and recreate the partition with the new size. Replace/dev/sdXwith the actual disk andYwith the partition number:sudo fdisk /dev/sdX Command (m for help): d Partition number (1-4): Y Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4): Y First sector (XXX-XXX, default XXX): Last sector, +sectors or +size{K,M,G} (XXX-XXX, default XXX): Command (m for help): w -
Reboot your system for the changes to take effect.
-
Finally, use the
resize2fscommand again to resize the file system one last time:sudo resize2fs /dev/sdXY
After following these steps, the partition should now be extended and ready to use the unallocated space on Linux.
-
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.