Page 1 of 1

reducing size of root vg

Posted: 2018/05/15 14:16:33
by cxc143
I have a centos 6.x vmware vm with a root volume group containing one virtual disk. that virtual disk was increased in size from 500 gb to 1 TB, and the server rebooted. No other operations were performed, i.e., no attempt to use this additional space was done. There is now a desire to reduce the size of that virtual disk back to 500Gb.

Am I risking any data loss by attempting to reduce the size of the virtual disk?

Re: reducing size of root vg

Posted: 2018/05/15 14:38:30
by TrevorH
What is the output from fdisk -lu /dev/XXX where XXX is the name of the disk in question? If it has a GPT label then use parted to print it instead (or gdisk from EPEL).

Re: reducing size of root vg

Posted: 2018/05/15 14:47:02
by cxc143
Disk /dev/sda: 1629.0 GB, 1629017341952 bytes
255 heads, 63 sectors/track, 198050 cylinders, total 3181674496 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00091f3b

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 1026048 1572863999 785918976 8e Linux LVM

Re: reducing size of root vg

Posted: 2018/05/15 14:47:30
by cxc143
update

it was a 750gb disk increased to 1.5 TB

Re: reducing size of root vg

Posted: 2018/05/15 15:01:41
by TrevorH
So your "disk" has 3181674496 sectors and the last allocated one is currently 1572863999 which means that the last 1608810497 are unused and you should be fine to shrink the disk as long as you don't make it smaller than that. Still, things can go wrong so if you have the ability to make a backup of it before you change it back, that would probably be a Good Thing(TM).

Re: reducing size of root vg

Posted: 2018/05/15 15:09:23
by cxc143
Ok, doable but risky,which is what I thought would be the case. It would be far less risk to just use that space to increase the size of the root vg, right?

Re: reducing size of root vg

Posted: 2018/05/15 15:20:12
by TrevorH
You're using LVM so you can add a new partition in that free space, use pvcreate to make it a PV, use vgextend to add that PV to your existing VG and now use lvextend -r to extend the filesystem you want to be larger (-r tells it to resize the filesystem as well). Or you can use the freespace in the VG to create new LVs and format those, mount them where you want the space and add to /etc/fstab to make permanent.

And when I said removing the space had risks, personally I would say those were low risk of happening but with a high severity if it did.

Re: reducing size of root vg

Posted: 2018/05/15 15:27:10
by cxc143
Thanks for the sanity check - wanted to be extra sure I wasn't missing anything.