Reduce each of the pieces, from the inside out. You'll need to do that with
/ unmounted, so you'll need to do it from a live CD/USB. SystemRescueCD is good at this kind of things. Note that you need fairly recent version of the LVM and
/ filesystem with
resize2fs /dev/mapper/hostname--vg-root 240G
Shrink the logical volume containing
lvresize. Make absolutely sure you don't shrink it below the size of the filesystem. Run
tune2fs -l /dev/mapper/hostname--vg-root to double-check the filesystem size.
lvresize -L 240g hostname/vg-root
Note: if supported, tell
lvresize to call
fsadm to resize the filesystem. This eliminates the risk of accidentally shrinking the volume below the size of the filesystem. If this works, the previous step can be skipped.
lvresize -r -L 240g hostname/vg-root
Shrink the physical volume
pvresize. This may or may not work, due to a limitation of
pvresize: if the logical volume happens to occupy some room near the end of the physical volume,
pvresize won't move any data towards unoccupied space closer to the beginning of the volume. If you get bitten by that, the only solution I know of is to reduce the
/ filesystem and the logical volume as much as possible, and remove the swap volume, until you're able to shrink the physical volume to your content.
pvresize --setphysicalvolume 248g /dev/mapper/sda5_crypt
Then deactivate the volume group.
vgchange -an hostname
Shrink the encrypted volume with
cryptsetup. Here again, make very sure not to shrink it below the size of the LVM physical volume. Note that the unit for the
--size argument is 512-byte sectors. Very importantly, note that this is the size of the containing device, not the size of the encrypted data, so allow space for the metadata.
cryptsetup resize --size $((248*2*1024*1024+4096)) sda5_crypt
Then deactivate the encrypted volume.
cryptsetup luksClose sda5_crypt
Shrink the partition with
fdisk. Make sure not to shrink it below the size of the encrypted volume. You can create a new partition here.
Tip: if unsure about sizes, leave a margin at each step: shrink the inside more than the outside. Then, once everything is smaller than your goal, enlarge the encrypted volume to fill the partition, then enlarge the physical volume to fill the encrypted volume, then enlarge the logical volume to fill the physical volume, then enlarge the filesystem to fill the logical volume. Calling
resize2fs without a size argument makes them fill the containing volume.