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?
Do you mean you have a CentOS 7 VM which has partitioned is virtual disk (eg /dev/vda) to have a LVM partition, which in turn has a logical volume for root?
It should be possible create a fresh virtual disk, add it to the VM as /dev/vdb (say), and then inside the CentOS 7 VM, partition the new disk into however many partitions you need (say /dev/vdb1 for /boot, /dev/vdb2 for swap, and /dev/vdb3 for /) and then use dd or use mkfs and rsync, etc. to copy the file systems, go a grub-install on /dev/vdb and then stop the VM and remove the /dev/vda disk from it and restart it. Oh, you might need to make sure the UUID or LABEL used to reference the root file system in the grub config file is updated to reflect the new root (might not be needed if you used dd).
Unlike MS-Windows, Linux is (generally) perfectly happy to disk "transplants", so long as you are careful about re-installing grub and making sure the grub config has the right "magic".
At Fri, 8 Jun 2018 12:11:40 -0500 CentOS mailing list centos@centos.org 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? _______________________________________________ CentOS mailing list CentOS@centos.org https://lists.centos.org/mailman/listinfo/centos
On Fri, Jun 8, 2018 at 1:00 PM, Robert Heller heller@deepsoft.com wrote:
Unlike MS-Windows, Linux is (generally) perfectly happy to disk "transplants", so long as you are careful about re-installing grub and making sure the grub config has the right "magic".
Also update /etc/fstab and anything else the might refer to a UUID or dev entry, like /etc/mdadm.conf or /etc/lvm/lvm.conf etc. Maybe run a "grep -ri 'uuid' /etc" to find anything pointing at a UUID entry.
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
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.
Does that still work if it is not a THIN LVM?
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@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: https://unix.stackexchange.com/questions/85865/trim-with-lvm-and-dm-crypt
Nataraj
On 08.06.2018 23:36, Nataraj wrote:
On 06/08/2018 12:34 PM, Ulf Volmer wrote:
issue_discards = 1
in /etc/lvm/lvm.conf.
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:
trust me, that's exactly the option to enable trim on LVM devices.
The link you posted below says also the same.
https://unix.stackexchange.com/questions/85865/trim-with-lvm-and-dm-crypt
best regards Ulf
On 06/08/2018 02:36 PM, Nataraj wrote:
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?
I think that what your dealing with is an issue of file systems in a virtual machine. I don't think you can shrink a filesystem in a virtual machine just by deleting files from it. Here's one explanation of how to do this. I'm not sure about zeroing out the free space on the partition (might be necessary, I don't know), but you do need to recover space from the qemu image using something similar to what is show in this post. It is the "qemu-img convert" that actually recovers the space, but only after you have reduced the usage in the VM. https://mindref.blogspot.com/2011/07/shrink-qcow2.html
This has nothing to do with trim (though still a good idea to enable trim for your SSD for other reasons).
Nataraj