2

This is a further question after this one.

I google for it, but most of the search results are about how to grow the partition and the file system at the same time.

I think this question is simpler than that, because I the partition is already larger than the file system, but I want to grow the file system to fill the partition.

The reason why my file system is smaller than the partition is that I didn't format the partition by doing mkfs on it, but rather cating a file system image into it. And the image is smaller than the target partition.

The reason why I have to grow the file system to fully fill the partition is that my embedded SoC won't boot when there's a gap, explained at the end of this wiki.

2

I just ran into this while upgrading the size of the microSD card in my phone. I had used dd to clone the existing card onto a new card. The new partition was larger, but the filesystem was still the same size as the previous microSD. To solve it I used fdisk and fatresize. Also, I should mention that I was working with the /dev/mmcblk0p1 partition, which fatresize did not like for some reason (I was getting Error: Could not stat device /dev/mmcblk0p - No such file or directory.), so I did have to use a workaround mentioned at https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=810735 and add a soft link sudo ln -s /dev/mmcblk0p1 /dev/tmp.

Anyway, to resize the vfat partition (substituting /dev/tmp for your specific partition):

  1. Use sudo fdisk -s /dev/tmp to determine the size of the partition in kB. In my case this was 244244480
  2. sudo fatresize -s 244244480k /dev/tmp (substituting the partition size from step 1.)

As always, make sure to have a backup of the partition before attempting this!

Make sure to remove the temporary device soft link if you had to use the workaround.

1

The only way I know is to shrink / grow the partition a little with gparted (or an old version of parted that still did this). Somehow the code for resizing vfat is hidden away in this partitioning program (or libparted for that matter) and there don't seem to be tools like resize2fs that do this directly or offer more options.

Whether such a resize is sufficient for your embedded SoC - I'm not sure how well is vfat able to adapt to arbitrary partition sizes - you linked to a program you can test with. You might have to make your partition slightly smaller so the values match.

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.