dropdown menu


SNAPSHOT - VG,LV:


VOLUME GROUP SNAPSHOT (splitvg, joinvg)

Splitvg turns a mirror copy of the volume group into a snapshot. LVs (and filesystems) in this new snapshot will receive an 'fs' prefix and /etc/filesystems will be updated with this mount point information. These new snapshot filesystems then can be mounted and backed up and after this vg can be rejoined with the original vg. (Or this snapshot vg can be used to move data to another system.)

Splitvg behind the scenes uses recreatevg, and it splits a volume group by mirror copy, not by physical volume. (It means all LV copies should match with each other, so 1st and 2nd copies should be not mixed up on the physical disks, these should be on separate disks.) After issuing splitvg, the original volume group will stop using the disks that are now part of the snapshot volume group.

While the volume group is split, it still looks like a mirrored vg, however any updates to it will result in stale logical volumes.

For example, if you copy some data into the original filesystem, the logical volume and JFSlog logical volume go stale. This is because the mirror is still associated with the original volume group, even when split off to a temporary new volume group. (splitvg -i will create an independent volume group which do not have this side effect, but it cannot be rejoined later.)

----------------------------

Splitting a volume group and after joining it to the original:
With these commands 1 side of a mirror is taken away, a new volume group is created and later it is joined with the original volume group.

0. lsvg -l origvg; lslv -m <lv>         <--check if VG (LV) mirror is correct (every lv should be mirrorred)
1. splitvg -y snapvg -c 2 origvg        <--2nd copy (-c 2) of the volume group origvg is turned into a new volume group (-y snapvg)
2. lsvg -p origvg                       <--it shows status of the disks (snapshotpv) in origvg (snapvg can be checked with lsvg <vg> as well)
   PV_NAME      PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
   hdisk0       active            405         396         81..72..81..81..81
   hdisk1       snapshotpv        405         396         81..72..81..81..81

3. mount /fs/origfs                     <--fs in snapvg can be mounted (it received an 'fs' prefix) (data in fs can be backed up)
4. umount /fs/origfs                    <--umount this fs in snapvg
5. joinvg origvg                        <--rejoin snapshot volume group to the original vg (snapvg will be removed from the system)
6. syncvg -v origvg                     <--if needed synchronize pp in the newly mirrorred vg ('lsvg -l origvg' will show if lv is staled)

----------------------------

Splitting a volume group that cannot be rejoined after into the original:
With these commands an independent volume group will be created, which will be exported and it will be moved to another system.
(using splitvg -i, will create a vg that can not be rejoined into the original later)

0. lsvg -l origvg; lslv -m <lv>         <--check if VG (LV) mirror is correct (every lv should be mirrorred)
1. splitvg -y newvg -i -c 2 origvg      <--2nd copy (-c 2) of origvg is turned into a new independent (-i) volume group (-y newvg)
2. lsvg -p origvg                       <--it will show only 1 disk (newvg is created as an independent vg)
   PV_NAME      PV STATE          TOTAL PPs   FREE PPs    FREE DISTRIBUTION
   hdisk0       active            405         396         81..72..81..81..81

3. varyoffvg newvg; exportvg newvg      <--varyoff and export this newly created vg
4. rmdev -dl hdiskX                     <--remove disks related to newvg from system (from ODM)
5. rmvdev...; mkvdev...                 <--on VIOS: remove mapping from LPAR and create new mapping to a new LPAR
6. cfgmgr; importvg -y newvg hdiskX     <--configure new disk and import this new volume group

----------------------------

# splitvg -y snapvg -c 2 origvg
0516-1359 splitvg: The mirror specified to split the volume group must exists on a disk or
        set of disks that contains nothing but this mirror.
0516-1355 splitvg: Unable to split the volume group.


This error means that for example 1st copy of a logical volume is mixed up on a disk, where there are 2nd copies of another logical volume.
(splitvg splits a volume group by mirror copy)

1. lsvg -M origvg                      <--it will show lv layout on disks (lslv -m <lv> could be better with large lists)
hdisk0:82       loglv00:1:1            <--it shows that on hdisk0 there are 1st and 2nd copies of different lvs
hdisk0:83       origlv:1:2
hdisk0:84       origlv:2:2
hdisk0:85       origlv:3:2
...
hdisk1:82       loglv00:1:2            <--same with hdisk1
hdisk1:83       origlv:1:1
hdisk1:84       origlv:2:1
hdisk1:85       origlv:3:1

2. rmlvcopy loglv00 1 hdisk0           <--remove 1st copy of loglv00 from hdisk0
                                       (on hdisk1 it will be changed automatically from 2nd copy to 1st copy)

3. mklvcopy loglv00 2 hdisk0           <--create 2nd copy on the correct disk (sync may needed), after that splitvg was successful

----------------------------
----------------------------
----------------------------
----------------------------
----------------------------

LOGICAL VOLUME SNAPSHOT (splitlvcopy)

splitlvcopy removes a copy from a Logical Volume and uses it to create a new Logical Volume. The new Logical Volume will have the same characteristics as the original one.

splitlvcopy -y <new_lv> <orig_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 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.

The splitlvcopy command is not allowed on a snapshot volume group or a volume group that has a snapshot volume group.

----------------------------

Splitlvcopy that contains a filesystem:

After the split there will be two logical volumes but there will only be one entry in the /etc/filesystems (with the original lv). To access new Logical Volume as a filesystem an additional entry must be created in /etc/filesystems. (If the mount point does not already exist, it must be created before the new filesystem can be mounted.)

1. mkdir /newfs                      <--create mount point for the new filesystems if needed

2. splitlvcopy -y newlv origlv 1     <--it will create a new logical volume (newlv) by leaving only 1 copy of origlv
                            (origlv can have a mounted filesystem, but to avoid potential data loss umount is suggested)
3. lsvg -l origvg                    <--newlv will be created, but it will be closed and no fs (mount point) will be associated with it

   LV NAME      TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
   origlv       jfs2       5       5       1    open/syncd    /origfs
   newlv        jfs2       5       5       1    closed/syncd  N/A

4. vi /etc/filesystems                <--edit /etc/filesystems, and create a /newfs stanza (copy /origfs and change fs name and dev)

   /origfs:
        dev             = /dev/origlv
        vfs             = jfs2
        log             = /dev/loglv00
        mount           = true
        check           = false
        options         = rw
        account         = false

   /newfs:
        dev             = /dev/newlv
        vfs             = jfs2
        log             = /dev/loglv00
        mount           = true
        check           = false
        options         = rw
        account         = false

5. fsck /dev/newlv                  <--fsck is needed on newlv before mounting (superblock should be updated with new info)

6. mount /newfs                     <--after mounting /newfs files will be available

----------------------------

1 comment: