https://www.youtube.com/watch?v=bWVmcCsQVzU

Step1. Add drive

Add one extra  drive in VMware workstation VM
Create LVM drives using below commands and save it
 
fdisk /dev/sdb
Reboot the Machine..

Step2. Create lvm partition

Create Physical Volume
pvcreate   /dev/sdb5  
 
Create Volume Group
vgcreate vgdata  /dev/sdb5  
 
Run command  to verify Volume group
vgs
 
Create Logical Volume
lvcreate -L +1GB -n lvdata vgdata  
 
Format LVM Partition
mkfs.ext4  /dev/mapper/vgdata-lvdata
 
Create a Directory
mkdir /u01
 
Mount LVM Partition
mount /dev/vgdata/lvdata /u01/

df -h
 
Create files in mounted Directory
cd /u01
 
touch files{0..999}    
Reboot  the Machine..

Step3. Creating Snapshot

Check the LVM partition with data
df -h   
 
Mount the LVM Partition and try again
mount /dev/vgdata/lvdata /u01/
df -h
 
Create Snapshot
lvcreate --snapshot --size 100m --name mysnap vgdata/lvdata
df -h
mkdir /snap
mount /dev/mapper/vgdata-mysnap   /snap
df -h
ls /snap
Reboot the Machine..

Step4. Delete volume

Delete file from LVM Partiotn Run below commands 
cd /u01
rm -f files*  
ls /u01
Reboot Machineā€¦

Step5. Recover data from snapshot drive

Unmount LVM Partition
umount /u01
 
Unmount Snapshot Partition
umount /snap
 
Recover data from Snapshot drive using below command
lvconvert --merge /dev/mapper/vgdata-mysnap

Step6. Mount LVM Partition

lvchange -a n /dev/mapper/vgdata-lvdata 
lvchange -a y /dev/mapper/vgdata-lvdata 
mount /dev/mapper/vgdata-lvdata /u01/
 
df -h
Reboot the VM..

Step7. Mount LVM Partition

Mount the partition Again
mount /dev/mapper/vgdata-lvdata /u01/
df -h   (Check the sized and data)
cd /u01  
ls /u01

For Live Installation you may refer below youtube link:-

https://www.youtube.com/watch?v=bWVmcCsQVzU

LEAVE A REPLY

Please enter your comment!
Please enter your name here