Snapshoting can be useful if you need to take a backup of a filesystem but want the filesystem to be a quiesced state when you do so. Using LVM and snapshots you just backup the snapshot of the original filesystem.
First lets create the “master” filesystem using /dev/sdc1 which has partitioned as Linux LVM in fdisk.
So create the physical volume
Then create a volume group containing the physical volume
>vgcreate test_vg /dev/sdc1
Then create a logical volume called v1 which is 5gb in size. Note that this volume group is 10gb in total size.
>lvcreate -n v1 -L 5G test_vg
Then create a filesystem on that volume
>mkfs -t ext4 /dev/test_vg/v1
Then mount this volume to /v1 and put some data in it.
>mount /dev/test_vg/v1 /v1
>cp /var/tmp/VMwareTools-8.3.2-257589.tar /v1
Ok, now that we have a logical volume with some data in it, lets make a snapshot of it.
First lets make a mountpoint for our snapshot
Now lets make the snapshot of /dev/test_vg/v1. Note that a snapshot volume can be as large or a small as you like but it must be large enough to hold all the changes that occur on the original volume during the lifetime of the snapshot. In this example I am creating a snapshot of 4gb.
>lvcreate -n snapvol -L 4G -s /dev/test_vg/v1
Using lvs or lvscan you can take a look at the snapshot volume.
ACTIVE Original ‘/dev/test_vg/v1’ [5.00 GiB] inherit
ACTIVE Snapshot ‘/dev/test_vg/snapvol’ [4.00 GiB] inherit
Now lets mount the snapshot readonly.
>mount -o ro /dev/test_vg/snapvol /v2
Now you can browse the contents of the snapshot, unmount it and mount it as needed. And back it up as well. Make sure that you remove the snapshot when done backing it up