- There is an os image file say
test.dd, and an LVM managed partition inside. - Enlarge the os image file size, then enlarge the partition size to full.
- Create a loopback device for
test.dd, then get the LVM managed partition device, such as/dev/loop0p1 - Activate the LVM VG(Volume Group), get an LV(Logical Volume) in it, such as
/dev/dm-1 - Enlarge PV(Physical Volume) size by
pvresize /dev/loop0p1 - Enlarge LV(Logical Volume) size by
lvextend -l +100%FREE /dev/dm-1
My questions are (actually just one: how can I safely copy the test.dd out to somewhere else):
- can I copy
test.ddout safely? (I don't care whethertest.ddin the disk has been physically flushed out, I just want to copy it out to somewhere else, either from disk or file buffer). - or should I call
syncbefore copy? - or should I detach the loopback device before copy?
- what if failed to detach the loopback device anyway?
EDIT: I am reluctant to call sync command because it sometimes it is very slow and become uninterruptible(i.e., kill -9 does not work then).
EDIT: The reason I ask the question is that I have experienced issues of data inconsistency related to loopback device and the backing file in other cases.
EDIT: For now, I use a script which call vgchange --activate n --select vg_uuid=$LVM_VG_UUID to deactivate the Volume Group, then losetup --detach /dev/loop0, followed by an udevadm settle then I started to copy the test.dd out. I just wonder whether I can copy the test.dd out without such hassle.
EDIT: sorry for wrong input for the order of command. It actually is vgchange --activate n --select vg_uuid=$LVM_VG_UUID -> udevadm settle -> losetup --detach /dev/loop0 -> cp test.dd ...