Debian LXC on Fedora 20

 article  Comments Off on Debian LXC on Fedora 20
Aug 162014
 

Debian wheezyをFedora 20上のContainerとして動かしてみました。

まずはrootファイルシステムとなるディレクトリを作成します。名前はdebian01としています。

[root@localhost ~]# mkdir -p /var/lib/libvirt/filesystems/debian01

debootstrapを入手して展開、実行します。
展開用にbinutilsに含まれるarコマンド、実行用にperlなどが必要になりますので、インストールします。

[root@localhost ~]# yum install binutils perl wget gnupg

debootstrap自体のインストール手順はD.3. Unix/Linux システムからの Debian GNU/Linux のインストール」の「D.3.2. debootstrap のインストール」を参照ください。
インストールしたdebootstrapを実行します。

[root@localhost ~]# /usr/sbin/debootstrap --arch amd64 stable /var/lib/libvirt/filesystems/debian01

Linux Containerとして起動します。

[root@localhost ~]# virt-install --connect lxc:// --name debian01 --ram 512 --filesystem /var/lib/libvirt/filesystems/debian01/,/

いったん止めます。

[root@localhost ~]# virsh -c lxc:// shutdown debian01

rootパスワードやコンソールログイン許可するttyデバイスを追加します。

[root@localhost ~]# chroot /var/lib/libvirt/filesystems/debian01 /bin/passwd root
[root@localhost ~]# echo "pts/0" >> /var/lib/libvirt/filesystems/debian01/etc/securetty

起動してコンソール接続します。

[root@localhost ~]# virsh -c lxc:// start --console debian01

これで先に設定したrootパスワードでコンソールログインできるはずです。

以下を参考にしました。
Launch secure LXC containers on Fedora 20 using SELinux and sVirt – major.io

virt-installでkvmゲストをインストール

 article  Comments Off on virt-installでkvmゲストをインストール
Jul 202013
 

かなり以前にvirt-installで仮想マシンをお手軽セットアップという記事を書きました。
前回はCentOS 5でxenゲストのインストールでしたが、今回はCentOS 6でkvmゲストです。

対話式でCentOSのインストーラーを起動する形式になりますのでコンソールが必要になりますが、グラフィカルな画面なしにシリアルコンソールを使ってインストールを実行します。

virt-install -n centos1 -r 512 --disk /var/lib/libvirt/images/centos1.img,size=8 --graphics none -x 'console=tty0 console=ttyS0,115200n8 serial' -l http://ftp.iij.ad.jp/pub/linux/centos/6/os/x86_64/

ちなみにシリアルコンソールを指定する-xオプション(–extra-args)を使用する場合、-lオプション(–location)が必須です。

インストーラーが起動されますので通常どおりインストールすれば完了。

/boot/grub/grub.confにもシリアルコンソールの設定が含まれるようになるので、次回起動時もシリアルコンソールを利用できます。

serial --unit=0 --speed=115200
terminal --timeout=5 serial console
title CentOS (2.6.32-358.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-358.el6.x86_64 ro root=/dev/mapper/VolGroup-lv_root rd_NO_LUKS LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=VolGroup/lv_swap SYSFONT=latarcyrheb-sun16 crashkernel=auto console=ttyS0,115200n8 rd_LVM_LV=VolGroup/lv_root  KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM
        initrd /initramfs-2.6.32-358.el6.x86_64.img

接続時は

virsh console centos1

切断時は接続時のプロンプトに出るように ^] (Ctrl+^ Ctrl+])で抜けられます。

仮想ディスク内のパーティションをマウント

 article  Comments Off on 仮想ディスク内のパーティションをマウント
Oct 282009
 

仮想ディスク上のgrub設定を編集したときのメモ。

[root@localhost ~]# fdisk -u -l /var/lib/libvirt/images/centos5_3-sda.img
You must set cylinders.
You can do this from the extra functions menu.

Disk /var/lib/libvirt/images/centos5_3-sda.img: 0 MB, 0 bytes
255 heads, 63 sectors/track, 0 cylinders, total 0 sectors
Units = sectors of 1 * 512 = 512 bytes
Disk identifier: 0x0003cb19

                                    Device Boot      Start         End      Blocks   Id  System
/var/lib/libvirt/images/centos5_3-sda.img1   *          63      192779       96358+  83  Linux
/var/lib/libvirt/images/centos5_3-sda.img2          192780    14811929     7309575   83  Linux
/var/lib/libvirt/images/centos5_3-sda.img3        14811930    16771859      979965   82  Linux swap / Solaris
Partition 3 has different physical/logical endings:
     phys=(1023, 254, 63) logical=(1043, 254, 63)
[root@localhost ~]# mount -o loop,offset=`expr 192780 \* 512` /var/lib/libvirt/images/centos5_3-sda.img /mnt
# mount -o loop,offset=`expr     63 \* 512` /var/lib/libvirt/images/centos5_3-sda.img /mnt/boot

[root@localhost ~]# cat /mnt/boot/grub/menu.lst
# Enable console output via the serial port. unit 0 is /dev/ttyS0, unit 1 is /dev/ttyS1...
serial --unit=0 --speed=115200 --word=8 --parity=no --stop=1
terminal --timeout=15 serial console

kernel          /vmlinuz-2.6.26-2-amd64 root=/dev/vda2 ro quiet
↓
kernel          /vmlinuz-2.6.26-2-amd64 root=/dev/vda2 ro quiet console=tty0 console=ttyS0,115200n8

ESXi 4.0でのSNMP有効化

 article  Comments Off on ESXi 4.0でのSNMP有効化
Oct 092009
 

ESXi 4.0を評価モードで利用し、SNMPを有効にしてみる。
以下、ESXiのIPアドレスは192.0.2.1、SNMPトラップを受信するサーバーのIPアドレスは192.0.2.2の場合の例。

# vicfg-snmp --server 192.0.2.1 --username root -E -c public -t 192.0.2.2@162/public
Enter password: 
# vicfg-snmp --server 192.0.2.1 --username root -s
Enter password:
Current SNMP agent settings:
Enabled  : 1
UDP port : 161

Communities :
public

Notification targets :
192.0.2.2@162/public

トラップをテスト送信してみる。

# vicfg-snmp --server 192.0.2.1 --username root -T
Enter password:
Sending test nofication(trap) to all configured targets...
Complete. Check with each target to see if trap was received.

192.0.2.2のサーバーではsnmptrapdが動作済みで、/var/log/messagesに以下が記録された。

Oct  8 23:32:37 192.0.2.2 snmptrapd[9386]: 2009-10-08 23:32:37 192.0.2.1(via UDP: [10.0.0.1]:51469) TRAP, SNMP v1, community public  SNMPv2-
SMI::enterprises.6876.4.1 Warm Start Trap (0) Uptime: 15:31:50.16

snmpwalkをやってみるとこんな感じ(マシンはHP ML115 G5)。

# snmpwalk -v 1 -c public 192.0.2.1 .
SNMPv2-MIB::sysDescr.0 = STRING: VMware ESX 4.0.0 build-171294 VMware, Inc. x86_64
SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.6876.4.1
DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (154208) 0:25:42.08
SNMPv2-MIB::sysContact.0 = STRING: not set
SNMPv2-MIB::sysName.0 = STRING: localhost.localdomain
SNMPv2-MIB::sysLocation.0 = STRING: not set
SNMPv2-MIB::sysServices.0 = INTEGER: 72
SNMPv2-MIB::sysORLastChange.0 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORID.1 = OID: SNMPv2-MIB::snmpMIB
SNMPv2-MIB::sysORID.2 = OID: IF-MIB::ifMIB
SNMPv2-MIB::sysORID.3 = OID: SNMPv2-SMI::enterprises.6876.1.10
SNMPv2-MIB::sysORID.4 = OID: SNMPv2-SMI::enterprises.6876.2.10
SNMPv2-MIB::sysORID.5 = OID: SNMPv2-SMI::enterprises.6876.3.10
SNMPv2-MIB::sysORDescr.1 = STRING: SNMPv2-MIB, RFC 3418
SNMPv2-MIB::sysORDescr.2 = STRING: IF-MIB, RFC 2863
SNMPv2-MIB::sysORDescr.3 = STRING: VMWARE-SYSTEM-MIB, REVISION 200801120000Z
SNMPv2-MIB::sysORDescr.4 = STRING: VMWARE-VMINFO-MIB, REVISION 200810230000Z
SNMPv2-MIB::sysORDescr.5 = STRING: VMWARE-RESOURCES-MIB, REVISION 200810150000Z
SNMPv2-MIB::sysORUpTime.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.2 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.3 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.4 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::sysORUpTime.5 = Timeticks: (0) 0:00:00.00
IF-MIB::ifNumber.0 = INTEGER: 1
IF-MIB::ifDescr.1 = STRING: Device vmnic0 at 11:00.0 tg3
IF-MIB::ifType.1 = INTEGER: ethernetCsmacd(6)
IF-MIB::ifMtu.1 = INTEGER: 1500
IF-MIB::ifSpeed.1 = Gauge32: 100000000
IF-MIB::ifPhysAddress.1 = STRING: 0:21:5a:eb:3b:d0
IF-MIB::ifAdminStatus.1 = INTEGER: up(1)
IF-MIB::ifOperStatus.1 = INTEGER: up(1)
IF-MIB::ifLastChange.1 = Timeticks: (0) 0:00:00.00
SNMPv2-MIB::snmpInPkts.0 = Counter32: 342
SNMPv2-MIB::snmpInBadVersions.0 = Counter32: 0
SNMPv2-MIB::snmpInBadCommunityNames.0 = Counter32: 0
SNMPv2-MIB::snmpInBadCommunityUses.0 = Counter32: 0
SNMPv2-MIB::snmpInASNParseErrs.0 = Counter32: 0
SNMPv2-MIB::snmpEnableAuthenTraps.0 = INTEGER: disabled(2)
SNMPv2-MIB::snmpSilentDrops.0 = Counter32: 0
SNMPv2-MIB::snmpProxyDrops.0 = Counter32: 0
SNMPv2-SMI::enterprises.6876.1.1.0 = STRING: "VMware ESXi"
SNMPv2-SMI::enterprises.6876.1.2.0 = STRING: "4.0.0"
SNMPv2-SMI::enterprises.6876.1.4.0 = STRING: "171294"
SNMPv2-SMI::enterprises.6876.2.1.1.2.16 = STRING: "centos5.localdomain"
SNMPv2-SMI::enterprises.6876.2.1.1.3.16 = STRING: "/vmfs/volumes/4ace6c4c-99080d8b-93fc-00215aeb3bd0/centos53/centos53.vmx"
SNMPv2-SMI::enterprises.6876.2.1.1.4.16 = STRING: "rhel5-64"
SNMPv2-SMI::enterprises.6876.2.1.1.5.16 = INTEGER: 512
SNMPv2-SMI::enterprises.6876.2.1.1.6.16 = STRING: "poweredOn"
SNMPv2-SMI::enterprises.6876.2.1.1.7.16 = INTEGER: 16
SNMPv2-SMI::enterprises.6876.2.1.1.8.16 = STRING: "running"
SNMPv2-SMI::enterprises.6876.2.1.1.9.16 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.2.2.1.3.16.1000 = STRING: "scsi0"
SNMPv2-SMI::enterprises.6876.2.2.1.4.16.1000 = STRING: "PN5Vmomi4TypeE"
SNMPv2-SMI::enterprises.6876.2.3.1.3.16.2000 = STRING: "scsi0:0"
SNMPv2-SMI::enterprises.6876.2.4.1.3.16.4000 = STRING: "ethernet0"
SNMPv2-SMI::enterprises.6876.2.4.1.4.16.4000 = STRING: "VM Network"
SNMPv2-SMI::enterprises.6876.2.4.1.5.16.4000 = STRING: "monitor_dev"
SNMPv2-SMI::enterprises.6876.2.4.1.6.16.4000 = STRING: "true"
SNMPv2-SMI::enterprises.6876.2.4.1.7.16.4000 = Hex-STRING: 00 0C 29 77 63 B6
SNMPv2-SMI::enterprises.6876.2.6.1.3.16.3002 = STRING: "/vmfs/devices/genscsi/mpx.vmhba2:C0:T0:L0"
SNMPv2-SMI::enterprises.6876.2.6.1.4.16.3002 = STRING: "false"
SNMPv2-SMI::enterprises.6876.3.1.1.0 = Gauge32: 1
SNMPv2-SMI::enterprises.6876.3.2.1.0 = Gauge32: 4189816
SNMPv2-SMI::enterprises.6876.3.2.2.0 = Gauge32: 0
SNMPv2-SMI::enterprises.6876.3.2.3.0 = Gauge32: 4189816
SNMPv2-SMI::enterprises.6876.3.5.1.0 = INTEGER: 6
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.1 = STRING: "vmhba0"
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.2 = STRING: "vmhba1"
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.3 = STRING: "vmhba2"
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.4 = STRING: "vmhba32"
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.5 = STRING: "vmhba33"
SNMPv2-SMI::enterprises.6876.3.5.2.1.2.6 = STRING: "vmhba34"
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.1 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.2 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.3 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.4 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.5 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.3.6 = INTEGER: 0
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.1 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.2 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.3 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.4 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.5 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.4.6 = INTEGER: 1
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.1 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.2 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.3 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.4 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.5 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.5.6 = STRING: "MCP55 SATA Controller"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.1 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.2 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.3 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.4 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.5 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.6.6 = STRING: "sata_nv"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.1 = STRING: "00:05.0"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.2 = STRING: "00:05.1"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.3 = STRING: "00:05.2"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.4 = STRING: "00:05.0"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.5 = STRING: "00:05.1"
SNMPv2-SMI::enterprises.6876.3.5.2.1.7.6 = STRING: "00:05.2"
End of MIB

