Top / Installmemo / zLinux / clone

トップ   編集 凍結 差分 バックアップ 添付 複製 名前変更 リロード   新規 一覧 単語検索 最終更新   ヘルプ   最終更新のRSS

導入済みのLinuxのクローンを作成する方法を述べる

クローン元環境およびクローン作業環境

VMユーザー名test01
使用DASDアドレス5801 5802 5803
OSSUSE Linux Enterprise Server 11 SP3 for System z

クローン先環境

VMユーザー名test02
使用DASDアドレス5901 5902 5903

DASDのコピー

コピー先DASDのAttach

# vmcp att 5901 test01
DASD 5901 ATTACHED TO TEST01 5901 WITH DEVCTL PAV BASE
# vmcp att 5902 test01
DASD 5902 ATTACHED TO TEST01 5902 WITH DEVCTL PAV BASE
# vmcp att 5903 test01
DASD 5903 ATTACHED TO TEST01 5903 WITH DEVCTL PAV BASE
# vmcp q v dasd
DASD 0190 3390 54ARES R/O        107 CYL ON DASD  551C SUBCHANNEL = 000B
DASD 0191 3390 54AW02 R/W         50 CYL ON DASD  5520 SUBCHANNEL = 0006
DASD 0193 3390 54AW01 R/O        167 CYL ON DASD  551F SUBCHANNEL = 000D
DASD 019E 3390 54AW01 R/O        250 CYL ON DASD  551F SUBCHANNEL = 000C
DASD 0592 3390 54AW02 R/O         70 CYL ON DASD  5520 SUBCHANNEL = 000E
DASD 5801 ON DASD  5801 R/W 0X5801 SUBCHANNEL = 0000
DASD 5802 ON DASD  5802 R/W 0X5802 SUBCHANNEL = 0001
DASD 5803 ON DASD  5803 R/W 0X5803 SUBCHANNEL = 0002
DASD 5901 ON DASD  5901 R/W 0X5901 SUBCHANNEL = 000F
DASD 5902 ON DASD  5902 R/W 0X5902 SUBCHANNEL = 0010
DASD 5903 ON DASD  5903 R/W 0X5903 SUBCHANNEL = 0011
# lsdasd -a
Bus-ID     Status      Name      Device  Type  BlkSz  Size      Blocks
==============================================================================
0.0.0190   offline
0.0.0191   offline
0.0.0193   offline
0.0.019e   offline
0.0.0592   offline
0.0.5901   offline
0.0.5902   offline
0.0.5903   offline
0.0.5801   active      dasda     94:0    ECKD  4096   7043MB    1803060
0.0.5802   active      dasdb     94:4    ECKD  4096   7043MB    1803060
0.0.5803   active      dasdc     94:8    ECKD  4096   7043MB    1803060

コピー実行

# vmcp flashcopy 5801 0 END TO 5901 0 END
Command complete: FLASHCOPY 5806 0 10016 TO 5906 0 10016
# vmcp flashcopy 5802 0 END TO 5902 0 END
Command complete: FLASHCOPY 5807 0 10016 TO 5907 0 10016
# vmcp flashcopy 5803 0 END TO 5903 0 END
Command complete: FLASHCOPY 5808 0 10016 TO 5908 0 10016

コピー完了確認

# vmcp q v flashcopy
VDEVN SSID LSS UA CU   SERIAL       ACTIVE    MAX PPRC
0190  5500  55 1C 2107 0000000YA941      0  50099
0191  5500  55 20 2107 0000000YA941      0  50099
0193  5500  55 1F 2107 0000000YA941      0  50099
019E  5500  55 1F 2107 0000000YA941      0  50099
0592  5500  55 20 2107 0000000YA941      0  50099
5801  5800  58 06 2107 0000000YA941      0  65534
5802  5800  58 07 2107 0000000YA941      0  65534
5803  5800  58 08 2107 0000000YA941      0  65534
5901  5900  59 06 2107 0000000YA941      0  65534
5902  5900  59 07 2107 0000000YA941      0  65534
5903  5900  59 08 2107 0000000YA941      0  65534

