1

Long story short: I'm trying to create a snapshot of a volume using lvcreate using the following command:

lvcreate -l 100%FREE -s -n SNAPSHOT /dev/volume-group/data

I get an error saying "Unable to create new logical volume with no extents." After some digging, I discovered that the volume group in question has no free space according to vgdisplay, even though df -h shows plenty of space available.

vgdisplay output:

--- Volume group --- VG Name volume-group System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 8 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 39.99 GiB PE Size 4.00 MiB Total PE 10238 Alloc PE / Size 10238 / 39.99 GiB Free PE / Size 0 / 0 VG UUID fP36on-3yzf-c8i2-bOzO-4Htf-txUa-k3y8p9 

df -h output:

Filesystem Size Used Avail Use% Mounted on udev 7.5G 0 7.5G 0% /dev tmpfs 1.5G 73M 1.5G 5% /run /dev/xvda1 62G 2.2G 60G 4% / tmpfs 7.5G 0 7.5G 0% /dev/shm tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 7.5G 0 7.5G 0% /sys/fs/cgroup tmpfs 1.5G 0 1.5G 0% /run/user/1000 /dev/mapper/volume--group--data 40G 17G 24G 43% /mnt/mysql 

I think what I'd need to do at this point is change the size of the logical volume containing /dev/volume-group/data to something a little bit larger than the current disk usage, take my snapshot, and then set it back to 40GB? But I'm not sure if that's the proper procedure or if I should be doing something else.

This is all happening in an AWS EC2 instance and the volume I'm trying to take a snapshot of is an EBS volume housing MySQL database data, in case those details matter.

2
  • Why do you want to take an LVM snapshot, instead of an EBS volume snapshot? Commented Apr 11, 2018 at 18:57
  • @Bob A snapshot taken within the VM after and XFS freeze is much more likely to achieve quiescence during an active transactional workload than shapshotting the backing storage. Commented Apr 16, 2018 at 15:04

1 Answer 1

1

LVM extent allocation and filesystems on top of logical volumes have no significant relationship. LVM commands operate on LVM, and don't care what you use logical volumes for.

You're trying to make a snapshot logical volume, which will require free extents in your volume group to create - a snapshot is really just another logical volume that backs up data as changes are made to the original volume.

Looking at this relevant line:

Free PE / Size 0 / 0

This says you don't have any room left over on your volume group to make another logical volume of any kind, which includes snapshots. One approach would be to shrink a logical volume to free up some extents on this VG. Shrinking your LV involves shrinking your filesystem first, as shrinking a logical volume without doing so would truncate the end of your filesystem and trash it. Thankfully, LVM can call out to most filesystem utilities to ensure a shrink happens first for the new target LV size - but make sure this is happening before you run with it.

Alternatively, you can resize an EBS volume and give yourself some additional physical extents. That's the easiest route, especially if you're using XFS which can't ever shrink.

5
  • Shrinking the filesystem seems like the best way to go for now; are there any pointers or tips on how to do this? I'm relatively new to all of this and could use a bit of hand-holding. Thanks! Commented Apr 11, 2018 at 18:51
  • What filesystem are you using? Commented Apr 11, 2018 at 18:52
  • The output of sudo blkid would show that nicely. Commented Apr 11, 2018 at 19:35
  • We're using xfs for that particular volume. So does that mean our only recourse is to resize the EBS volume? Commented Apr 12, 2018 at 15:50
  • That's correct. XFS simply cannot be shrunk, so you can either trash it and recreate it as a smaller LV or resize your EBS volume. Commented Apr 12, 2018 at 16:15

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.