I am using LVM on Ubuntu 9.10 (Karmic). I have a single LVM physical volume (and a single volume group).
I have an ext3 filesystem inside an LVM logical volume which I no longer use, but for the time being I would like not to delete it. I'm trying to figure out how to minimise the space it takes up inside my PV. resize2fs has the -M option which works well at resizing the filesystem to have zero free space, but of course this doesn't affect the logical volume. Most of the recipes on the web for shrinking ext3 inside an LV (e.g. this one), follow this basic pattern to alleviate problems with inaccurate calculations of filesystem boundaries, etc.:
- Shrink ext3 more than you quite want with resize2fs
- Shrink the LV to the exact size you want
- Re-run resize2fs to grow the filesystem slightly to efficiently use the complete LV.
That doesn't fully solve the problem in my case, because I want the LV size to be driven by the filesystem, rather than the other way round.
Is there a command or commands I can run to do this? Alternatively, it is possible for me to do the calculation of the filesystem size to give to lvresize with some degree of confidence?