1

I have a redhat server with two disks 100gb and 500gb. The 500GB disk was unused, however I then used it to extend the /var LV. The filesystem on all mountpoints are xfs and you actually can't reduce lv on a xfs filesystem.

So what has been done to this point is:

  1. Create a partition on 500GB disk
  2. Extend LV lv_var with 50% of 500gb disk

I have not grown the filesystem yet with xfs_grow so the fs is still at 2gb on /var. My issue is then, how can I in a safe way remove the extended disk space on the 500gb disk without harming the filesystem on /var.

lsblk:

sda                            8:0    0   65G  0 disk
└─sda3                         8:3    0   64G  0 part
  ├─vg_rhel-lv_var           253:4    0  250G  0 lvm  /var
sdb                            8:16   0  500G  0 disk
└─sdb1                         8:17   0  500G  0 part
  └─vg_rhel-lv_var           253:4    0  250G  0 lvm  /var

Alex
  • 11
  • 1

1 Answers1

0

Usually you would use pvmove with lvreduce, but there is not enough room to move the extents from sdb1 to sda3. I will leave the pvmove information in this answer, but you could just use lvreduce.

If you didn't do lvresize -r to resize the filesystem, you can still shrink the lv.

You can then use lvreduce to reduce the size of the lv lvreduce -L 500g /dev/vg_rhel/lv_var. Be careful not to shrink smaller than actual filesystem. You can be safe run xfs_check (I think) after, but it has to be unmounted I believe, which, with var, would probably require single user mode.

Of course, if you actually want to resize var, as you mentioned, you can't shrink xfs. In that case you would have to create a completely new volume, copy everything over (first to minimize downtime), boot into single user mode, finish a copy (with rsync to get final changes), change fstab to mount new vol, reboot, and then you can deallocate old vol.

Pvmove information, which is really helpful for moving lvs between pvs.

https://linux.die.net/man/8/pvmove

In this case, probably pvmove -n lv_var /dev/sdb1 /dev/sda3

Forgive the formatting of this answer, I'm on mobile and don't have all the features. Anybody can feel free to edit.

So you move the extents of the var logical volume from sdb1 (whichever partition is part of the pv) to sda3 (again, whichever partition is part of the pv).

Then you have var all on sda3 and sdb1 would be unused, no extents allocated to any lv. Then you can vgreduce and pvremove if that is your goal.

lsd
  • 1,673
  • 10
  • 10