Recording and restoring logical volume snapshots in LVM (part 3)
The LVM snapshot is a copy of the lvm volume created by changing the space time. It only works in lvm and only occupies the space of the snapshot volume when the source logical volume changes. If the source volume changes to 1 GB, the snapshot volume also changes. Therefore, the best way to make effective use of space is to always make small changes. If snapshots consume up storage space, you can use lvextend to resize it. If we need to reduce the volume occupied by the snapshot, we can use lvreduce.
Recording snapshots in LVM
If any file is accidentally deleted after a snapshot is created, we do not need to worry because the snapshot contains the original file of the file we deleted. When creating a snapshot, it is very likely that the file already exists. Do not change the snapshot volume to keep it as it is used for fast recovery.
Snapshot cannot be used for backup options. Backup is the basic copy of some data, so we cannot use snapshots as a backup option.
Pre-reading
- Use LVM to create elastic disk storage-Part 1
- Expanding/downgrading LVM in Linux (Part 2)
- Recording and restoring logical volume snapshots in LVM (part 3)
My server settings
- Operating System-CentOS 6.5 with LVM installed
- Server IP-192.168.0.200
Step 1: Create an LVM Snapshot
First, run the 'vgs 'command to check the free space in the volume group to create a new snapshot.
- # Vgs
- # Lvs
Check LVM disk space
As you can see, 8 GB of free space is available in the vgs command output. Therefore, let's create a snapshot for my volume named tecmint_datas. For demonstration purpose, I will use the following command to create a 1 GB snapshot volume.
- # Lvcreate-L 1 GB-s-n tecmint_datas_snap/dev/vg_tecmint_extra/tecmint_datas
Or
- # Lvcreate -- size 1G -- snapshot -- name tecmint_datas_snap/dev/vg_tecmint_extra/tecmint_datas
The two commands above are both doing the same thing:
- -S-create a snapshot
- -N-name the snapshot
Create an LVM Snapshot
Here is a description of the highlighted points above.
- The size of the snapshot I created here.
- Create a snapshot.
- The name of the created snapshot.
- The new snapshot name.
- The volume to create the snapshot.
If you want to remove a snapshot, you can use the 'lvdelete' command.
- # Lvremove/dev/vg_tecmint_extra/tecmint_datas_snap
Disk management-LVM
Linux Tutorial: Use LVM logical volume manager to manage flexible storage
Configure LVM (logical volume management) in CentOS 6.3)
Linux LVM (Logical Volume Manager) Study Notes
LVM-snapshot: LVM snapshot-based backup preparation
LVM-snapshot: LVM-based snapshot Backup
RHEL5.9 LVM usage
For more details, please continue to read the highlights on the next page: