3

I want to shrink my /dev/sda2 partition from 463.37GB to 400GB to make room for a new partition.

So I did e2fsck -f /dev/sda2 followed by resize2fs /dev/sda2 400G.

As per man resize2fs, the resize2fs program does not manipulate the size of partitions., so the size is still 463.37GB.

When I start GParted, I can see the unallocated space:

enter image description here

13.27 GB Used + 386.73 GB Unused space totals 400 GB, as per my resize2fs command. Also, they grey area displayed is the unallocated space into which I'd like to create the new partition.

So far so good.

Yet, I'd like to see the size of the unallocated space without any GUI tool, only with command line tools such parted, fdisk, df or whatever. Unfortunately, I can't find how I can do that.

Is this somehow possible?

1
  • You only took care of the fs. Now you have to boot from a DVD/pen and shrink the actual partition; with fdisk you have to actually delete it, and recreate it again with 401GB, just to be safe; you might be able to shrink it with parted, not sure about that. Then I would prefer to delete also the swap space, and recreate it again just to organize things around. Mar 16 '16 at 13:39
1

df is already not that bad. df doesn't show the size of the partition, but the size of the filesystem itself. However, what it shows is also the available space, it does not reflect overhead, metadata and such.

For an exact value, you need more filesystem specific tools; for example tune2fs -l /dev/device should give you block count, block size and that should reflect your 400G setting.

But since you already know it's 400G you can just resize the partition to 400G directly, just make sure not to use 400GB instead of 400GiB by accident...

Also if there are storage layers in between (mdadm, cryptsetup, ...), they add their own metadata and offsets which you have to take into account.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.