Logical volume question

Issues related to applications and software problems and general support
mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Logical volume question

Post by mjz » 2021/01/11 14:40:10

I have a two 2TB disk Centos 8 server. The disks are partitioned as one large XFS logical volume and an ext4 boot/OS partition.
Together I was using 63% of the available space.

I want to replace one of the 2TB drives with a 4TB drive I have. I moved a key directory off the logical volume and this reduced my logical volume size from 63% to 12%.

I then used PVmove to try and move the extants off the second drive to empty it and it failed (no available space) which puzzled me. I'm new to logical volume management and not sure on what next to do in the order I need to do them.

I would like to shrink the logical volume so data is only on one drive. And then add the second drive and extend the volume back up or just create a new filesystem and partition table.

I thought all I would have to do is reduce the space used, shrink the volume - add the new larger disk and then expand the volume again. If I can't do this easily (i.e. learn how to do it so it's easy, like most things are easy once you know how~!), I feel stuck. I don't want to mess much with the boot disk.

thanks for in advance for educating me on how to do this correctly.

User avatar
jlehtone
Posts: 3711
Joined: 2007/12/11 08:17:33
Location: Finland

Re: Logical volume question

Post by jlehtone » 2021/01/11 16:32:01

You can shrink LV only if you shrink the filesystem that is in the LV too.
It is not possible to shrink XFS.

mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Re: Logical volume question

Post by mjz » 2021/01/11 16:45:43

so if I can't shrink xfs - what do you recommend?

User avatar
TrevorH
Forum Moderator
Posts: 31159
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Logical volume question

Post by TrevorH » 2021/01/11 18:18:17

How are your existing drives setup? Just with LVM so a VG with two PVs in it? Or mdadm underneath creating a RAID 0 deivce with LVM on top? Show the output from the commands pvs, vgs, lvs and df -h (first 3 as root, 4th doesn't matter).
CentOS 6 died in November 2020 - migrate to a new version!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Re: Logical volume question

Post by mjz » 2021/01/11 22:14:04

Thanks Trevor -
(I just assume get rid of snapd - it's legacy when I wanted to use Filezilla before it was in the Centos8 repository. It's not needed now, but not urgent.)

PVS:
PV VG Fmt Attr PSize PFree
/dev/sda2 cl lvm2 a-- <1.82t 0
/dev/sdb1 cl lvm2 a-- <1.82t 0

VGS:
VG #PV #LV #SN Attr VSize VFree
cl 2 3 0 wz--n- <3.64t 0

LVS:
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home cl -wi-ao---- 3.57t
root cl -wi-ao---- 50.00g
swap cl -wi-ao---- <15.77g

df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 16G 0 16G 0% /dev
tmpfs 16G 0 16G 0% /dev/shm
tmpfs 16G 9.6M 16G 1% /run
tmpfs 16G 0 16G 0% /sys/fs/cgroup
/dev/mapper/cl-root 50G 7.3G 43G 15% /
/dev/loop2 32M 32M 0 100% /var/lib/snapd/snap/snapd/10492
/dev/loop7 56M 56M 0 100% /var/lib/snapd/snap/core18/1932
/dev/loop3 31M 31M 0 100% /var/lib/snapd/snap/snapd/9721
/dev/loop1 161M 161M 0 100% /var/lib/snapd/snap/gnome-3-28-1804/116
/dev/loop4 63M 63M 0 100% /var/lib/snapd/snap/gtk-common-themes/1506
/dev/loop5 163M 163M 0 100% /var/lib/snapd/snap/gnome-3-28-1804/145
/dev/loop0 55M 55M 0 100% /var/lib/snapd/snap/core18/1668
/dev/loop6 65M 65M 0 100% /var/lib/snapd/snap/gtk-common-themes/1514
/dev/mapper/cl-home 3.6T 609G 3.0T 17% /home
/dev/sda1 976M 369M 541M 41% /boot
tmpfs 3.2G 1.2M 3.2G 1% /run/user/42
tmpfs 3.2G 28K 3.2G 1% /run/user/1000

mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Re: Logical volume question

Post by mjz » 2021/01/11 22:29:57

Additional information on filesystems: Both are type xfs

/dev/mapper/cl-root on / type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)

/dev/mapper/cl-home on /home type xfs (rw,relatime,attr2,inode64,logbufs=8,logbsize=32k,noquota)

mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Re: Logical volume question

Post by mjz » 2021/01/13 17:57:14

Any help on how to shrink a logical volume so a disk can be removed?
If XFS can't be shrunk - how can I remove the filesystem without affecting my boot partition and recreate it smaller so the second disk can be removed.

User avatar
TrevorH
Forum Moderator
Posts: 31159
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Logical volume question

Post by TrevorH » 2021/01/13 18:00:16

I think you're going to end up having to backup all the data on that LV and remove it. Then vgreduce to remove one of the 2TB disks and then add the 4TB one. Or you could add the 4TB drive as a separate PV/VG/LV so you don't have this fun next time.
CentOS 6 died in November 2020 - migrate to a new version!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

mjz
Posts: 81
Joined: 2020/02/13 22:05:02

Re: Logical volume question

Post by mjz » 2021/01/14 00:51:23

Part of this is learning. All data is backed up - redundantly, just takes hours restoring.

I think my mistake was just taking defaults when I created the logical volume in the first place - 'xfs' is not appropriate here ... then PVmove would have worked fine (I suspect).

I only have two drive bays, so not an option to just add the third drive. I prefer just to replace the 2TB with the larger drive.

I just need to be sure of syntax in removing "just" the logical volume and not mess up the boot partition and OS.

User avatar
TrevorH
Forum Moderator
Posts: 31159
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Logical volume question

Post by TrevorH » 2021/01/14 01:19:24

Make sure you remove it from /etc/fstab and check the kernel command lines in /boot/grub2/grub.cfg (or its UEFI equivalent somewhere under /boot/efi) to see if it's listed there as an LV to activate at boot. If it's /home then you will need to make sure any user command lines you have open are not using your home directory as their cwd. There might be other places that I haven't though of but those are the two I remember.

I don't think this is xfs's fault BTW. You just have more data than can fit on one of the 2TB drives - LVM doesn't know about the filesystem on top of it so it just knows "how big am I?". It doesn't know about files on the filesystem nor about how much of the filesystem is used and how much is free.

xfs's main fault is its inability to be resized smaller which I am told appears to be by design so not something that's ever likely to be fixed.
CentOS 6 died in November 2020 - migrate to a new version!
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 is dead, do not use it.
Full time Geek, part time moderator. Use the FAQ Luke

Post Reply

Return to “CentOS 8 - General Support”