0

i have 2 disks (4T & 2T) as lvm formatted as ext4... i've only used around 1T and wish to remove the 2T disk. is this possible? i've tried running:

pvmove /dev/sdb1

but errors No extents available for allocation

Edit: more info

pvs:

  PV         VG     Fmt  Attr PSize  PFree
  /dev/sdb1  vgmain lvm2 a--  <1.82t    0 
  /dev/sdc1  vgmain lvm2 a--  <3.64t    0

vgs:

  VG     #PV #LV #SN Attr   VSize  VFree
  vgmain   2   1   0 wz--n- <5.46t    0
1
  • perhaps you want pvremove - since you wish to remove the 2T disk - perhaps vgreduce to remove a physical volume from a volume group may also be needed
    – Bravo
    Nov 28 '21 at 2:09
2
  1. umount the filesystem
  2. Reduce the size of the filesystem by at least the size of the PV you want to remove (with e.g. resize2fs or fsadm; this step can be integrated into the next one with lvresize --resizefs)
  3. Reduce the size of the LV by at least the size of the PV you want to remove (lvresize); check the success with pvs and vgs.
  4. Use pvmove for moving all the data to other PVs.
  5. Use vgreduce for taking a disk out of a VG.
  6. Use pvremove for making the disk not look like a PV any more.

In order for pvmove to work there must be enough free space on the other PVs (see pvs).

7
  • i've only used 1T out of the ~6T storage, but both my disks says 0 free for pvs. i guess in this case i got to go the caveman route and backup data and recreate the storage as i wish...
    – Anton A
    Nov 28 '21 at 4:48
  • @AntonA That will not be necessary. Add the outputs of pvs and vgs to your question. Nov 28 '21 at 12:08
  • thanks a lot for your attention, i have added the info...
    – Anton A
    Nov 28 '21 at 19:57
  • 1
    @AntonA, note that amount of space used or free in the filesystem is not the same as the amount of space used of free in the volume group. LVM doesn't know about things like "files" or "ext4", it just allocates space for volumes and makes them available a bit like disk partitions. If you have a 6 TB logical volume on a 6 TB volume group, the VG is full, regardless of what you've stored in the LV. (or even if the LV is totally cleared!) If it just so happens that you have a single filesystem spanning the whole VG, you'll need to look into resizing the filesystem first.
    – ilkkachu
    Nov 28 '21 at 20:07
  • 1
    (resizing the filesystem, and then resizing the LV, and then possibly moving the LV completely to the other PV, and then you get to remove the PV from the VG.)
    – ilkkachu
    Nov 28 '21 at 20:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.