VG名の変更

DASDをコピーしたクローン先のDASDをマウントするがVG名が競合するとマウントできない。そこで、VG名の変更を実施する。
作業はシングルユーザーモード(ランレベル1)にて行う。

# init 1

test01側のVG名を変更する

# vgrename test01vg test01tvg
# vgchange -u test01tvg
# pvchange -u /dev/dasda3
# pvchange -u /dev/dasdb1
# pvchange -u /dev/dasdc1

コピー先のtest02側のDASDを有効化するが、VG名はtest01用のためtest02用VG名の変更を行う。
DASDのonline

# chccwdev -e 5906
# chccwdev -e 5907
# chccwdev -e 5908

test02側のVG名を変更する。

# pvscan
# vgrename test01vg test02vg
# vgchange -u test02vg
# pvchange -u /dev/dasdd3
# pvchange -u /dev/dasde1
# pvchange -u /dev/dasdf1

VG名の変更が完了したらランレベルを3に移行する

# init 3

test02用の設定

test02側の設定を行うためにtest01にファイルシステムをマウントする。

  • test02側のPhysical volumeの確認
    test01:~ # pvscan
      PV /dev/dasdd3   VG test02vg   lvm2 [4.38 GiB / 0    free]
      PV /dev/dasde1   VG test02vg   lvm2 [6.88 GiB / 0    free]
      PV /dev/dasdf1   VG test02vg   lvm2 [6.88 GiB / 4.00 MiB free]
      PV /dev/dasda3   VG test01vg   lvm2 [4.38 GiB / 0    free]
      PV /dev/dasdb1   VG test01vg   lvm2 [6.88 GiB / 0    free]
      PV /dev/dasdc1   VG test01vg   lvm2 [6.88 GiB / 4.00 MiB free]
      Total: 6 [36.25 GiB] / in use: 6 [36.25 GiB] / in no VG: 0 [0   ]
  • test02側VGの有効化
    test01:~ # vgchange -ay test02vg
      5 logical volume(s) in volume group "test02vg" now active
  • test02側ファイルシステムのマウント
    test01:/tmp # mount /dev/dasdd2 /tmp/test02/
    test01:/tmp # mount /dev/dasdd1 /tmp/test02/boot
    test01:/tmp # mount /dev/mapper/test02vg-homelv /tmp/test02/home/
    test01:/tmp # mount /dev/mapper/test02vg-tmplv /tmp/test02/tmp/
    test01:/tmp # mount /dev/mapper/test02vg-userlv /tmp/test02/usr/
    test01:/tmp # mount /dev/mapper/test02vg-varlv /tmp/test02/var/
    test01:/tmp # mount -t devtmpfs none /tmp/test02/dev/
test01:/tmp # df -k
Filesystem                  1K-blocks    Used Available Use% Mounted on
/dev/dasda2                   2064144  215440   1743836  11% /
udev                           251992     184    251808   1% /dev
tmpfs                          251992       0    251992   0% /dev/shm
/dev/dasda1                    507624   39188    442236   9% /boot
/dev/mapper/test01vg-homelv    516040   16864    472964   4% /home
/dev/mapper/test01vg-tmplv    4128448  139464   3779272   4% /tmp
/dev/mapper/test01vg-userlv   5160576 2534020   2364412  52% /usr
/dev/mapper/test01vg-varlv    7865808  256708   7209536   4% /var
/dev/dasdd2                   2064144  215360   1743916  11% /tmp/test02
/dev/dasdd1                    507624   39188    442236   9% /tmp/test02/boot
/dev/mapper/test02vg-homelv    516040   16864    472964   4% /tmp/test02/home
/dev/mapper/test02vg-tmplv    4128448  139460   3779276   4% /tmp/test02/tmp
/dev/mapper/test02vg-userlv   5160576 2534020   2364412  52% /tmp/test02/usr
/dev/mapper/test02vg-varlv    7865808  256608   7209636   4% /tmp/test02/var
  • test02側カスタマイズのためtes02のファイルシステムへchrootする
    test01:/tmp # chroot /tmp/test02/

