How to resize the static partition in Linux without losing your data?

Some Prerequisites we need to check…

  • The only way to change a static partition size using fdisk is by deleting and recreating it so ensure that the information on the file system is backed up.
  • Make sure the partition you are resizing is the last partition on a particular disk.


1. Creating a partition and store some data:

  • Use fdisk -l to check disk and partiton details…
  • To create a new partition…
  • I am allocated 2G size. Now format and mount it to some directory.

And I also created one file with some data.

2. Unmount the partition:

# umount /dev/xvdf1

3. Run fdisk disk_name…

  • Check the partition number you wish to delete with the p. The partitions are listed under the heading “Device”.
  • Now use the option d to delete a partition. If there is more than one, fdisk prompts for which one to delete.
  • Use option n to create a new partition. Follow the prompts and if it asks to remove the signature, type N. And use option w to save the partition.

Don’t format the partition after it is created.

4. Run fsck on the partition:

The system utility fsck (file system consistency check) is a tool for checking the consistency of a file system in Unix and Unix-like operating systems, such as Linux.

5. Use resize2fs tool for grow/shrink the partiton:

The resize2fs is a command-line utility that allows you to resize ext2, ext3, or ext4 file systems.

6. Finally, mount it again and check the size this time…

We can see that size of disk is increased to 4GiB and data of disk is also still remained the same.

Do Clap if you find this useful :)

Thanks for Reading…😊

Feel free to connect on linkedin…😊




Tech Enthusiasts, Passion to learn and share

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Myths About Python Development Debunked

Edge Computing 101

Breaking Down Conflicts In Open Source Community

How you can benefit from Robotic Process Automation (RPA)

GraphQL: Simple authorization and authentication with HotChocolate 11 and ASP.NET Core 3

ArcoLinux is the Best Linux Distribution

Dynamic Programming

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Gaurav Gupta

Gaurav Gupta

Tech Enthusiasts, Passion to learn and share

Code Folding — Organizing your python code

Unit Testing your Python code — use of random for test data generation


Python Interview Questions 2021

What is Variables?