ラベル linux の投稿を表示しています。 すべての投稿を表示
ラベル linux の投稿を表示しています。 すべての投稿を表示

2011/02/19

debianでソースからqemu-kvmをインストールしてみる

USB接続のHDDにdebianをインストール。
netinstのCDでインストール。
let's note R7だとビデオの関係で画面が出ないので、最初の画面でinstallでTABを押してオプションを表示、 vga=normal に書き換えて起動。
baseとsshだけインストール。
grubは /dev/sdb にインストール。

再起動後はsshでrootでのログインは拒否する。

とりあえずカーネルを最新にしておく。
apt-get install kernel-package fakeroot ncurses
カーネルは http://kernel.org/ からstableなソースをダウンロード。
cd /usr/src
tar xjvf ダウンロードしたカーネル
ln -s /usr/src/解凍したディレクトリ linux
cd /usr/src/linux
cp -p /boot/config-○○ .config
make oldconfig
新しい項目を聞かれるけどデフォルトでとりあえず終了。
make menuconfig
変更はせずそのまま終了。
make-kpkg clean
fakeroot make-kpkg --initrd --revision=bananagunso-1 kernel_image kernel_headers
rebisionは数字が必須らしい。
再構築
再構築
・
・
・
cd ../
dpkg -i 今回作った.debのファイル。
grubも更新してくれた。
再起動で終了。

kvmをソースからインストール
http://sourceforge.net/projects/kvm/files/ からダウンロード。
cd /usr/local/src
tar xzvf qemu-kvm-0.14.0-rc1.tar.gz
cd qemu-kvm-0.14.0-rc1
./configure
  Error: zlib check failed 怒られた 
apt-get install zlib1g-dev
./configure
make
make install


libvirtdをインストール(これもソースから)
apt-get install bridge-utils
ftp://libvirt.org/libvirt/ からダウンロード
cd /usr/local/src
tar xzvf /mnt/debian/libvirt-0.8.8.tar.gz
cd libvirt-0.8.8/
./configure 
 Could not find libxml2 anywher 怒られる
apt-get install libxml2-dev
./configure
 You must install the GnuTLS library 怒られる
apt-get install libgnutls-dev
./configure
 You must install device-mapper-devel/libdevmapper まだ怒られる
apt-get install libdevmapper-dev
 libnl-devel >= 1.1 is required for macvtap support まだかいな
apt-get install libnl-dev
./configure 
 libnl-devel >= 1.1 is required for macvtap support なんで?
apt-get install libvirt-dev
./configure やっと通った
make
make install


起動してみる
libvirtd
エラーいっぱい
libvirtd: /usr/lib/libvirt.so.0: version `LIBVIRT_0.8.6' not found (required by libvirtd)
libvirtd: /usr/lib/libvirt.so.0: version `LIBVIRT_0.8.5' not found (required by libvirtd)
libvirtd: /usr/lib/libvirt.so.0: version `LIBVIRT_0.8.8' not found (required by libvirtd)
libvirtd: /usr/lib/libvirt.so.0: version `LIBVIRT_PRIVATE_0.8.8' not found (required by libvirtd)



ldconfig
libvirtd
エラーではなくワーニングになった
23:38:47.676: 8445: info : libvirt version: 0.8.8
23:38:47.676: 8445: error : virCommandWait:1229 : internal error Child process (/sbin/iptables --table mangle --insert POSTROUTING --out-interface virbr0 --protocol udp --destination-port 68 --jump CHECKSUM --checksum-fill) exited with status 2.
23:38:47.676: 8445: warning : networkAddGeneralIptablesRules:1128 : Could not add rule to fixup DHCP response checksums on network 'default'.
23:38:47.676: 8445: warning : networkAddGeneralIptablesRules:1129 : May need to update iptables package & kernel to support CHECKSUM rule.
23:38:47.818: 8445: error : virCommandWait:1229 : internal error Child process (dnsmasq --strict-order --bind-interfaces --pid-file=/usr/local/var/run/libvirt/network/default.pid --conf-file=  --except-interface lo --listen-address 192.168.122.1 --dhcp-range 192.168.122.2,192.168.122.254 --dhcp-lease-max=253 --dhcp-no-override) exited with status 1.
23:38:47.874: 8445: error : virCommandWait:1229 : internal error Child process (/sbin/iptables --table mangle --delete POSTROUTING --out-interface virbr0 --protocol udp --destination-port 68 --jump CHECKSUM --checksum-fill) exited with status 2.
23:38:47.986: 8445: error : ebiptablesDriverInit:3749 : internal error essential tools to support ip(6)tables firewalls could not be located
23:38:47.986: 8445: error : ebiptablesDriverInit:3758 : internal error firewall tools were not found or cannot be used
23:38:48.125: 8445: warning : lxcStartup:2128 : Unable to create cgroup for driver: No such device or address


別の端末から
virsh net-undefine default


libvirtd を再起動
virbr0に関するものは消えた
23:41:55.309: 8669: info : libvirt version: 0.8.8
23:41:55.309: 8669: error : ebiptablesDriverInit:3749 : internal error essential tools to support ip(6)tables firewalls could not be located
23:41:55.309: 8669: error : ebiptablesDriverInit:3758 : internal error firewall tools were not found or cannot be used
23:41:55.429: 8669: warning : lxcStartup:2128 : Unable to create cgroup for driver: No such device or address




