I'm curious if it is possible to create a snapshot of (e.g.) 10G volume, and then resize the snapshot to be 20G, along with the file-system within?
Using lvresize
or lvextend
only alters the COW-table size, the LV Size remains at 10G, and subsequently attempting to resize the file-system fails. E.g.
# lvextend --size 20G --resizefs /dev/vg_data/bigsize_test
fsck from util-linux 2.20.1
e2fsck 1.42 (29-Nov-2011)
/dev/mapper/vg_data-bigsize_test: clean, 27/655360 files, 85571/2621440 blocks
Extending logical volume bigsize_test to 20.00 GiB
Logical volume bigsize_test successfully resized
resize2fs 1.42 (29-Nov-2011)
The containing partition (or device) is only 2621440 (4k) blocks.
You requested a new size of 5242880 blocks.
fsadm: Resize ext4 failed
fsadm failed: 1
This leaves the snapshot with a big COW-table size
, but not a big LV Size
which is what I was aiming for:
# lvdisplay /dev/vg_data/bigsize_test
--- Logical volume ---
LV Name /dev/vg_data/bigsize_test
VG Name vg_data
LV UUID 77uCVJ-Sdml-KlQS-xGkS-mPiT-ITzU-0i7Zwi
LV Write Access read/write
LV snapshot status active destination for /dev/vg_data/origin
LV Status available
# open 0
LV Size 10.00 GiB
Current LE 2560
COW-table size 20.00 GiB
COW-table LE 5120
Allocated to snapshot 0.00%
Snapshot chunk size 4.00 KiB
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 252:30
Is it possible to make a snapshot bigger than its origin?
Am LVM2 snapshot isn't a clone, it's just keeps track of the state of the snapshotted partition at the time. If it was 10GB, you can't just change that. If you want to create a larger copy of the content of a partition at a certain time, just make a new 20GB volume, and copy the snapshot over. It is good to be clear (to yourself and others) what you want to achieve.