OpenVZ インストール · 2 min read · Jan 25, 2026
Debian Wheezy に OpenVZ をインストールして使用する - ページ 2
2.2 OpenVZ プロジェクトから Debian Wheezy カーネルをインストールする
/etc/apt/sources.list に次の行を追加します:
vi /etc/apt/sources.list| [...] deb http://download.openvz.org/debian wheezy main |
OpenVZ キーを apt に追加します:
wget -O- "http://ftp.openvz.org/debian/archive.key" | apt-key add -パッケージデータベースを更新します:
apt-get updateOpenVZ カーネル、vzctl、vzquota、および vzdump を次のようにインストールします:
apt-get install vzkernel vzctl vzquota vzdump次に、システムを再起動したときに正しいカーネル(OpenVZ カーネル)が起動することを確認する必要があります。最後のコマンドの出力には次のようなものが表示されるはずです:
Generating grub.cfg …
Found linux image: /boot/vmlinuz-3.2.0-4-amd64
Found initrd image: /boot/initrd.img-3.2.0-4-amd64
Found linux image: /boot/vmlinuz-2.6.32-042stab059.7
Found initrd image: /boot/initrd.img-2.6.32-042stab059.7
done
root@server1:~#
これは、システムに別のカーネル(3.2.0)があり、OpenVZ カーネル(2.6.32)がリストの最初にないことを意味します。したがって、OpenVZ カーネルをデフォルトのカーネルにするために、GRUB でデフォルトのカーネルを調整する(推奨)か、非 VZ カーネルを削除するかの2つのオプションがあります。
GRUB でデフォルトのカーネルを調整するには、/etc/default/grub を開きます…
vi /etc/default/grub… そして GRUB_DEFAULT 行を修正します(カウントは 0 から始まります; 各カーネルにはリカバリモードもあるため、OpenVZ カーネルは 3 番目のカーネルであり、ここに 2 を入力する必要があります):
| [...] GRUB_DEFAULT=2 [...] |
その後、GRUB を更新します:
update-grubデフォルトのカーネルを削除するには、次を実行します…
apt-get remove linux-image-amd64 linux-image-3.2.0-4-amd64… そして GRUB を更新します:
update-grub正しいカーネルが起動することを確認したので、次に進むことができます。
次に、/etc/fstab でデバイス名の代わりに UUID を使用していることを確認する必要があります。そうしないと、OpenVZ カーネルでシステムが起動しない可能性があります。次を実行します…
blkid… デバイス/パーティションの UUID を調べます:
root@server1:/tmp# blkid
/dev/mapper/server1-swap_1: UUID=”c465cb44-1bf9-4fbe-bb31-17139fd43004” TYPE=”swap”
/dev/sda5: UUID=”WRK6Xm-fg52-T836-sp4k-6uxm-trHH-FiRdBx” TYPE=”LVM2_member”
/dev/sda1: UUID=”46d1bd79-d761-4b23-80b8-ad20cb18e049” TYPE=”ext2”
/dev/mapper/server1-root: UUID=”d5ac6d76-0b69-46da-b0c1-a4376f2f0e4e” TYPE=”ext4”
root@server1:/tmp#
/etc/fstab を開きます:
vi /etc/fstab私の元の /etc/fstab は次のようになります(/boot パーティションの UUID はすでに使用されていますが、/ と swap にはデバイス名が使用されています):
| # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # |
すべてのパーティションに UUID が使用されるように修正します:
| # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # |
/var/lib/vz から /vz へのシンボリックリンクを作成して、後方互換性を提供します:
ln -s /var/lib/vz /vz/etc/sysctl.conf を開き、次の設定が含まれていることを確認します:
vi /etc/sysctl.conf| [...] net.ipv4.conf.all.rp_filter=1 net.ipv4.icmp_echo_ignore_broadcasts=1 net.ipv4.conf.default.forwarding=1 net.ipv4.conf.default.proxy_arp = 0 net.ipv4.ip_forward=1 kernel.sysrq = 1 net.ipv4.conf.default.send_redirects = 1 net.ipv4.conf.all.send_redirects = 0 net.ipv4.conf.eth0.proxy_arp=1 [...] |
/etc/sysctl.conf を修正する必要がある場合は、次を実行します
sysctl -p 次のステップは、仮想マシンの IP アドレスがホストシステムの IP アドレスとは 異なるサブネット にある場合に重要です。これを行わないと、仮想マシンでネットワークが機能しません!
/etc/vz/vz.conf を開き、NEIGHBOUR_DEVS を all に設定します:
vi /etc/vz/vz.conf| [...] # Controls which interfaces to send ARP requests and modify APR tables on. NEIGHBOUR_DEVS=all [...] |
最後に、システムを再起動します:
rebootシステムが問題なく再起動すれば、すべてが正常です!
次を実行します
uname -r新しい OpenVZ カーネルが表示されるはずです:
root@server1:~# uname -r
2.6.32-042stab059.7
root@server1:~#
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。