Device情報の変更

DASD認識ルールの修正

udevルールのファイル名をDASDアドレスにあわせて変更

test01:/etc/udev/rules.d> mv 51-dasd-0.0.5801.rules 51-dasd-0.0.5901.rules
test01:/etc/udev/rules.d> mv 51-dasd-0.0.5802.rules 51-dasd-0.0.5902.rules
test01:/etc/udev/rules.d> mv 51-dasd-0.0.5803.rules 51-dasd-0.0.5903.rules

ルール内のDASDアドレス修正

test01:/etc/udev/rules.d> sed -e 's/5801/5901/g' 51-dasd-0.0.5901.rules > a-51-dasd-0.0.5901.rules
test01:/etc/udev/rules.d> sed -e 's/5802/5902/g' 51-dasd-0.0.5902.rules > a-51-dasd-0.0.5902.rules
test01:/etc/udev/rules.d> sed -e 's/5803/5903/g' 51-dasd-0.0.5903.rules > a-51-dasd-0.0.5903.rules
test01:/etc/udev/rules.d> mv 51-dasd-0.0.5901.rules /tmp
test01:/etc/udev/rules.d> mv 51-dasd-0.0.5902.rules /tmp
test01:/etc/udev/rules.d> mv 51-dasd-0.0.5903.rules /tmp
test01:/etc/udev/rules.d> mv a-51-dasd-0.0.5901.rules 51-dasd-0.0.5901.rules
test01:/etc/udev/rules.d> mv a-51-dasd-0.0.5902.rules 51-dasd-0.0.5902.rules
test01:/etc/udev/rules.d> mv a-51-dasd-0.0.5903.rules 51-dasd-0.0.5903.rules

fstabの修正

test01:/etc> cp -ip fstab  fstab.org
test01:/etc> vi fstab
test01:/etc> diff fstab fstab.org
1,7c1,7
< /dev/test02vg/swaplv swap                 swap       defaults              0 0
< /dev/disk/by-path/ccw-0.0.5901-part2 /                    ext3       acl,user_xattr        1 1
< /dev/disk/by-path/ccw-0.0.5901-part1 /boot                ext3       acl,user_xattr        1 2
< /dev/test02vg/homelv /home                ext3       acl,user_xattr        1 2
< /dev/test02vg/tmplv  /tmp                 ext3       acl,user_xattr        1 2
< /dev/test02vg/userlv /usr                 ext3       acl,user_xattr        1 2
< /dev/test02vg/varlv  /var                 ext3       acl,user_xattr        1 2
---
> /dev/test01vg/swaplv swap                 swap       defaults              0 0
> /dev/disk/by-path/ccw-0.0.5801-part2 /                    ext3       acl,user_xattr        1 1
> /dev/disk/by-path/ccw-0.0.5802-part1 /boot                ext3       acl,user_xattr        1 2
> /dev/test01vg/homelv /home                ext3       acl,user_xattr        1 2
> /dev/test01vg/tmplv  /tmp                 ext3       acl,user_xattr        1 2
> /dev/test01vg/userlv /usr                 ext3       acl,user_xattr        1 2
> /dev/test01vg/varlv  /var                 ext3       acl,user_xattr        1 2

ホスト名の変更

test01:/etc> cp -ip hosts hosts.org
test01:/etc> vi hosts
test01:/etc> cp -ip HOSTNAME HOSTNAME.org
test01:/etc> vi HOSTNAME

ネットワーク情報の修正

test01:/etc/sysconfig/network> cp -ip ifcfg-eth0 /tmp/ifcfg-eth0.org
test01:/etc/sysconfig/network> vi ifcfg-eth0
test01:/etc/sysconfig/network> diff ifcfg-eth0 /tmp/ifcfg-eth0.org
2,3c2,3
< IPADDR='192.168.0.2/24'
< BROADCAST='192.168.0.255'
---
> IPADDR='192.168.0.1/24'
> BROADCAST=''