vSphere Remote CLI on CentOS 5.3

 article  Comments Off on vSphere Remote CLI on CentOS 5.3
Sep 292009
 

CentOS 5.3にvSphere Remote CLIを入れてみたが動かない。

$ vmware-cmd --server vir.example.jp --user root -l
Enter password:
Error: Server version unavailable at 'https://vir.example.jp/sdk/vimService.wsdl'

$

PerlモジュールのCrypt::SSLeayのバージョンが低かった模様。
perl-Crypt-SSLeayパッケージを入れていたが、こちらをCPANから入れなおす。

# yum remove perl-Crypt-SSLeay
# yum -y install openssl-devel.x86_64 gcc
# perl -MCPAN -e shell
cpan> install Crypt::SSLeay
:
cpan> exit

そしてvSphere Remote CLIを再度インストール。

# ./vmware-vsphere-cli-distrib/vmware-install.pl

virt-installで仮想マシンをお手軽セットアップ

 article  Comments Off on virt-installで仮想マシンをお手軽セットアップ
Jan 042009
 

CentOS 5.2のDomain-0上にCentOS 5.2をインストール。ディスクにイメージファイルを使う場合、virt-installで非常に簡単。

# vitrt-install
Would you like a fully virtualized guest (yes or no)?  This will allow you to run unmodified operating systems. no
What is the name of your virtual machine? centos5
How much RAM should be allocated (in megabytes)? 512
What would you like to use as the disk (file path)? /var/lib/xen/images/centos5-sda.img
How large would you like the disk (/var/lib/xen/images/centos5-sda.img) to be (in gigabytes)? 8
Would you like to enable graphics support? (yes or no) no
What is the install location? http://mirror.centos.org/centos/5/os/x86_64/

ここまで答えればあとはインストーラが起動する。
“Would you like a fully virtualized guest (yes or no)?”にnoを答えれば準仮想化、すなわちXenのDomain-Uになる。
ディスクイメージはSELinuxを有効にしている場合/var/lib/xen/imagesに配置するのが無難らしい。
準仮想化の場合、install location配下のimages/xen/vmlinuzカーネルでブートするようなので、Fedora 9でもいけるかもしれない。

