Creating an AMI image with lvm2 defined physical volumes, logical volumes, volume groups, and filesystems

0

I created an AMI image that used lvm2 to create physical volumes, logical volumes, volume groups, and filesystems. I expected when I launched a new instance from the AMI, the lvm defined physical volumes, volume groups, and filesystems would transfer. However, only the non-lvm defined filesystems were created in the new EC2 instance. When creating/launching an image, are there additional steps to follow to preserve the lvm defined data? Thanks

1개 답변
1
수락된 답변

Is the problem that any LVM commands like pvdisplay or vgs etc. always come back with an error of the form Devices file sys_wwid nvme.1d0f-[big_long_random_string] PVID [shorter_random_string] last seen on /dev/sdb not found. ? I hope it is, because that's the behaviour I've managed to replicate :-)

Not sure whether to call this a fix, or a workaround, or a hack, but anyway what you need to do ensure use_devicesfile = 0 is present in /etc/lvm/lvm.conf on the instance from which the AMI is created, and then create a fresh AMI with this entry in place.

sed -i 's/# use_devicesfile = 0/use_devicesfile = 0/' /etc/lvm/lvm.conf

See comment #8 of https://bugzilla.redhat.com/show_bug.cgi?id=2072201

I tested with an entry in /etc/fstab for an filesystem on an LVM volume, and it mounts the first time a new EC2 is booted from the AMI, with no manual intervention required.

profile picture
전문가
Steve_M
답변함 5달 전
  • ^^^ this is pure gold. I had multiple lvm modules in my fstab and that was fine on the instance I made them on. When I made an AMI from that instance, the new ec2 would not stand up and this was the fix for that. many thanks

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