Virtual Machine options

Booting and installing sidux to a KVM Virtual Machine

KVM is a full virtualisation solution for Linux on x86 hardware containing virtualisation extensions (Intel VT or AMD-V).

Prerequisites

To ascertain whether your hardware supports KVM, ensure that KVM is enabled in the BIOS (in some cases on an Intel VT or AMD-V system it may not evident as to where the switch is, therefore assume that it is in a KVM state). The way to check is in a console run:

cat /proc/cpuinfo | egrep --color=always 'vmx|smx'

If you see smx or vmx in the cpu flags field, your system supports KVM. (Otherwise go back to the BIOS if you believe it is supported and check again, else search the internet as to where in the BIOS menus KVM 'enable' could be hiding).

Should your BIOS not support KVM refer to Virtualbox or QEMU

To install and run KVM, firstly ensure that Virtualbox modules are not loaded, (--purge them is the best option), then depending on your chipset:

For vmx:

apt-get install qemu-kvm
modprobe kvm_intel

For smx:

apt-get install qemu-kvm
modprobe kvm_amd

Another option is reboot as the qemu-kvm initscripts will take care of loading the modules.

Using KVM to boot a sidux-*.iso

As user:

$ kvm -net nic,model=virtio -net user -soundhw ac97 -m 512 -monitor stdio -cdrom <sidux.iso>
Installing a sidux-*.iso to a KVM image

First create a hard disk image, (this image will be minimal and only grow as required due to qcow2 compression ratios):

$ qemu-img create -f qcow2 sidux-2010-*-.img 12G

Boot the sidux-*.iso with the following parameters to enable KVM to recognise that there is an QEMU hard disk image available:

$ kvm -net nic,model=virtio -net user -soundhw ac97 -m 512 -monitor stdio -cdrom </path/to/sidux.iso> -boot d </path/to/sidux-20xx-*-.img>

Once the cdrom has booted up click on the sidux installer icon to activate the installer, (or use the menu), click on the Partitioning tab and you should see on the left hand side a box that has a disk ready for partitioning and formatting, most likely noted as /dev/sda. Underneath that are the options for partitioning, choose gparted.

gparted kvm hard disk naming

In the Gparted menu you can confirm that Gparted sees the image with View>Device Information which should state it is a ATA QEMU Harddisk and most likely noted as /dev/sda,(in this example), as this will be crucial when moving back to the installer and choosing where to put Grub, as it needs to go to /dev/sda.

Next, in the Partition menu choose Device>Create Partiton Table and create the partition table.

Then format the partition table with ext4 and also include a swap of 2 gig. The formatting will take time so be patient.

After formatting has completed, click OK to be returned to the installer and proceed as if you are performing a standard install, (again, be patient). Note: Install the Grub to /dev/sda.

You now have a sidux-*-VM ready for use:

$ kvm -net nic,model=virtio -net user -soundhw ac97 -m 512 -monitor stdio -drive if=virtio,boot=on,file=<absolute/path/to/sidux-20xx-*.img>

If the guest does not support virtio, or you do not specify an absolute path, use:

$ kvm -net nic,model=virtio -net user -soundhw ac97 -m 512 -monitor stdio -hda </path/to/sidux-20xx-*.img>

See also:

$ man kvm
Managing your KVM virtual machine installations
apt-get install aqemu

