100% found this document useful (2 votes)
722 views

LVM Snapshot Concepts and Mechanism

This document discusses LVM snapshot concepts and mechanisms including: 1. Volume group snapshots which allow splitting a volume group into a new volume group containing snapshot copies of logical volumes. 2. Logical volume snapshots which use the splitlvcopy command to split a logical volume copy into a new snapshot logical volume. 3. JFS2 filesystem snapshots which use the snapshot command to create a snapshot logical volume associated with an original filesystem for backup purposes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (2 votes)
722 views

LVM Snapshot Concepts and Mechanism

This document discusses LVM snapshot concepts and mechanisms including: 1. Volume group snapshots which allow splitting a volume group into a new volume group containing snapshot copies of logical volumes. 2. Logical volume snapshots which use the splitlvcopy command to split a logical volume copy into a new snapshot logical volume. 3. JFS2 filesystem snapshots which use the snapshot command to create a snapshot logical volume associated with an original filesystem for backup purposes.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

LVM snapshot concepts and mechanism

Part_1: Volume Group snapshot


# mkvg -y mashvg hdisk1 hdisk3
# crfs -v jfs2 -g mashvg -m /mashfs -a size=128M
# mount /mashfs
# lslv -m fslv00
fslv00:/mashfs
LP PP1 PV1
0001 0097 hdisk3
0002 0098 hdisk3
0003 0099 hdisk3
0004 0100 hdisk3

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

TOTAL PPs FREE PPs FREE DISTRIBUTION


479
474
96..91..95..96..96
479
474
96..91..95..96..96

LPs
1
4

PPs PVs LV STATE


2
2 open/syncd
8
2 open/syncd

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

# splitvg -c 2 -y snapshotvg mashvg


** Note if "-i" option used in splitvg command, it will split the mirror copy of the
VG into a new volume group that can NOT be rejoined into the original.
# lsvg -o
rootvg
mashvg
snapshotvg
# lspv | grep -v None
hdisk0
00f825c01021b29b
hdisk1
00f825c0ba562243
hdisk3
00f825c04883788d
# lsvg snapshotvg | tail -3 | head -1
SNAPSHOT VG:
yes

rootvg
active
snapshotvg
active
mashvg
active
PRIMARY VG:

# lsvg mashvg | tail -3 | head -1


SNAPSHOT VG:
snapshotvg
# readvgda -v3 /dev/hdisk1 | grep -i snap
SNAPSHOT VG:
1
# readvgda -v3 /dev/hdisk3 | grep -i snap
SNAPSHOT VG:
0

mashvg

# lsvg -l mashvg
mashvg:
LV NAME
TYPE
loglv00
jfs2log
fslv00
jfs2

LPs
1
4

PPs PVs LV STATE


2
2 open/stale
8
2 open/stale

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

# grep -p mash /etc/filesystems


/mashfs:
dev
= /dev/fslv00
vfs
= jfs2
log
= /dev/loglv00
mount
= false
account
= false
/fs/mashfs:
dev
vfs
log
mount
check
account

= /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

256 Nov 15 08:15 lost+found

# echo "the first copy" >file1.txt


# cat file1.txt
the first copy
# cd /fs/mashfs
# ls -l
drwxr-xr-x 2 root

system

256 Nov 15 08:15 lost+found

# echo "the second copy" >file1.txt


# cat file2.txt
the second copy
# df | grep mash
/dev/fslv00
/dev/fsfslv00

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

TOTAL PPs FREE PPs


479
474
479
474

LPs
1
4

PPs PVs LV STATE


2
2 open/syncd
8
2 open/syncd

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

15 Nov 15 09:20 file1.txt

Part_2: Logical Volume snapshot


# lsvg -l mashvg
vg00:
LV NAME
TYPE
loglv02
jfs2log
fslv08
jfs2

LPs
1
4

PPs PVs LV STATE


2
2 open/syncd
8
2 open/syncd

MOUNT POINT
N/A
/mashfs

# splitlvcopy -y <new_lv> <original_lv> copies


The 'copies' parameter determines the number of copies of the Logical Volume to
Remain after the split. For example, if orig_lv has 3 copies before the split, and
The 'copies' parameter is 2, orig_lv will have 2 copies after the split and new_lv will
have 1 copy.
# splitlvcopy -y snaplv fslv08 1
splitlvcopy: WARNING! The logical volume being split, fslv08, is open.
Splitting an open logical volume may cause data loss or corruption
and is not supported by IBM. IBM will not be held responsible for
data loss or corruption caused by splitting an open logical volume.
Do you wish to continue? y(es) n(o)? y
snaplv
# lsvg -l vg00
vg00:
LV NAME
loglv02
fslv08
snaplv

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

PPs PVs LV STATE


2
2 open/syncd
4
1 open/syncd
4
1 closed/syncd

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

jfs2 Dec 20 04:24 rw,log=/dev/loglv02

Part_3: jfs2 snapshot


# snapshot -o snapfrom=/mashfs -o size=128M
It will create a new snapshot logical volume (eg: fslv01).
To mount the new snapshot:
# mkdir /mysnap
# mount -o snapshot /dev/fslv01 /mysnap
- We can backup the snapshot filesystem using the below:
# cd /mysnap
# find . | backup -iqvf backup_device_or_file
- To create snapshot and back it up in one operation:
# backsnap -m /mysnap -s size=128M -i -f backup_device /mashfs
- To delete the snapshot logical volume:
# umount /mysnap -----> if mounted
# snapshot -d /dev/fslv01 (snapshot logical volume)

Thank you,
Mash
Ahmed Mashhour
Global AIX SME, EMEA TSS AIX Technical Lead
[email protected]

You might also like