Open Tech Press | OpenVZの実行ガイドを見ながら、手元のノートPCのUbuntu上にOpenVZを組み込んでみた。
カーネルは、Download/kernel/2.6.24/2.6.24-ovz004.1から Kernel patchをいただいて、素の2.6.24にパッチを当ててmake-kpkg --initrd binaryして作成。
以下は、冒頭のページを見ながら、ほぼそのまま。
# dpkg -i linux-image-2.6.18-openvz-18-53.5d1-686_028.53.5d1_i386.deb # dpkg -i linux-headers-2.6.18-openvz-18-53.5d1-686_028.53.5d1_i386.deb # vi /etc/sysctl.conf # apt-get install vzctl/etc/sysctl.confも冒頭のページで書かれた内容をそのまま書き加えた(^^;
ゲストOSはdebian-4.0を。
# vzctl create 1001 --ostemplate debian-4.0-i386-minimal Creating VE private area (debian-4.0-i386-minimal) Performing postcreate actions VE private area was created
確認。
# ls /var/lib/vz/root/ 1001 # ls /var/lib/vz/root/1001/ # ls /var/lib/vz/private/ 1001 # ls /var/lib/vz/private/1001/ bin dev home lib mnt proc sbin sys usr boot etc initrd media opt root srv tmp varほほー、出来てる。
最後のかんたんな設定。
# vzctl set 1001 --ipadd 192.168.0.11 --nameserver 192.168.0.250 --hostname hopenvz --save Saved parameters for VE 1001
おもむろに動かす。
# vzctl start 1001 Starting VE ... VE is mounted Adding IP address(es): 192.168.0.11 vps-net_add WARNING: Function proxy_arp for eth0 is set to 0. Enable with 'sysctl -w net.ipv4.conf.eth0.proxy_arp=1'. See /usr/share/doc/vzctl/README.Debian. Setting CPU units: 1000 Set hostname: hopenvz File resolv.conf was modified VE start in progress...ちょっと怒られたので、上記コマンドラインを実行後、追加で/etc/sysctl.confを後でいじった。
# vzlist
VEID NPROC STATUS IP_ADDR HOSTNAME
1001 4 running 192.168.0.11 hopenvz
動いているっぽい。
とりあえず、確認。
# vzcalc -v 1001 Resource Current(%) Promised(%) Max(%) Low Mem 0.07 1.22 1.22 Total RAM 0.10 n/a n/a Mem + Swap 0.05 0.70 n/a Alloc. Mem 0.08 0.70 5.26 Num. Proc 0.01 n/a 0.10 -------------------------------------------- Memory 0.10 1.22 5.26ふふーん、慣れない感じの見え方だなぁ。
sshで仮想マシンに入ろうとしたら、rootのパスワード不明(^^;
どうやって入るんだろうと思っていたら、冒頭のページに書いていた。
# vzctl enter 1001 entered into VE 1001 hopenvz:/# df Filesystem 1K-blocks Used Available Use% Mounted on simfs 1048576 154604 893972 15% / tmpfs 1031872 0 1031872 0% /lib/init/rw tmpfs 1031872 0 1031872 0% /dev/shmsimfsというのがmountされてる。
hopenvz:/# ps axww
PID TTY STAT TIME COMMAND
1 ? Ss 0:00 init [2]
320 ? Ss 0:00 /sbin/syslogd
343 ? Ss 0:00 /usr/sbin/sshd
355 ? Ss 0:00 /usr/sbin/cron
379 ? Ss 0:00 vzctl: pts/0
380 pts/0 Ss 0:00 -bash
385 pts/0 R+ 0:00 ps axww
最低限のプロセスが動いているなぁ。
おもむろに、apt-get update。
hopenvz:/# apt-get update Get:1 http://security.debian.org etch/updates Release.gpg [189B] Get:2 http://security.debian.org etch/updates Release [37.6kB] Get:3 http://ftp.se.debian.org etch Release.gpg [378B] Get:4 http://ftp.se.debian.org etch Release [58.2kB] Ign http://security.debian.org etch/updates/main Packages/DiffIndex Ign http://security.debian.org etch/updates/contrib Packages/DiffIndex Get:5 http://security.debian.org etch/updates/main Packages [320kB] Ign http://ftp.se.debian.org etch/main Packages/DiffIndex Get:6 http://security.debian.org etch/updates/contrib Packages [8934B] Ign http://ftp.se.debian.org etch/contrib Packages/DiffIndex Ign http://ftp.se.debian.org etch/main Sources/DiffIndex Ign http://ftp.se.debian.org etch/contrib Sources/DiffIndex Get:7 http://ftp.se.debian.org etch/main Packages [5619kB] Get:8 http://ftp.se.debian.org etch/contrib Packages [71.6kB] Get:9 http://ftp.se.debian.org etch/main Sources [1653kB] Get:10 http://ftp.se.debian.org etch/contrib Sources [21.0kB] Fetched 7790kB in 17s (436kB/s) Reading package lists... Doneなぜか、seから。
でも、そのまま、upgrade。
hopenvz:/# apt-get upgrade Reading package lists... Done Building dependency tree... Done The following packages will be upgraded: bsdutils cpio debconf debconf-i18n debian-archive-keyring e2fslibs e2fsprogs findutils libblkid1 libc6 libcomerr2 libkrb53 libpam-modules libpam-runtime libpam0g libss2 libssl0.9.8 libuuid1 lsb-base mount nano perl-base tar tzdata util-linux vim-common vim-tiny 27 upgraded, 0 newly installed, 0 to remove and 0 not upgraded. Need to get 13.8MB of archives. After unpacking 1376kB disk space will be freed. Do you want to continue [Y/n]? 以下略とりあえず、あまり意識せずにそのまま使えそう。
ちなみに、母艦側で、
# cd /var/lib/vz/private/1001/tmp # touch dadaを行った後に、仮想マシン側でどうなるか見たところ、
hopenvz:/# ls -l /tmp total 0 -rw-r--r-- 1 root root 0 Mar 30 14:53 dadaてな感じで出来ている。