When using AQEMU ensure that you choose the KVM mode from the drop down box for 'Emulator Type' in the 'General' tab. (Documentation for AQEMU is basically non existent, therefore a few 'trials by error' will be required to figure out the easy to use GUI, however a good start is to use first use the 'VM' menu followed by the 'General' tab.

Booting and installing sidux to a VirtualBox Virtual Machine

The Steps:

最低限必要な条件

RAMのサイズ: 1GB(推奨) : 理想的にはホストに512MBとゲストに512 MB。 (それ以下のRAMでも使えますが、あまり良いパフォーマンスは期待できません)。

ハードディスクスペース: VirtualBoxそのものはとても小さいプログラムです(普通にインストールすれば30MB程度のスペースしか使いません)が、バーチャルマシンはハードディスクの代わりとしてディスク上にかなり大きいファイルを必要とします。 そのため、例えばMS Windows XP(TM)をインストールするには何GBものスペースが必要になるでしょう。 siduxをVirtualBoxのゲストOSとして使うのには5GBのイメージとスワップスペースがあればいいでしょう。

Installation:

apt-get update
apt-get install virtualbox-ose-qt virtualbox-ose-source dmakms module-assistant

Then prepare the module:

m-a prepare
m-a a-i virtualbox-ose-source

Then activate Dynamic Module-Assistant Kernel Module Support for virtualbox, so that the next time the Linux kernel is updated a virtualbox module is prepared for it too, without manual intervention. To do that, add virtualbox-ose-source to the /etc/default/dmakms configuration file.

mcedit /etc/default/dmakms
virtualbox-ose-source

Then reboot the computer.

This is essential reading on dmakms

siduxをバーチャルマシンにインストールする

VirtualBoxのウィザードを使ってsiduxが使うバーチャルマシンを作り、続いて通常のsiduxのインストールの手順を踏みます。

VirtualBoxにはダウンロードできる詳しいヘルプPDFがあります

Booting and installing sidux to a QEMU Virtual Machine

A QT GUI tool is available to help you configure QEMU:

apt-get install qtemu

ハードディスクイメージを作る

QEMUを使うためにはハードディスクイメージを作る必要があります。 このファイルをハードディスクの代わりとしてバーチャルマシンのファイルを保存するために使います。

そのためには:

qemu-img create -f qcow sidux.qcow 3G

このコマンドで"sidux.qcow"という名のイメージファイルtを作ります。 "3G"というパラメータはディスクのサイズ-この場合3GBを指定しています。 Mを使えばメガバイトの表示も使えます(例、"256M"とかけば256MB) あまりイメージサイズを気にすることはありません。 qcowフォーマットはイメージを圧縮するため空白のスペースのためにファイルが大きくなってしまうことはありません。

オペレーションシステムのインストール

初めてエミュレータを使うとき注意すべきこと: 一度QEMUのウィンドウの中をクリックするとマウスはバーチャルマシンに捕まります。 これを解放するには:

Ctrl+Alt

起動フロッピーが必要ならばQEMUを次のコマンドで起動します:

qemu -floppy sidux.iso -net nic -net user -m 512 -boot d sidux.qcow

CD-ROMから起動できる場合はQEMUを次のコマンドで起動します:

qemu -cdrom sidux.iso -net nic -net user -m 512 -boot d sidux.qcow

siduxを本物のハードディスクへの場合と同じ用にインストールします

システムの作動

システムを作動するには単純に:

qemu [hd_image]

オーバーレイイメージを使ってみるのもいい考えです。 この方法だと一度ハードディスクイメージを作って、その後の変化は外部のファイルに保存します。 何か問題が起こったとき簡単に以前の状態に戻せるため安定して使うことができます。

オーバーレイイメージを作るには:

qemu-img create -b [[base''image]] -f qcow [[overlay''image]]

ハードディスクイメージをベースイメージ(ここではsidux.qcow)と取り替えます。 これから先はQEMUをスタートするのに:

qemu [overlay_image]

のコマンドを使います。

もとのイメージはそのまま手をつけずに保存されます。 このベースイメージの名前と場所はオーバーレイに記憶されるので、けっして変更してはいけません。

本当のパーティションをハードディスクイメージのプライマリパーティションとして使う

時にはシステムパーティションの一つをQEMUの内部から使いたいことがあります。 (同じパーティションをルートとして実際に起動したりQEMUから起動したりしたい場合など)。 ソウトウェアRAIDをリニアモードで使い(そのためにはカーネルモジュールlinear.koが必要です)合わせてループバックデバイスを使うことで実現できます: QEMUのディスクイメージに埋め込みたい本物のパーティションの先頭にマスターブートレコード(MBR)をダイナミックに差し込むのがトリックです。

仮にまだマウントされていないパーティション /dev/sdaN があって、何らかのファイルシステムにフォーマットされていて、これをQEMUのディスクイメージの一部に取り込みたいとします。 まず、MBRを保持する小さいファイルを作ります:

dd if=/dev/zero of=/path/to/mbr count=32

これで16 KB(32x512バイ)のファイルが作られました。 (MBRが必要なのは512バイトブロックが一つだけではあるけれど)このファイルのサイズが小さすぎないことが大切です。 あまり小さいとソフトウェアRAIDデバイスのチャンクサイズも小さくなってしまい、パフォーマンスに影響がでます。 ではMBRファイルのループバックデバイスを設定します:

losetup -f /path/to/mbr

すでにループデバイスが存在するとは限らないので仮にこれから作るループデバイスを /dev/loop0 としましょう。 次のステップはソフトウェアRAIDを使ってMBRとディスクイメージ/dev/sdaNを合併することです:

 modprobe linear
 mdadm --build --verbose /dev/md0 --chunk=16 --level=linear --raid-devices=2 /dev/loop0 /dev/sdaN

こうして作られた /dev/md0 をQEMUのディスクイメージファイルとして使います。 (エミュレータがアクセスで切るようにパーミッションを設定するのを忘れないように)。 最後の(一番トリッキーな)ステップはディスク設定(ディスクの形状とパーティションテーブル)においてMBRのプライマリパーティションのスタートポイントが /dev/md0 のなかの /dev/sdaN のポイントと一致するように(この例ではオフセットが16 x 512 = 16384バイトちょうどになるように)設定することです。 この作業はエミュレータの中では行わず、ホストマシーンの上でfdiskを使って行いましょう。 QEMUのデフォルトのロウディスク認識ルーチンはしばしばキロバイトで割り切れないオフセット(上の例だと31.5Kb)を出力するため、ソフトウェアRAIDコードでは扱えません。 だからホスト上で行います:

 fdisk /dev/md0

このプラグラムで /dev/sdaN に対応する単一のプライマリパーティションを作成し、XpertメニューのSectorコマンドを試しながら最初のシリンダ(初めのセクターが始まるところ)ばMBRのサイズと一致する設定を探し、Writeコマンドで結果を書き込んで終わりです。 これでこのパーティションをホストからでもQEMUのディスクイメージの一部としてでも使えるようになりました:

 qemu -hdc /dev/md0 [...]

もちろんこのディスクイメージにQEMUを使って(元の/boot/sdaNパーティションに必要なツールさえあれば)どんなブートローダでも設定できます。

QEMUのアクセレータモジュールを使う

QEMUの開発者はQEMUを時にはネイティブに近い早さまで加速する追加のカーネルモジュールを作っています。 これをロードするには:

major=0

必要な/dev/kqemuデバイスを自動的につくるには:

echo "options kqemu major=0" >> /etc/modprobe.conf

このコマンドでmodprobe.confを修正して、モジュールがロードされる度にこのオプションが追加されるように設定されます。

qemu [...] -kernel-kqemu

これで最大限のバーチャリゼイションになりスピードがかなり早くなります。

qemuをアクティブにするには:

qemu -cdrom /tmp/pkg/sidux-debug.iso -net nic -net user -m 512

QEMUプロジェクトの公式ドキュメント

QEMUについての内容の一部はこのサイトからGNU Free Documentation License 1.2に基づいて取得されsidux-manual用に変更されています

Page last revised 13/04/2010 1450 UTC