[linux-lvm] lvremove does not pass discards if volume is part of thin pool

Tomas Janousek tomi at nomi.cz
Tue Jan 26 17:03:18 UTC 2016


Hello all again,

I will answer one of my questions myself as I just found the answer:

On Fri, Jan 22, 2016 at 06:18:29PM +0100, Tomas Janousek wrote:
> Is there perhaps some way to force the discard manually? I thought that maybe
> creating a new sparse file/loop device/physical volume and doing pvmove might
> help, but what I got instead was a file that wasn't sparse at all, actually
> taking more space than the original one. Is this expected?
> (The only explanation I can think of is that pvmove doesn't care nor
> understand the on-disk format of device mapper thin-pools so it has to copy
> everything byte by byte. Is that it?)
> 
> Maybe creating a sufficiently large volume in the thin pool, doing a dd
> if=/dev/zero of=/path/to/volume/tmp/blanks and then deleting
> /path/to/volume/tmp/blanks would help, but could be quite slow. :-(

This hack with dd if=/dev/zero works indeed, but there's a tool called
blkdiscard in util-linux which works much better. I just call it prior to
lvremove (or lxc-destroy in my case) and the space is freed.

-- 
Tomáš Janoušek, a.k.a. Pivník, a.k.a. Liskni_si, http://work.lisk.in/




More information about the linux-lvm mailing list