I need to identify the last sector used by an ext4 filesystem so that I can move it to another device.
The filesystem has been shrunk (with resize2fs) and is smaller than the partition that contains it, so I am not asking how to find the last sector in the partition.
I have done tune2fs -l and identified that
Block count: 48934
First block: 0
Block size: 4096
From that I would postulate that the filesystem uses 48934 * 4096 / 512 = 391472 sectors and that I can move that many sectors with dd starting at the first sector of the partition (as reported by gdisk).
I am uncertain whether that block count includes any ext4 overhead or if there is additional size that needs to be considered. I read this question which implies there is additional space to be considered.