Disk Cloning With Splitvg

In a recent post, Low-impact database clone with splitvg, Anthony English used the splitvg command to clone a database. I hadn’t thought of the splitvg command since playing with it when it was first announced in the Differences Guide for AIX 5.2 (?). As luck I was building a new LPAR that is a copy of an already existing LPAR. I don’t strictly NEED the files in the filesystems copied to the new LPAR, but I do need the filesystems. But getting the files might save the application analysts some time.  So, I decided to break out the old splitvg command.

Luckily, I had a spare LUN assigned to this LPAR that was available. The first step was to simply extend the VG to the new disk, and run mirrorvg. After everything was synced up, the split was painless and only took a few seconds:

splitvg -y copyvg -i -c 2 cernervg

After that, the new VG shows up:

# lspv
...
hdisk10         00043a1267585862                    cernervg        active
hdisk11         00043a1267650a54                    copyvg          active
...

And, you can look at the LVs with lsvg:

# lsvg -l copyvg
copyvg:
LV NAME             TYPE       LPs     PPs     PVs  LV STATE      MOUNT POINT
fscernerlv          jfs2       8       8       1    closed/syncd  /fs/fs/cerner
fscernerwhlv        jfs2       1       1       1    closed/syncd  /fs/fs/cerner/w_standard
...

For some odd reason, the filesystems were created with the prefix "/fs/fs". They should have been created with just the "/fs" prefix, but I'll fix that later anyway.

Then I did a varyoffvg and exportvg on the source LPAR, presented the LUN to the target LPAR, and ran cfgmgr on the target. After that, the disk showed up, with the same PVID as before:

 # lspv
hdisk0          000439c25388aca6                    rootvg          active
hdisk1          00043a1267650a54                    None

A quick importvg, and we're in business:

# importvg -y cernervg hdisk1

But, the filesystems still have the "/fs/fs" prefix. So, a quick and dirty script cleans that up:

for fs in `lsvg -l cernervg | grep fs | awk '{ print $7 }' | cut -d'/' -f 4-`
do
chfs -m /$fs /fs/fs/$fs
done

And, the LVs still have the "fs" prefix, I could leave them, but my OCD won't let me:

for fs in `lsvg -l cernervg | grep fs | awk '{ print $1 }' | cut -d's' -f 2-`
do
chlv -n $fs fs$fs
done

Then I used "mount -a" to mount all the filesystems. They had to replay the JFS2 logs, but since they didn't have much in the way of writes going on when I ran the splitvg, they were fine.

Overall, it wasn't a bad way to go. The mirrorvg took a while to complete, and fixing the names for the LVs and filesystems took a little work, but not bad. It's better than creating all the filesystems by hand.

If I really wasn't concerned about the data, I could have use the savevg and restvg command to recreate the filesystems onto a blank LUN faster with less effort.

Leave a Reply

Your email address will not be published. Required fields are marked *

*
*