1

I ran resize2fs on a ext4 linux partition and I want to create a partition after it. However I want to sanity check that the size I put into fdisk afterwards was correct. What's the best way to sanity check that the size of the partition + the filesystem match up.

NOTE: I used sectors in resize2fs and +sectors in fdisk to do the sizes. I think this was correct.

  • Why not simply use resize2fs / resize4fs to resize the filesystem to the full size of the partition (I think you just run it as resize2fs /dev/XXX and it figures it out for itself) – davidgo Dec 22 '15 at 3:37
  • Yeah, most docs don't say to do that, but I guess it makes sense to just do all the resizing in fdisk then let resize2fs do the moving. – RLZaleski Dec 22 '15 at 16:37
2

The way I do it is to resize the filesystem to something smaller than the new size of the partition it is on so that when you create the new partition you can just do resize2fs /dev/sdX and it will use the "unallocated" space.

Let me give you an example:

/dev/sda is a 20G harddrive and there is one partition, /dev/sda1 which uses all 20G. Now you want /dev/sda1 and /dev/sda2 of 10G each. First you resize your filesystem to something smaller than 10G. I'd use 8 or 9G. Then resize the partion, create the new partition sda2 and then finally run resize2fs /dev/sda1 to use the leftover 1 or 2G.

Let me know if I misunderstood something.

  • I did this on accident last night. Good to know that actually should work good. Just get nervous the ext one will end up sized too large and overwrite the EFI partition. But at least it's for Linux so it shouldn't be that hard to recreate. – RLZaleski Dec 22 '15 at 16:35

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.