2

I'm looking for a good tutorial on making a LVM snapshot on Ubuntu Server. I can't find one that isn't way too in depth about what LVM is or I can't find one that is up to date. My ultimate goal is to learn how to make snapshots of my server with LVM so I can return to previous states if I need to.

Also I looked at the volume groups and logical volumes on a clean install of Ubuntu Server 16 in a VM. It looks like there is already an LVM. This is where I got confused.

Could somebody provide a link to a good tutorial for that? Am I completely misunderstanding what LVM is? Thanks for the help!

0

1 Answer 1

4

What is a snapshot?

snapshots are a facility which makes us able to create a new block device (like /dev/My-vg/snapshot_home ) which presents an exact copy of a logical volume frozen at some point in time. After we are done with what we are doing, we can simply remove the snapshot device.

Important to note while creating a snapshot:
While creating a snapshot we should consider enough disk space for our changes, if our changes makes snapshot device space full then it will be dropped and becomes unusable.

When to use it?
Some times we need to install an application or run a program we don't know what it's going to happens or in any situations that makes any changes to our files we can setup a snapshot device, if we were not happy with the change we can simply make everything same as the time we created our snapshot.

How to create a snapshot

To create a snapshot we can use a command like:

lvcreate -s -n  home_snap -L 1G /dev/My-vg/home
  • -s is for snapshot
  • -n home_snap is the name of our new logical volume (snapshot device)
  • L 1G is the size of our snapshot, so it supports to 1GB of changes (remember the above important note).
  • /dev/mapper/my--vg-home is the logical volume that I want to create a snapshot of.

then use sudo lvs to get a list of your logical volumes you should see your newly created snapshot device.

Note that you should have enough free space on your volume group to create a new snapshot.

sources: 1, 2

Not the answer you're looking for? Browse other questions tagged .