以下はML115 G5でのインストーラ起動までのブートログ。

Starting install...
Retrieving file .treeinfo 100% |=========================|  417 B    00:00
Retrieving file vmlinuz.. 100% |=========================| 1.9 MB    00:03
Retrieving file initrd.im 100% |=========================| 5.7 MB    00:08
Creating storage file...  100% |=========================| 8.0 GB    00:00
Creating domain...                                                 0 B 00:01
Bootdata ok (command line is   method=http://mirror.centos.org/centos/5/os/x86_64/)
Linux version 2.6.18-92.el5xen (mockbuild@builder10.centos.org) (gcc version 4.1.2 20071124 (Red Hat 4.1.2-42)) #1 SMP Tue Jun 10 19:20:18 EDT 2008
BIOS-provided physical RAM map:
Xen: 0000000000000000 - 0000000020800000 (usable)
No mptable found.
Built 1 zonelists.  Total pages: 133120
Kernel command line:   method=http://mirror.centos.org/centos/5/os/x86_64/
Initializing CPU#0
PID hash table entries: 4096 (order: 12, 32768 bytes)
Xen reported: 2299.998 MHz processor.
Console: colour dummy device 80x25
Dentry cache hash table entries: 131072 (order: 8, 1048576 bytes)
Inode-cache hash table entries: 65536 (order: 7, 524288 bytes)
Software IO TLB disabled
Memory: 499968k/532480k available (2414k kernel code, 23744k reserved, 1349k data, 176k init)
Calibrating delay using timer specific routine.. 5756.12 BogoMIPS (lpj=11512251)
Security Framework v1.0.0 initialized
SELinux:  Initializing.
selinux_register_security:  Registering secondary module capability
Capability LSM initialized as secondary
Mount-cache hash table entries: 256
CPU: L1 I Cache: 64K (64 bytes/line), D cache 64K (64 bytes/line)
CPU: L2 Cache: 512K (64 bytes/line)
CPU: Physical Processor ID: 0
CPU: Processor Core ID: 1
(SMP-)alternatives turned off
Brought up 1 CPUs
checking if image is initramfs... it is
Grant table initialized
NET: Registered protocol family 16
ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread 1E7A0 could not acquire Mutex [2] [20060707]
No dock devices found.
ACPI Exception (utmutex-0262): AE_BAD_PARAMETER, Thread 1E7A0 could not acquire Mutex [2] [20060707]
Brought up 1 CPUs
PCI: Fatal: No PCI config space access function found
PCI: setting up Xen PCI frontend stub
ACPI: Interpreter disabled.
Linux Plug and Play Support v0.97 (c) Adam Belay
pnp: PnP ACPI: disabled
xen_mem: Initialising balloon driver.
usbcore: registered new driver usbfs
usbcore: registered new driver hub
PCI: System does not support PCI
PCI: System does not support PCI
NetLabel: Initializing
NetLabel:  domain hash size = 128
NetLabel:  protocols = UNLABELED CIPSOv4
NetLabel:  unlabeled traffic allowed by default
NET: Registered protocol family 2
IP route cache hash table entries: 32768 (order: 6, 262144 bytes)
TCP established hash table entries: 131072 (order: 9, 2097152 bytes)
TCP bind hash table entries: 65536 (order: 8, 1048576 bytes)
TCP: Hash tables configured (established 131072 bind 65536)
TCP reno registered
audit: initializing netlink socket (disabled)
audit(1230701013.253:1): initialized
VFS: Disk quotas dquot_6.5.1
Dquot-cache hash table entries: 512 (order 0, 4096 bytes)
Initializing Cryptographic API
ksign: Installing public key data
Loading keyring
- Added public key 52394A11B61A91
- User ID: CentOS (Kernel Module GPG key)
io scheduler noop registered
io scheduler anticipatory registered
io scheduler deadline registered
io scheduler cfq registered (default)
pci_hotplug: PCI Hot Plug PCI Core version: 0.5
rtc: IRQ 8 is not free.
Non-volatile memory driver v1.2
Linux agpgart interface v0.101 (c) Dave Jones
RAMDISK driver initialized: 16 RAM disks of 16384K size 4096 blocksize
Xen virtual console successfully installed as xvc0
Event-channel device installed.
Uniform Multi-Platform E-IDE driver Revision: 7.00alpha2
ide: Assuming 50MHz system bus speed for PIO modes; override with idebus=xx
ide-floppy driver 0.99.newide
usbcore: registered new driver hiddev
usbcore: registered new driver usbhid
drivers/usb/input/hid-core.c: v2.6:USB HID core driver
PNP: No PS/2 controller found. Probing ports directly.
i8042.c: No controller found.
mice: PS/2 mouse device common for all mice
md: md driver 0.90.3 MAX_MD_DEVS=256, MD_SB_DISKS=27
md: bitmap version 4.39
TCP bic registered
Initializing IPsec netlink socket
NET: Registered protocol family 1
NET: Registered protocol family 17
XENBUS: Device with no driver: device/vbd/51712
XENBUS: Device with no driver: device/vif/0
Write protecting the kernel read-only data: 461k

Greetings.
anaconda installer init version 11.1.2.113 starting
mounting /proc filesystem... done
creating /dev filesystem... done
mounting /dev/pts (unix98 pty) filesystem... done
mounting /sys filesystem... done
anaconda installer init version 11.1.2.113 using /dev/xvc0 as console
trying to remount root filesystem read write... done
mounting /tmp as ramfs... done
running install...
running /sbin/loader
Jan 022009
 

CentOS 5.2のXen環境にDomain-U Debian(sid)を構築してみた。
ディスクはイメージファイルではなく、論理ボリューム区画を割り当てている。
論理ボリューム区画にしてみたのは、将来ディスク領域が不足したときDomain0で割り当てを増やし(lvextend)、DomainUでファイルシステムをオンラインリサイズ(ext2online)できないものかと考えたから。

論理ボリュームの割り当てとフォーマット

vg00はCentOSセットアップ時に作成したボリュームグループ。

# lvcreate -L 96M -n debian_boot vg00
# lvcreate -L 1024M -n debian_swap vg00
# lvcreate -L 8192M -n debian_root vg00
# mke2fs -j /dev/vg00/debian_boot
# mke2fs -j /dev/vg00/debian_root
# mkswap /dev/vg00/debian_swap

論理ボリュームをマウント

# mkdir /mnt/debian
# mount /dev/vg00/debian_root /mnt/debian
# mkdir /mnt/debian/boot
# mount /dev/vg00/debian_boot /mnt/debian/boot

debootstrapコマンドの準備

debootstrapコマンドをインストール。rpmパッケージ管理外のファイルが/usr/binや/usr/lib直下に配置されるが良しとする。

# cd /usr/local/src
# wget -N http://ftp.debian.org/debian/pool/main/d/debootstrap/debootstrap_0.3.3.2_all.deb
# yum -y install binutils
# ar -x debootstrap_0.3.3.2_all.deb
# cd /
# zcat /usr/local/src/data.tar.gz | tar xvp

Debianインストール

debootstrapコマンドで論理ボリューム上にDebianをインストール。

# /usr/sbin/debootstrap --arch amd64 sid /mnt/debian http://ftp.jp.debian.org/debian

セットアップ

セットアップのためインストールしたDebianにchrootする。

# chroot /mnt/debian
# mount -t proc proc /proc
  • /etc/fstab作成
    # /etc/fstab: static file system information.
    #
    /dev/sda1    /boot   ext3    ro,nosuid,nodev         0 2
    /dev/sda2    /       ext3    defaults                0 1
    /dev/sda3    none    swap    sw                      0 0
    proc         /proc   proc    defaults                0 0
    
  • kernelイメージインストール
    # aptitude install linux-image-xen-amd64
    
  • /etc/inittabにXen用コンソール定義追加
    以下を追加。ラベルは重複しないものを適当に割り当てた。

    h0:12345:respawn:/sbin/getty 38400 hvc0
    x0:12345:respawn:/sbin/getty 38400 xvc0
    

    ちなみにDebian sidの場合、hvcもxvcも/etc/securettyには定義済み(以下、抜粋)。

    # Standard hypervisor virtual console
    hvc0
    
    # Oldstyle Xen console
    xvc0
    
  • /boot/grub/grub.conf作成
    boot=/dev/sda
    default=0
    timeout=5
    #splashimage=(hd0,0)/grub/splash.xpm.gz
    hiddenmenu
    title Debian (2.6.26-1-xen-amd64)
            root (hd0,0)
            kernel /vmlinuz-2.6.26-1-xen-amd64 ro root=/dev/sda2 xencons=xvc console=xvc0
            initrd /initrd.img-2.6.26-1-xen-amd64
    

    kernelパラメータにXen用コンソール定義、xvcを追加している。

  • /boot/grub/menu.lst作成(grub.confにシンボリックリンク)
    # cd /boot/grub
    # ln -s grub.conf menu.lst
    
  • /boot/grub/device.map作成
    (hd0)   /dev/sda
    
  • DomainU設定ファイル作成

    /etc/xen/debianで作成

    name = "debian"
    uuid = "4917533f-38ac-4650-a342-dd468650b2d3"
    maxmem = 384
    memory = 384
    vcpus = 1
    bootloader = "/usr/bin/pygrub"
    disk = [ 'phy:vg00/debian_boot,sda1,w',
             'phy:vg00/debian_root,sda2,w',
             'phy:vg00/debian_swap,sda3,w' ]
    vif = [ "mac=00:16:3e:27:ea:aa,bridge=xenbr0" ]
    on_poweroff = 'destroy'
    on_reboot   = 'restart'
    on_crash    = 'restart'
    

    uuidはuuidgenを使って生成。
    vifのMACアドレスは『19.22. MAC アドレス生成の為のスクリプト作成』に掲載されているmacgen.pyスクリプトを用意して生成。

    最初の目的であるファイルシステム拡張がおこなえるかどうかは後日。

    参考サイト

    Dec 292008
     

    格安サーバのHP ML115 G5にVMware ESXi(Version 3.5 Update 3 | 123629 – 11/06/08)をインストールしてみた。
    巷で見かけるUSBメモリをブートデバイスにして動かす方法ではなく、インストール途中でチェックスクリプトを書き換えて
    ハードディスクに無理やりインストールしてしまう方法。

    当然のことながらベンダーの動作保証外だし、今後のアップグレードを無事おこなっていけるかも含めて無保証。

    • インストールメディアを用意して起動。
    • Welcome screenが表示されたらInstallに進まずに、Alt+F1を押してターミナルに切り替える。
    • ログインプロンプトが表示されているので、ユーザー:root、パスワード:空でログインする。
    • インストーラのpythonプロセスをkillする。
    • エディタ(viが使えます)で/usr/lib/vmware/installer/Core/TargetFilter.pyの73行目(IDEFilterのところ)を以下のとおり書き換える。
      return interface.GetInterfaceType() == ScsiInterface.SCSI_IFACE_TYPE_IDE
      ↓
      return interface.GetInterfaceType() == ScsiInterface.SCSI_IFACE_TYPE_ISCSI
      
    • インストーラを起動する。
      /sbin/install
      
    • あとは普通にインストールできると思う。

      こちらのサイトを参考にさせていただいた。
      VMware ESXi on an HP Proliant ML115 G5 at Tom’s FreeBSD blog

      ■2008-12-30追記
      このあと再インストールを試みたが、スクリプト変更後に起動したインストーラの画面表示がうまくおこなわれず、先に進めなかった orz
      最初だけうまくいったのは偶然だったのか 😕
      ISOイメージに含まれるinstall.tgzに含まれるスクリプトを予め変更しておいて、途中で中断せずに進めたほうが確実かもしれない。どっちにせよ無保証だが。