IPL情報の修正

IPL設定ファイル修正

test01:/etc> cp -ip zipl.conf zipl.conf.org
test01:/etc> vi zipl.conf
test01:/etc> diff zipl.conf zipl.conf.org
10c10
<     parameters = "root=/dev/disk/by-path/ccw-0.0.5901-part2 hvc_iucv=8 TERM=dumb resume=/dev/test02vg/swaplv"
---
>     parameters = "root=/dev/disk/by-path/ccw-0.0.5801-part2 hvc_iucv=8 TERM=dumb resume=/dev/test01vg/swaplv"
17c17
<     parameters = "root=/dev/disk/by-path/ccw-0.0.5901-part2 hvc_iucv=8 TERM=dumb noresume x11failsafe"
---
>     parameters = "root=/dev/disk/by-path/ccw-0.0.5801-part2 hvc_iucv=8 TERM=dumb noresume x11failsafe"
34c34
<     parameters = "root=/dev/disk/by-path/ccw-0.0.5901-part2 hvc_iucv=8 TERM=dumb resume=/dev/test02vg/swaplv"
---
>     parameters = "root=/dev/disk/by-path/ccw-0.0.5801-part2 hvc_iucv=8 TERM=dumb resume=/dev/test01vg/swaplv"

IPL情報の書き込み

initファイルの再作成

test01:/etc> mkinitrd

Kernel image:   /boot/image-3.0.82-0.7-default
Initrd image:   /boot/initrd-3.0.82-0.7-default
device node not found
Root device (/dev/dasdd2) not found
There was an error generating the initrd (1)

IPL情報の書き込み

test01:/etc> zipl
Using config file '/etc/zipl.conf'
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Building bootmap in '/boot/zipl'
Building menu 'menu'
Adding #1: IPL section 'SLES11_SP3_1' (default)
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Adding #2: IPL section 'Failsafe_2'
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Adding #3: IPL section 'ipl'
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Warning: Could not determine driver name for major 94 from /proc/devices
Warning: Preparing a logical device for boot might fail
Preparing boot device: 5901.
Done.

クローン先DASDの切り離し

chroot終了

mcs111:/etc # exit

test02用ファイルシステムのumount

test01:~ # umount /tmp/test02/var
test01:~ # umount /tmp/test02/usr
test01:~ # umount /tmp/test02/tmp
test01:~ # umount /tmp/test02/home
test01:~ # umount /tmp/test02/boot
test01:~ # umount /tmp/test02/dev
test01:~ # umount /tmp/test02

test02用VGの無効化

test01:~ # vgchange -an test02vg
 0 logical volume(s) in volume group "test02vg" now active

test02用DASDのOffline化

test01:~ # chccwdev -d 5901
Setting device 0.0.5901 offline
Done
test01:~ # chccwdev -d 5902
Setting device 0.0.5902 offline
Done
test01:~ # chccwdev -d 5903
Setting device 0.0.5903 offline
Done

test02用DASDをtest01からdetach

test01:~ # vmcp det 5901
DASD 5901 DETACHED
test01:~ # vmcp det 5902
DASD 5902 DETACHED
test01:~ # vmcp det 5903
DASD 5903 DETACHED
test01:~ # lsdasd -a
Bus-ID     Status      Name      Device  Type  BlkSz  Size      Blocks
==============================================================================
0.0.0190   offline
0.0.0191   offline
0.0.0193   offline
0.0.019e   offline
0.0.0592   offline
0.0.5801   active      dasda     94:0    ECKD  4096   7043MB    1803060
0.0.5802   active      dasdb     94:4    ECKD  4096   7043MB    1803060
0.0.5803   active      dasdc     94:8    ECKD  4096   7043MB    1803060

test02からIPL

5901から5903のDASDをtest02へattachし、z/VMのtes02ユーザーでログインしIPLする。以上でtest01のクローンをtest02へ作成した。

IPL 5901

Counter: 623, today: 2, yesterday: 0