Attempting to increase the size of a Linux LVM Disk
-
#assign filesystem to disk
mkfs.ext3 /dev/xvdb 2>/dev/null
mount /dev/xvdc /mnt -t auto
http://i.imgur.com/b16MOmA.jpg
Now I want to allocate the space in
/dev/xvdb
tocentos-root
. What would be the best way to do that? My first instinct is to shrink/dev/xvdb
and then apply whatever space I saved tocentos-root
but I'm doubting that's the best way to do it. -
If you're wanting to add this to an already existing logical volume you don't need to do anything with the file system at first. You need to add the new physical volume to the volume group that your existing logical volume is on. Once that physical volume has been added to the volume group you can extend the logical volume and increase it's size. At that point you can grow the file system to occupy the newly allocated space.
Here's an article that should help walk you through the process if you're not familiar: http://www.tecmint.com/extend-and-reduce-lvms-in-linux/
-
@RamblingBiped So I can unmount it and delete the virtual disk then recreate to start over, correct?
-
@wirestyle22 I think that should work. As long as you can see the disk you should be able to use LVM's pvcreate to create a physical volume and then add that volume to the volume group that is associated with your logical volume.
pvs and pvdisplay will show pertinent information in regards to your LVM physical volumes.
vgs and vgdisplay will show volume group information.
lvs and lvdisplay will show logical volume information.
-
@RamblingBiped So I can see that both Logical Volumes and Physical Volumes are added.
The question now is how to add the VFree space to
dev/mapper/centos-root
-
@wirestyle22 Did you do an lvextend on the logical volume that you are wanting to add the extra storage space to?
-
@wirestyle22 said in Attempting to increase the size of a Linux LVM Disk:
The question now is how to add the VFree space to dev/mapper/centos-root
So if you do a vgs command it should show your volume group with your newly increased capacity. When you do a lvs it should show your logical volumes (probably root and swap). You'll want to do a lvextend on your root logical volume to add the newly allocated space on the volume group to that logical volume.
The article I linked you previously should give a good example of that command. Google-fu will result in some official redhat documentation that will do a good job of walking you through it too.
Once you've extended your logical volume you'll just need to expand the filesystem to occupy the space. After that you should be all set.
-
-
Let's see if I can remember this without looking anything up this time...
pvcreate /dev/new_drive vgextend vg_name /dev/new_drive lvextend lv_name -l 100%FREE
Dang, I forget the ones to extend the file system
-
@travisdh1 My problem is
LVS
andVGS
displays the right amout of space.PVS
displays twoPV's
in the sameVG
, both at 1.95TB but nothing is listed asVFree
.vgs
lvs
pvs
df -h
-
Have you expanded the filesystem yet?
-
resize2fs /dev/mapper/centos-root
[root@localhost ~]# resize2fs /dev/mapper/centos-root 3.91T
resize2fs 1.42.9 (28-Dec-2013)
resize2fs: Bad magic number in super-block while trying to open /dev/mapper/centos-root
Couldn't find valid filesystem superblock. -
That's not good. Try it with the -p flag.
-
What filesystem do you have? Could it be XFS?
-
If XFS the command syntax is...
xfs_growfs /mount/point -D size
-
It's XenServer, we are expecting EXT4 here, right?
-
@scottalanmiller Correct
-
Is this improper syntax?
-
@wirestyle22 said in Attempting to increase the size of a Linux LVM Disk:
Is this improper syntax?
Try +3.91.
Also, why not have the data on its own volume? It's more flexible that way.
-
If the +doesn't work you will have to add it to the existing size. So if its 5TB it would be 8.91