mkdir /dev/cgroup
mount none -t cgroup /dev/cgroup



libvirtd を再起動
23:43:16.201: 8695: info : libvirt version: 0.8.8
23:43:16.201: 8695: error : ebiptablesDriverInit:3749 : internal error essential tools to support ip(6)tables firewalls could not be located
23:43:16.201: 8695: error : ebiptablesDriverInit:3758 : internal error firewall tools were not found or cannot be used



多分大丈夫


/usr/local/etc/libvirt/libvirtd.confを書き換える
listen_tcp = 1
unix_sock_group = "libvirt"
unix_sock_rw_perms = "0770"
auth_unix_ro = "none"
auth_unix_rw = "none"


libvirtグループを追加
groupadd -g 10000 libvirt

kvmを起動してみる(一般ユーザーで)
 open /dev/kvm: No such file or directory
 Could not initialize KVM, will disable KVM support

modprobe kvm_intel

もう一度kvm
 open /dev/kvm: Permission denied
グループkvmを追加

groupadd -g 10001 kvm
kvmを実行するユーザーはkvmグループにも追加
usermod -a --group kvm ユーザーID
chgrp kvm /dev/kvm
chmod g+rw /dev/kvm
エラーが出なくなった
 
kvmを使うために必要なコマンドを/etc/rc.localに追加
/bin/mkdir /dev/cgroup
/bin/mount none -t cgroup /dev/cgroup
/sbin/modprobe kvm_intel
/bin/chgrp kvm /dev/kvm
/bin/chmod g+rw /dev/kvm


2011/02/05

LinuxでHDD引越し

最近のLinuxはUUIDとやらのおかげでそのままHDDの中身をコピーしても起動できなかったりして
困ってたけど今のところ確実に引越しできる方法が分かったのでメモ。

LiveCDでもUSBでもいいので、引越し元、引越し先のHDDを2台つないで起動。
コピー元が/dev/sda1 コピー先が/dev/sdb1 の場合
mkdir /mnt2
mount /dev/sda1 /mnt

mount /dev/sdb1 /mnt2
cd /mnt2
rsync -avHt /mnt/ ./ (コピー元は最後の/が無いと/mnt2/mnt/にコピーされる)
コピーが終わったら今度は元のHDDで起動。
コピー先をマウント
mount /dev/sdb1 /mnt
なにやら必要なものをコピー先にマウント
mount -o bind /dev /mnt/dev
mount -o bind /proc /mnt/proc
コピー先にchroot
chroot /mnt
コピー先のHDDの情報でgrub.cfgを作成
gurb-mkconfig -o /boot/grub/grub.cfg
コピー先にgrubをインストール
grub-install /dev/hdb
コピー先のHDDで起動して引越し完了。

今回はHDDレコーダーが250Gのうち5G程しか使って無かったのでUSBメモリに移動させようとしたけど、
休止からの復帰がううまくいかず、CFをIDEにつないでみたけど今度は遅すぎて断念。
結局売るに売れない10GのIDE接続のHDDにして250Gは外した。
本当はSSDにすれば静かだし早いけどもったいない。

使っていないHDDは中古に売るにも小さいやつは買ってくれないので何とか使うしかない。
最近はデータはファイルサーバーなのでメインのWindows7以外は小さくていいよ。
ローラー部屋のPCも売れないIDEの40Gにしてもいいかも。

2010/06/30

番組表取得修正

以前mc2xmlを使うように修正してうまくいったと思っていたら、その後番組表が
更新されていない。
要は番組表データのxmltv.xmlが更新されていないのが原因。
mythfilldatabaseコマンドはデータを登録するだけのようなので、その前に
mc2xmlコマンドで強制的に番組表をダウンロードしてxmltv.xmlを上書きした後、
mythfilldatabaseで登録すればうまくできそう。

ものすごく原始的だけどmc2xml_1、mc2xml_2にそれぞれCATVのセットボックスと
地デジチューナー用のファイルがあって移動して更新している。

#!/bin/sh
cd ~/mc2xml_1
./mc2xml -f -c jp -g 5830882 -U
mythfilldatabase --refresh-all --file 1 ./xmltv.xml
cd ~/mc2xml_2
./mc2xml -f -c jp -g 5830882 -U
mythfilldatabase --refresh-all --file 2 ./xmltv.xml

2010/06/24

番組表取得

mythtvの番組表がontvjapanから取れなくなって久しく、システムを入れ替えたついでに
mx2xmlとやらに変更。
サンプルのスクリプトは変なので修正したものをメモ

#!/bin/sh
cd ~/mc2xml
if [ -x ~/mc2xml/mc2xml ]
then
   mythfilldatabase --refresh-all --file 1 ./xmltv_1.xml
   mythfilldatabase --refresh-all --file 2 ./xmltv_2.xml
fi

僕の場合CATVのセットボックスと地デジチューナの2つの番組表を取るためxmltv.xmlを
リネームしている。

最初は  mc2xml -c jp -g 郵便番号 -Uでxmltv.xmlとmc2xml.datを作る
そこから必要なチャンネルのリスト mc2xml.chlと
チャンネル番号を変えるための対応表mc2xml.renを作る
書き方はオフィシャルに載ってる。


そして、xmltv.xmlとmc2xml.daを削除してもう一度
mc2xml -c jp -g 郵便番号 -Uで作れば必要なチャンネルでxmltv.xmlができる。
後は上のスクリプトで呼び出せばOK。