2

I'm trying to configure a CentOS HA system with 2 nodes, with DRBD for replicated storage. I'm following the "Clusters from Scratch" guide, and at the DRBD portion, I need to create a partition for DRBD, and I'm running into some problems

First of all, vgdisplay shows 0 free space

  --- Volume group ---
  VG Name               centos
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                3
  Open LV               3
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               931.02 GiB
  PE Size               4.00 MiB
  Total PE              238341
  Alloc PE / Size       238341 / 931.02 GiB
  Free  PE / Size       0 / 0   
  VG UUID               c2Vgsy-6GNs-f3sq-rkA9-tPVq-7ie8-ElyJeC

Hence, when I try to do a lvcreate, I get the error message "Volume group "centos" has insufficient free space (0 extents): 256 required."

My CentOS 7 installation is with GUI, and df shows the following:

Filesystem              1K-blocks    Used Available Use% Mounted on
/dev/mapper/centos-root  52403200 7587668  44815532  15% /
devtmpfs                 12196412       0  12196412   0% /dev
tmpfs                    12205536   54800  12150736   1% /dev/shm
tmpfs                    12205536   25532  12180004   1% /run
tmpfs                    12205536       0  12205536   0% /sys/fs/cgroup
/dev/sda1                  505580  204620    300960  41% /boot
/dev/mapper/centos-home 911041916  576192 910465724   1% /home
/dev/sdb1                 7815240 3310764   4504476  43% /run/media/root/0935-41EE

There's plenty of space being used by /dev/mapper/centos-home. How do I carve out some space to create a new partition?

2
  • Managing LVMs in CentOS This should fix you up real nice! Commented Oct 1, 2014 at 3:00
  • What is the filesystem on /home? Have you looked at shrinking that filesystem first, so you can do a lvreduce to free up space in the volume group? Commented Oct 1, 2014 at 3:05

2 Answers 2

2

When pv/vg/lvdisplaying, you may find the -C option helpful. Most of the time, we only need to see what it tells us; eg lvdisplay -C .

When you resize2fs and lvresize (or lvreduce), make sure your resize2fs gives you a volume SMALLER than your lvresize command gives. Very occasionally, if you don't have the FS smaller than the LV by a tiny amount, bad things happen. When your LV is the right size, you can expand the FS to fill it with a simple 'resize2fs /dev/centos/home' (with no other options).

Fox XFS, that answer isn't the same. You cannot resize XFS, and it's a huge drawback for a small speed increase. Your option then is to make a new filesystem, copy everything over to it, and delete the old filesystem. If you don't have spare space on your host, you will need to get creative.

Throw us the results of a 'mount' command, and with what we have here already, someone can maybe help you out.

3
  • Yup, a quick google search seems to indicate that XFS cannot be shrunk, only grown. Actually, what's in the /home partition? If it's just data files (not installed applications, services, configuration files, etc), then I don't mind losing it and just creating a new non XFS partition. I'm going to be running mostly as a root user anyway Commented Oct 2, 2014 at 2:42
  • 1
    Oh. And using the -r option to the lvresize will automatically run the proper resize2fs command and shrink the filesystem to match: e2fsck blah blah lvresize -r -l-10%LV /dev/data/home .. and the -r makes it do the right thing. Commented May 7, 2015 at 17:00
  • There's also the easier option: boot a gparted live cd and use it to resize the volume. Commented Jan 16, 2017 at 21:22
0

There is plenty of space in your /home but this space is currently allocated to the centos-home logical volume, and cannot be used on another one.

You should either reduce or re-create centos-home to a smaller size to retrieve some unallocated space.

To reduce (assuming /home fs is ext4 and you want to set 100G for it):

 # umount /home 
 # e2fsck -f /dev/centos/home
 # resize2fs /dev/centos/home 100G
 # lvreduce -L 100G /dev/centos/home

to recreate (assuming xfs) :

first backup your data to some other place using "cp -r --preserve=all ..." or "tar --selinux --acls --xattrs -cvf ... " :

then:

 # umount /home 
 # lvremove /dev/centos/home
 # lvcreate -L 100G -n home centos 
 # mkfs.xfs /dev/centos/home

and then restore data

1
  • Thanks. It's actually xfs, not ext4. Would the command be the same? Commented Oct 2, 2014 at 1:26

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.