LVM Snapshot Concepts and Mechanism
LVM Snapshot Concepts and Mechanism
PP2 PV2
PP3 PV3
# mklvcopy fslv00 2
# mklvcopy loglv00 2
# syncvg -v mashvg
# lsvg -p mashvg
mashvg:
PV_NAME
PV STATE
hdisk1
active
hdisk3
active
# lsvg -l mashvg
mashvg:
LV NAME
loglv00
fslv00
TYPE
jfs2log
jfs2
LPs
1
4
MOUNT POINT
N/A
/mashfs
# lslv -m fslv00
fslv00:/mashfs
LP PP1 PV1
0001 0097 hdisk3
0002 0098 hdisk3
0003 0099 hdisk3
0004 0100 hdisk3
PP2 PV2
0097 hdisk1
0098 hdisk1
0099 hdisk1
0100 hdisk1
PP3 PV3
# lslv -m loglv00
loglv00:N/A
LP PP1 PV1
0001 0101 hdisk3
PP2 PV2
0097 hdisk1
PP3 PV3
rootvg
active
snapshotvg
active
mashvg
active
PRIMARY VG:
mashvg
# lsvg -l mashvg
mashvg:
LV NAME
TYPE
loglv00
jfs2log
fslv00
jfs2
LPs
1
4
MOUNT POINT
N/A
/mashfs
# lsvg -l snapshotvg
snapshotvg:
LV NAME
TYPE
LPs PPs PVs LV STATE
fsloglv00
jfs2log 1
1 1 closed/syncd
fsfslv00
jfs2
4
4 1 closed/syncd
MOUNT POINT
N/A
/fs/mashfs
= /dev/fsfslv00
= jfs2
= /dev/fsloglv00
= false
= false
= false
# mount /fs/mashfs
Replaying log for /dev/fsfslv00.
# cd /mashfs
# ls -l
drwxr-xr-x 2 root
system
system
262144
262144
261440
261440
1%
1%
5
5
1%
1%
/mashfs
/fs/mashfs
261440
1%
1%
/mashfs
# umount /fs/mashfs
# df | grep mash
/dev/fslv00
262144
# joinvg mashvg
# lsvg -o
rootvg
mashvg
# lsvg -p mashvg
mashvg:
PV_NAME
PV STATE
hdisk1
active
hdisk3
active
# lsvg -l mashvg
mashvg:
LV NAME
TYPE
loglv00
jfs2log
fslv00
jfs2
LPs
1
4
FREE DISTRIBUTION
96..91..95..96..96
96..91..95..96..96
MOUNT POINT
N/A
/mashfs
# cd /mashfs
# ls -ltr
-rw-r--r-- 1 root
system
# cat file1.txt
the first copy
# umount /fs/mashfs
# varyoffvg snapshotvg
# exportvg snapshotvg
LPs
1
4
MOUNT POINT
N/A
/mashfs
TYPE
jfs2log
jfs2
jfs2
# lslv -m fslv08
fslv08:/mashfs
LP PP1 PV1
0001 0130 hdisk26
0002 0131 hdisk26
0003 0132 hdisk26
0004 0133 hdisk26
LPs
1
4
4
PP2 PV2
PP3 PV3
MOUNT POINT
N/A
/mashfs
N/A
# lslv -m snaplv
snaplv:N/A
LP PP1 PV1
0001 0130 hdisk27
0002 0131 hdisk27
0003 0132 hdisk27
0004 0133 hdisk27
PP2 PV2
PP3 PV3
- splitlvcopy command can split logical volumes that are open (containing mounted
filesystems),
But this is not recommended as it may lose consistency with if multiple processes are
using it
Simultaneously. When splitting an open logical volume, there is a potential risk of data
loss.
To avoid this risk, close logical volumes before splitting and unmount filesystems before
splitting.
- Now, we can create new mount point for snaplv (mkdir /snapfs), and add entries in
/etc/filesystems:
/snapfs:
dev
= /dev/snaplv
vf
= jfs2
log
= /dev/loglv02
mount
= true
account
= false
- Then, we can check the correctness of the entries:
# lsfs | grep -i snap
/dev/snaplv -- /snapfs
jfs2 262144
-# fsck -y /snapfs
The current volume is: /dev/snaplv
Primary superblock is valid.
*** Phase 1 - Initial inode scan
*** Phase 2 - Process remaining directories
*** Phase 3 - Process remaining files
*** Phase 4 - Check and repair inode allocation map
*** Phase 5 - Check and repair block allocation map
File system is clean.
Superblock is marked dirty (FIXED)
yes no
# mount /snapfs
# df | grep -i snap
/dev/snaplv
262144
# mount | grep -i snap
/dev/snaplv /snapfs
261448
1%
1% /snapfs
Thank you,
Mash
Ahmed Mashhour
Global AIX SME, EMEA TSS AIX Technical Lead
[email protected]