作業ノート

様々なまとめ、雑感など

VirtualBoxでクローンを作成する

VirtualBoxで作成した仮想マシンをベースに新しい仮想マシンを用意する方法。

複製元の仮想マシン

  • Ubuntu 12.04 64 bit
  • NICはNAT用とホストオンリーアダプター用の2つ

CentOS版は、VirtualBoxでCenOSのクローンを作成する - 作業ノートを参照。

クローン作成

1. VirtualBoxマネージャで、複製元の仮想マシンを選択

仮想マシンは電源オフの状態にする。

2. 右クリックし、メニューから「クローン」を選択

  1. 「新しいマシン名」ウィザード
    • 仮想マシン名を入力する
    • 「すべてのネットワークカードのMACアドレスを再初期化」をオン
    • 「続ける」ボタンをおして次へ
  2. 「クローンのタイプ」ウィザード
    • 「すべてをクローン」を選択
    • 「クローン」ボタンを押す

これでクローンが作成される。

複製後の設定

複製した仮想マシンの設定を行う。

ネットワークの再設定

ネットワークカードのMACアドレスを初期化したので、下記のようにファイルを編集してNICを再設定する。

$ cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:03.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:6f:25:a5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:08.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:8d:3e:c5", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:03.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:97:d9:5b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth2"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:08.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e0:8b:24", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth3"

複製前の設定(上2つ)を削除し、新しい設定(下2つ)のNAMEをそれぞれeth0, eth1にする。

$ cat /etc/udev/rules.d/70-persistent-net.rules
# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:03.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:97:d9:5b", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:/sys/devices/pci0000:00/0000:00:08.0 (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="08:00:27:e0:8b:24", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"

設定後、再起動する。
再起動後、ifconfigコマンドでeth0とeth1が表示されればOK。

参考