■KVMに必要なCPUフラグが無いので、通常のQEMUを導入する。
$ grep flags /proc/cpuinfo | sed s/" "/"\n"/g | grep "vmx\|svm"
■qemu-launcherの導入
$ apt-cache search ^qemu | grep "GUI\|フロントエンド"
aqemu - QEMU および KVM の Qt4 フロントエンド
qemuctl - qemu 制御用 GUI
qemu-launcher - QEMU コンピュータエミュレータ向け GTK+ 版フロントエンド
qtemu - QEMU 用 GUI
$ sudo apt-get install -y qemu-launcher
■vyattaは以下を選択。
$ ~/iso_system/vyatta/vyatta-livecd_VC6.5R1_i386.iso
■数年前に使った時とあまり変わらず遅い(同じマシンのWindows上のvmplayerよりはるかに遅い)のと、
GUIのマウス操作が無応答になるので却下。。。
見た目はvmplayerやvirtualboxと同様なので、コマンドを忘れていても使える。
$ sudo pkill qemu*
■LXCの導入
※0.7.2ではcgroupのメモリ管理が出来ない。
0.7.3以上が推奨。
Setting up LXC on Debian squeeze
http://sutas.eu/setting-up-lxc-on-debian-squeeze/
$ sudo apt-get install bridge-utils debootstrap
$ sudo apt-get install -y lxc
■LXCの初期設定
$ echo "cgroup /sys/fs/cgroup cgroup defaults 0 0" | sudo tee -a /etc/fstab
cgroup /sys/fs/cgroup cgroup defaults 0 0
$ sudo mount cgroup
$ lxc-version
lxc version: 0.7.2
$ sudo lxc-checkconfig | grep missing
Cgroup memory controller: missing
■lennyでは無くsqueezeを導入しようとするが「Couldn't find these debs: dhcp-client」でコケる。
$ grep -i lenny /usr/lib/lxc/templates/lxc-debian
lenny $cache/partial-$arch http://ftp.debian.org/debian
$ sudo cp /usr/lib/lxc/templates/lxc-debian /usr/lib/lxc/templates/lxc-debian.org
$ sudo sed -i s/lenny/squeeze/ /usr/lib/lxc/templates/lxc-debian
$ sudo grep squeeze /usr/lib/lxc/templates/lxc-debian
squeeze $cache/partial-$arch http://ftp.debian.org/debian
$ sudo mkdir -p /lxc/vm0
$ sudo /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/ 2>&1 | grep ^E
E: Couldn't find these debs: dhcp-client
■パッケージが「isc-dhcp-client」に置き換わっているので対応する。
また、MIRROR参照は直接書き換えてしまう。
$ apt-cache search dhcp-client
dhcpcd - IPv4 ネットワーク自動設定用 DHCP クライアント
isc-dhcp-client - ISC DHCP クライアント
isc-dhcp-client-dbg - ISC DHCP クライアント (デバッグシンボル)
pump - IP 設定の自動化のための BOOTP および DHCP 用クライアント
$ grep "dhcp-client\|ftp" /usr/lib/lxc/templates/lxc-debian
dhcp-client,\
squeeze $cache/partial-$arch http://ftp.debian.org/debian
$ sudo sed -i s/dhcp-client/isc-dhcp-client/ /usr/lib/lxc/templates/lxc-debian
$ sudo sed -i s/ftp.debian.org/ftp.jp.debian.org/ /usr/lib/lxc/templates/lxc-debian
$ grep "dhcp-client\|ftp" /usr/lib/lxc/templates/lxc-debian
isc-dhcp-client,\
squeeze $cache/partial-$arch http://ftp.jp.debian.org/debian
■再度作成するが、今度はperlの警告が出る。
$ sudo /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/
...
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = "ja_JP.UTF-8"
are supported and installed on your system.
...
■確かに未設定。
$ locale
LANG=ja_JP.UTF-8
LANGUAGE=
LC_CTYPE="ja_JP.UTF-8"
LC_NUMERIC="ja_JP.UTF-8"
LC_TIME="ja_JP.UTF-8"
LC_COLLATE="ja_JP.UTF-8"
LC_MONETARY="ja_JP.UTF-8"
LC_MESSAGES="ja_JP.UTF-8"
LC_PAPER="ja_JP.UTF-8"
LC_NAME="ja_JP.UTF-8"
LC_ADDRESS="ja_JP.UTF-8"
LC_TELEPHONE="ja_JP.UTF-8"
LC_MEASUREMENT="ja_JP.UTF-8"
LC_IDENTIFICATION="ja_JP.UTF-8"
LC_ALL=
$ echo -e "export LANGUAGE=\"ja\"\nexport LC_ALL=\"C\"" | sudo tee -a ~/.bashrc
export LANGUAGE="ja"
export LC_ALL="C"
$ exit
■再々作成。今度はLANG変数ですか。
$ sudo /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/ | tee -a vm0.log
$ sudo locale | grep "LANGUAGE\|LC_ALL"
LANGUAGE=ja
LC_ALL=C
$ sudo /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/debian/rootfs-i386 ...
Copying rootfs to /lxc/vm0//rootfs...Generating locales (this might take a while)...
Generation complete.
*** update-locale: Error: invalid locale settings: LANG=ja_JP.UTF-8
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
Root password is 'root', please change !
■ふむ、今度はうまくいった。
ネットワークを固定にする方法は特に変わらないので触れない。
$ sudo env LANG=C /usr/lib/lxc/templates/lxc-debian -p /lxc/vm0/
debootstrap is /usr/sbin/debootstrap
Checking cache download in /var/cache/lxc/debian/rootfs-i386 ...
Copying rootfs to /lxc/vm0//rootfs...Generating locales (this might take a while)...
Generation complete.
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
update-rc.d: using dependency based boot sequencing
Root password is 'root', please change !
$ lxc-info -n vm0
'vm0' is STOPPED
$ cat /lxc/vm0/rootfs/etc/network/interfaces
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp
■当然、DHCPサーバは応答しない。
$ sudo env LANG=C lxc-start -n vm0 -f /lxc/vm0/config
INIT: version 2.88 booting
Using makefile-style concurrent boot in runlevel S.
Activating swap...done.
Cleaning up ifupdown....
Setting up networking....
Activating lvm and md swap...done.
Checking file systems...fsck from util-linux-ng 2.17.2
done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Cleaning up temporary files....
Setting kernel variables ...done.
Configuring network interfaces...Internet Systems Consortium DHCP Client 4.1.1-P1
Copyright 2004-2010 Internet Systems Consortium.
All rights reserved.
For info, please visit https://www.isc.org/software/dhcp/
Listening on LPF/eth0/00:1e:68:ca:e7:56
Sending on LPF/eth0/00:1e:68:ca:e7:56
Sending on Socket/fallback
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 7
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 8
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 9
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 15
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 15
No DHCPOFFERS received.
No working leases in persistent database - sleeping.
done.
Cleaning up temporary files....
INIT: Entering runlevel: 3
Using makefile-style concurrent boot in runlevel 3.
Starting OpenBSD Secure Shell server: sshd.
Debian GNU/Linux 6.0 acer-debian console
acer-debian login: root
Password:
Linux acer-debian 2.6.32-5-686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
■別のコンソールから確認。
$ sudo env LANG=C lxc-info -n vm0
'vm0' is RUNNING
$ ls /usr/bin/lxc-*
/usr/bin/lxc-attach /usr/bin/lxc-freeze /usr/bin/lxc-setcap
/usr/bin/lxc-cgroup /usr/bin/lxc-info /usr/bin/lxc-setuid
/usr/bin/lxc-checkconfig /usr/bin/lxc-kill /usr/bin/lxc-start
/usr/bin/lxc-checkpoint /usr/bin/lxc-ls /usr/bin/lxc-stop
/usr/bin/lxc-console /usr/bin/lxc-monitor /usr/bin/lxc-unfreeze
/usr/bin/lxc-create /usr/bin/lxc-netstat /usr/bin/lxc-unshare
/usr/bin/lxc-destroy /usr/bin/lxc-ps /usr/bin/lxc-version
/usr/bin/lxc-execute /usr/bin/lxc-restart /usr/bin/lxc-wait
$ lxc-ps
CONTAINER PID TTY TIME CMD
12556 pts/8 00:00:01 bash
12670 pts/8 00:00:00 lxc-ps
12671 pts/8 00:00:00 ps
$ sudo env LANG=C lxc-console -n vm0
Type <Ctrl+a q> to exit the console
$ sudo env LANG=C lxc-netstat -n vm0 -an | grep -v ^unix | wc -l
25
$ sudo env LANG=C lxc-ls
vm0
■停止する。
$ sudo env LANG=C /usr/bin/lxc-stop -n vm0
$ sudo env LANG=C /usr/bin/lxc-info -n vm0
'vm0' is STOPPED
■コンソールが速すぎるとのエラーが出るので。。。
$ sudo grep 38400 /lxc/vm0/rootfs/etc/inittab
1:2345:respawn:/sbin/getty 38400 console
c1:12345:respawn:/sbin/getty 38400 tty1 linux
c2:12345:respawn:/sbin/getty 38400 tty2 linux
c3:12345:respawn:/sbin/getty 38400 tty3 linux
c4:12345:respawn:/sbin/getty 38400 tty4 linux
$ sudo sed -i s/38400/9600/ /lxc/vm0/rootfs/etc/inittab
■ついでに、NICはmanualにする。
$ sudo sed -i s/dhcp/manual/ /lxc/vm0/rootfs/etc/network/interfaces
$ sudo env LANG=C lxc-start -n vm0 -f /lxc/vm0/config
INIT: version 2.88 booting
Using makefile-style concurrent boot in runlevel S.
Activating swap...done.
Cleaning up ifupdown....
Setting up networking....
Activating lvm and md swap...done.
Checking file systems...fsck from util-linux-ng 2.17.2
done.
Mounting local filesystems...done.
Activating swapfile swap...done.
Cleaning up temporary files....
Setting kernel variables ...done.
Configuring network interfaces...done.
Cleaning up temporary files....
INIT: Entering runlevel: 3
Using makefile-style concurrent boot in runlevel 3.
Starting OpenBSD Secure Shell server: sshd.
Debian GNU/Linux 6.0 acer-debian console
acer-debian login: root
Password:
Last login: Tue Mar 5 13:15:15 UTC 2013 on console
Linux acer-debian 2.6.32-5-686
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.