Cannot do `pvresize`

I’m trying to run pvmove to move a lvm physical partition, but it’s returning Required device-mapper target(s) not detected in your kernel.

This is on a single partition. Output of pvs:

  PV             VG    Fmt  Attr PSize    PFree
  /dev/nvme0n1p3 chunk lvm2 a--  <475.94g <109.94g

Do you just have to pvcreate on the device you’re trying to move to? And maybe add it to your volume group?

(Accidentally opened this topic early, whoops! Asking about pvmove was an xy problem)

The actual issue I have is that I’m trying to do pvresize --setphysicalvolumesize 470G /dev/nvme0n1p3, but get this output instead:

/dev/nvme0n1p3: Requested size 470.00 GiB is less than real size <475.94 GiB. Proceed?  [y/n]: y
  WARNING: /dev/nvme0n1p3: Pretending size is 985661440 not 998115983 sectors.
  /dev/nvme0n1p3: cannot resize to 120319 extents as later ones are allocated.
  0 physical volume(s) resized or updated / 1 physical volume(s) not resized

For the pvmove problem, which I note because that’s a problem I was just hitting and this post turned up in my search results, you need the dm-mirror kernel module, which probably means adding "dm-mirror" to the boot.initrd.kernelModules list in your hardware-configuration.nix.

(I only managed to work this out by going to read the lvm source code!)

For the pvresize problem, pvmove might be the solution you need: the issue is that the PV contains data that’s stored somewhere that would be beyond the end of the PV after you had shrunk it.

You’ll need to move that data somewhere else, either earlier in the physical volume or onto a different volume. pvdisplay -m is useful for working out what extents are located where, then your next steps will depend on what you want to do with the data that’s past where you want the PV to end, but the examples at the bottom of man pvmove might be useful.

1 Like