On my intranet server, I have a 100.00 GiB partition /dev/sda5, which I use as a physical volume for lvm2.
- It's the only physical volume in my volume group vg01.
- vg01 currently contains one logical volume lv01, using the full 100.00 GiB - well, actually 99.99 GiB due to some rounding (that's where the problem starts).
- lv01 contains an ext3 file system, using the entire space.
I want to reduce lv01 to approximately 97 GiB, so I can create lv02 with approx. 3 GiB (I need it to take lvm snapshots).
What I did so far:
e2fsck -f /dev/mapper/vg01-lv01
resize2fs /dev/mapper/vg01-lv01 97G
This has worked well. But now I'll have to run
lvreduce --size ? /dev/mapper/vg01-lv01
And I'm not sure, which exact value I'll have to specify. The lvreduce
man page warns explicitly, that the resulting size must not be smaller than the file system. I also don't want to make it larger than it has to be. But now I have different numbers:
- I specified
97G
in resize2fs. df -h
says, it's 96 G.df
says, it's 100115936 1K-blocks.- lvdisplay (of course) still reports 99.99 GiB for the logical volume.
What will I have to specify for lvreduce
?
Edit:
The currently accepted answer provides a nice workaround. However, in order to integrate such things in solid scripts etc., I would generally prefer to use precise measurements instead. Or maybe there's already a reliable (!) script or tool which performs the entire resize procedure in one step?
resize2fs
to reduce the filesystem down to 90GiB or so, and then muck around with arguments tolvreduce
(followed byresize2fs
) to see what works best.