reducing size of root vg

General support questions
Post Reply
cxc143
Posts: 6
Joined: 2015/08/20 21:01:46

reducing size of root vg

Post by cxc143 » 2018/05/15 14:16:33

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?

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

Re: reducing size of root vg

Post by TrevorH » 2018/05/15 14:38:30

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).
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

cxc143
Posts: 6
Joined: 2015/08/20 21:01:46

Re: reducing size of root vg

Post by cxc143 » 2018/05/15 14:47:02

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

cxc143
Posts: 6
Joined: 2015/08/20 21:01:46

Re: reducing size of root vg

Post by cxc143 » 2018/05/15 14:47:30

update

it was a 750gb disk increased to 1.5 TB

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

Re: reducing size of root vg

Post by TrevorH » 2018/05/15 15:01:41

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).
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

cxc143
Posts: 6
Joined: 2015/08/20 21:01:46

Re: reducing size of root vg

Post by cxc143 » 2018/05/15 15:09:23

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?

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

Re: reducing size of root vg

Post by TrevorH » 2018/05/15 15:20:12

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.
CentOS 5 died in March 2017 - migrate NOW!
Full time Geek, part time moderator. Use the FAQ Luke

cxc143
Posts: 6
Joined: 2015/08/20 21:01:46

Re: reducing size of root vg

Post by cxc143 » 2018/05/15 15:27:10

Thanks for the sanity check - wanted to be extra sure I wasn't missing anything.

Post Reply