Is it possible to reload lvm.conf without reboot?

9,035

According to the default comments in my lvm.conf, the issue_discards option only controls what happens to the freed space when you run lvreduce or lvremove, nothing else:

# 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. 

It is confirmed by this message on linux-lvm mailing list by RedHat's Mike Snitzer:

lvm.conf's issue_discards doesn't have any affect on the kernel (or underlying device's) discard capabilities. It only controls whether discards are issued by lvm for certain lvm operations (like when an LV is removed).

So, if the underlying SSD supports TRIM or other method of discarding data, you should be able to use blkdiscard on it or any LVs placed on it just fine.

In other words, if you enable issue_discards, you can achieve the discarding of a LV's contents in two ways:

  • run blkdiscard on the LV. Example:

# lvcreate -L 1g vg00 Logical volume "lvol6" created. # blkdiscard -v /dev/vg00/lvol6 /dev/vg00/lvol6: Discarded 1073741824 bytes from the offset 0

  • just use lvremove and LVM does the discarding for you. You don't have to do anything special to make the setting take effect.

[issue_discards initially disabled] # lvremove /dev/vg00/lvol6 Do you really want to remove active logical volume vg00/lvol6? [y/n]: y Logical volume "lvol6" successfully removed # vi /etc/lvm/lvm.conf [set issue_discards to enabled] # lvcreate -L 1g vg00 Logical volume "lvol6" created. # lvremove /dev/vg00/lvol6 Do you really want to remove and DISCARD active logical volume vg00/lvol6? [y/n]: y Logical volume "lvol6" successfully removed

Note the added ... and DISCARD ... in the message of the lvremove command.

Share:
9,035
Lapsio
Author by

Lapsio

Updated on September 18, 2022

Comments

  • Lapsio
    Lapsio over 1 year

    I enabled issue_discards in lvm.conf file on machine with ssd and I'd like to perform blkdiscard on one of logical volumes. Can i do that without rebooting machine? I'm able to unmount physical volume along with all logical volumes stored on this particular ssd but I'd prefer to avoid system reboot.

  • Lapsio
    Lapsio about 6 years
    Unfortunately I'm getting /dev/mapper/data-cache: BLKDISCARD ioctl failed: Operation not supported whereas I'm pretty sure I had no problem with running blkdiscard on entire partition/drive. It's Samsung 850 pro. hdparm -I /dev/sdi says Data Set Management TRIM supported (limit 8 blocks). I remember setting up full trim support up to btrfs level on old installation but this time i didn't bother until now.
  • Lapsio
    Lapsio about 6 years
    Oh i forgot to mount dm-crypt with discard enabled
  • telcoM
    telcoM about 6 years
    From the information you initially supplied, I would have needed a really wizardly crystal ball to see that :-) Good to hear that you found the cause.