[CentOS] Convert from LVM

Fri Jun 8 21:36:05 UTC 2018
Nataraj <incoming-centos at rjl.com>

On 06/08/2018 12:34 PM, Ulf Volmer wrote:
> On 08.06.2018 19:11, Matt wrote:
>> I have a Centos 7 install using EXT4 on LVM.  Its running as a VM
>> inside KVM.  Issue I have run into is that fstrim does not work due to
>> the LVM.  Without fstrim snapshots have gotten huge.  Is there a way
>> convert it from LVM to non-LVM without a complete reinstall?
> please consider to enable trim over LVM. You have just to set
> issue_discards = 1
> in /etc/lvm/lvm.conf.
> best regards
> Ulf
> _______________________________________________
> CentOS mailing list
> CentOS at centos.org
> https://lists.centos.org/mailman/listinfo/centos

I  believe that it is possible to use trim on an LVM, but I don't think
that is what that option is.  In my /etc/lvm/lvm.conf file, it describes
that option as follows:

	# Configuration option devices/issue_discards.
	# Issue discards to PVs that are no longer used by an LV.
	# Discards are sent to an LV's underlying physical volumes when the LV
	# is no longer using the physical volumes' space, e.g. lvremove,
	# lvreduce. Discards inform the storage that a region is no longer
	# used. Storage that supports discards advertise the protocol-specific
	# way discards should be issued by the kernel (TRIM, UNMAP, or
	# WRITE SAME with UNMAP bit set). Not all storage will support or
	# benefit from discards, but SSDs and thinly provisioned LUNs
	# generally do. If enabled, discards will only be issued if both the
	# storage and kernel provide support.
	issue_discards = 1

My understanding of issue_discards is that the trims will be issued 
automatically if you delete a logical volume.  If you are running lvm on
an encrypted volume then you may also need to set the discard option in
/etc/crypttab. Still probably a good idea to enable this, but possible
downside is that if you accidently incorrectly lvremove the wrong LVM,
you can't get it back cause blocks are returned to the free pool inside
the logic of the SSD.

Note that whether you use or don't use trim is not going to directly
effect the size of your snapshots (or other files).  If you have a
problem with that, then you may need to look at how your managing
snapshots.  When you enable trim it will free blocks for reuse in the
logic of your ssd (which is a good thing)  but your kvm files will not
appear to be a different size with "ls -l" or "du".

Here's an interesting post on using trim with an LVM on top of an
encrypted partition: