XenのゲストOS(FedoraCore4)をインストールする
(FedoraCore4)
Modified: 21 August 2005
イメージファイルの作成
まず、HDDのイメージファイルを作成します。
以下で、2GBのHDDイメージが作れます。
# dd if=/dev/zero of=/root/fc4.img bs=1M count=1 seek=2048 読み込んだブロック数は 1+0 書き込んだブロック数は 1+0 # mke2fs -F -j /root/fc4.img mke2fs 1.37 (21-Mar-2005) warning: 256 blocks unused. Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) 262656 inodes, 524288 blocks 26227 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=536870912 16 block groups 32768 blocks per group, 32768 fragments per group 16416 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912 Writing inode tables: done Creating journal (8192 blocks): done Writing superblocks and filesystem accounting information: done This filesystem will be automatically checked every 24 mounts or 180 days, whichever comes first. Use tune2fs -c or -i to override. #
確認
確認します。"ls"コマンドでみると、2GBですが、"du"コマンドで見ると、67MBです。これは、2GBの領域を予約しただけで、実際には67MBです。使っっていくと2GBまで拡張できます。
# ls -l /root 合計 67736 drwxr-xr-x 2 root root 4096 8月 20 02:00 Desktop -rw------- 1 root root 1311 8月 19 02:16 anaconda-ks.cfg -rw-r--r-- 1 root root 2148532224 8月 20 02:36 fc4.img -rw-r--r-- 1 root root 94738 8月 19 02:16 install.log -rw-r--r-- 1 root root 9960 8月 19 02:16 install.log.syslog # du fc4.img 67620 fc4.img #
最初から2GBの領域を確保しておきたい場合(そのほうがパフォーマンスは高い)、以下のように指定します。
# dd if=/dev/zero of=/root/fc4.img bs=1M count=2048
デバイスファイルの作成
まずマウントします。
# mount -o loop /root/fc3.img /mnt以下のコマンドで、デバイスファイルを作成します。
# mkdir /mnt/dev # MAKEDEV -d /mnt/dev -x console # MAKEDEV -d /mnt/dev -x null # MAKEDEV -d /mnt/dev -x zero # mkdir /mnt/proc # mount -t proc none /mnt/proc
yumでインストールする
ゲストOSは、yumでインストールしますので、その準備設定をします。
ゲストOSのCDを持っていてもCDからインストールできないようです。
rpmの設定ファイルを生成
まずは、rpmの設定ファイルを作ります。
# rpm --root /mnt --initdb # rpm --root /mnt --import /usr/share/rhn/RPM-GPG-KEY # rpm --root /mnt --import /usr/share/rhn/RPM-GPG-KEY-fedora
yumの設定ファイルを作成
yum用のフォルダを作ります。
# mkdir -p /mnt/var/cache/yum # mkdir -p /mnt/etc/yum.repos.d # cp /etc/yum.conf /mnt/etc/設定ファイル、"/mnt/etc/yum.repos.d/frdora.repo"を、"vi" で作ります。
[base] name=Fedora Core 4 - i386 - Base baseurl=http://ftp.kddilabs.jp/Linux/packages/fedora/core/4/i386/os/ enabled=1 gpgcheck=1設定ファイル、"/mnt/etc/yum.repos.d/frdora-updates.repo"を、"vi" で作ります。
[base] name=Fedora Core 4 - i386 - Base baseurl=http://ftp.kddilabs.jp/Linux/packages/fedora/core/4/i386/os/ enabled=1 gpgcheck=1
"fstab"の作成
途中で、"fstab"が参照されますので、以下の内容で、"/mnt/etc/fstab" を作っておきます。
/dev/sda1 / ext3 defaults 1 1 none /dev/pts devpts gid=5,mode=620 0 0 none /dev/shm tmpfs defaults 0 0 none /proc proc defaults 0 0 none /sys sysfs defaults 0 0
インストールの実行
インストールを開始します。
# yum --installroot=/mnt -y groupinstall base
ドメインU(ゲストOS)のサービス起動
xenのサービスを起動し、以降、自動起動されるようにしておきます。
設定ファイルを作る
"xmexample1"をコピーして、"/etc/xen/fc4.conf"を作ります。
カーネルは、"/boot"を見て、最後が、"xenU"となっているファイル名を書きます。
## -*- mode: python; -*-
#============================================================================
# Python configuration setup for 'xm create'.
# This script sets the parameters used when a domain is created using 'xm create'.
# You use a separate script for each domain you want to create, or
# you can set the parameters for the domain on the xm command line.
#============================================================================
#----------------------------------------------------------------------------
# Kernel image file.
kernel = "/boot/vmlinuz-2.6.11-1.1369_FC4xenU"
# Optional ramdisk.
#ramdisk = "/boot/initrd.gz"
# The domain build function. Default is 'linux'.
#builder='linux'
# Initial memory allocation (in megabytes) for the new domain.
memory = 128
# A name for your domain. All domains must have different names.
name = "FedoraCore4"
# Which CPU to start domain on?
#cpu = -1 # leave to Xen to pick
# Number of Virtual CPUS to use, default is 1
#vcpus = 1
#----------------------------------------------------------------------------
# Define network interfaces.
# Number of network interfaces. Default is 1.
#nics=1
# Optionally define mac and/or bridge for the network interfaces.
# Random MACs are assigned if not given.
#vif = [ 'mac=aa:00:00:00:00:11, bridge=xen-br0' ]
#----------------------------------------------------------------------------
# Define the disk devices you want the domain to have access to, and
# what you want them accessible as.
# Each disk entry is of the form phy:UNAME,DEV,MODE
# where UNAME is the device, DEV is the device name the domain will see,
# and MODE is r for read-only, w for read-write.
disk = [ 'file:/root/fc4.img,sda1,w' ]
#----------------------------------------------------------------------------
# Set the kernel command line for the new domain.
# You only need to define the IP parameters and hostname if the domain's
# IP config doesn't, e.g. in ifcfg-eth0 or via DHCP.
# You can use 'extra' to set the runlevel and custom environment
# variables used by custom rc scripts (e.g. VMID=, usr= ).
# Set if you want dhcp to allocate the IP address.
#dhcp="dhcp"
# Set netmask.
#netmask=
# Set default gateway.
#gateway=
# Set the hostname.
#hostname= "vm%d" % vmid
# Set root device.
root = "/dev/sda1 ro"
# Root device for nfs.
#root = "/dev/nfs"
# The nfs server.
#nfs_server = '169.254.1.0'
# Root directory on the nfs server.
#nfs_root = '/full/path/to/root/directory'
# Sets runlevel 4.
extra = "4"
#----------------------------------------------------------------------------
# Set according to whether you want the domain restarted when it exits.
# The default is 'onreboot', which restarts the domain when it shuts down
# with exit code reboot.
# Other values are 'always', and 'never'.
#restart = 'onreboot'
#============================================================================
起動してみる
起動前に、メモリを確保します。
# xm balloon 0 256 #そして、起動してみます。
# xm create -c /etc/xen/fc4.conf Using config file "/etc/xen/fc4.conf". Started domain FedoraCore4, console on port 9607 ************ REMOTE CONSOLE: CTRL-] TO QUIT ******** Linux version 2.6.11-1.1369_FC4xenU (bhcompile@decompose.build.redhat.com) (gcc version 4.0.0 20050525 (Red Hat 4.0.0-9)) #1 SMP Thu Jun 2 23:33:51 EDT 2005 BIOS-provided physical RAM map: Xen: 0000000000000000 - 0000000008000000 (usable) 128MB LOWMEM available. Using x86 segment limits to approximate NX protection DMI not present. IRQ lockup detection disabled Allocating PCI resources starting at 08000000 (gap: 08000000:f8000000) Built 1 zonelists Kernel command line: root=/dev/sda1 ro 4 Initializing CPU#0 PID hash table entries: 1024 (order: 10, 16384 bytes) Xen reported: 2259.236 MHz processor. Using tsc for high-res timesource Dentry cache hash table entries: 32768 (order: 5, 131072 bytes) Inode-cache hash table entries: 16384 (order: 4, 65536 bytes) Memory: 125440k/131072k available (1785k kernel code, 5384k reserved, 506k data, 156k init, 0k highmem) Checking if this processor honours the WP bit even in supervisor mode... Ok. Security Framework v1.0.0 initialized SELinux: Initializing. SELinux: Starting in permissive mode selinux_register_security: Registering secondary module capability Capability LSM initialized as secondary Mount-cache hash table entries: 512 CPU: Trace cache: 12K uops, L1 D cache: 8K CPU: L2 cache: 512K Enabling fast FPU save and restore... done. Enabling unmasked SIMD FPU exception support... done. Checking 'hlt' instruction... disabled CPU0: Intel(R) Pentium(R) 4 CPU 2.26GHz stepping 08 per-CPU timeslice cutoff: 1462.82 usecs. task migration cache decay timeout: 2 msecs. SMP motherboard not detected. smpboot_clear_io_apic_irqs Brought up 1 CPUs softlockup thread 0 started up. NET: Registered protocol family 16 xen_mem: Initialising balloon driver. Grant table initialized audit: initializing netlink socket (disabled) audit(1124516999.088:1): initialized Total HugeTLB memory allocated, 0 VFS: Disk quotas dquot_6.5.1 Dquot-cache hash table entries: 1024 (order 0, 4096 bytes) SELinux: Registering netfilter hooks Initializing Cryptographic API ksign: Installing public key data Loading keyring - Added public key 42BD35A990375F72 - User ID: Red Hat, Inc. (Kernel Module GPG key) io scheduler noop registered io scheduler anticipatory registered io scheduler deadline registered io scheduler cfq registered RAMDISK driver initialized: 16 RAM disks of 16384K size 1024 blocksize Xen virtual console successfully installed as tty1 Event-channel device installed. Blkif frontend is using grant tables. xen_blk: Initialising virtual block device driver xen_net: Initialising virtual ethernet driver. md: md driver 0.90.1 MAX_MD_DEVS=256, MD_SB_DISKS=27 NET: Registered protocol family 2 IP: routing cache hash table of 512 buckets, 8Kbytes TCP established hash table entries: 8192 (order: 5, 131072 bytes) TCP bind hash table entries: 8192 (order: 4, 98304 bytes) TCP: Hash tables configured (established 8192 bind 8192) Initializing IPsec netlink socket NET: Registered protocol family 1 NET: Registered protocol family 17 md: Autodetecting RAID arrays. md: autorun ... md: ... autorun DONE. kjournald starting. Commit interval 5 seconds EXT3-fs: mounted filesystem with ordered data mode. VFS: Mounted root (ext3 filesystem) readonly. Freeing unused kernel memory: 156k freed security: 3 users, 6 roles, 827 types, 100 bools security: 55 classes, 196759 rules SELinux: Completing initialization. SELinux: Setting up existing superblocks. SELinux: initialized (dev sda1, type ext3), uses xattr SELinux: initialized (dev selinuxfs, type selinuxfs), uses genfs_contexts SELinux: initialized (dev mqueue, type mqueue), uses genfs_contexts SELinux: initialized (dev hugetlbfs, type hugetlbfs), uses genfs_contexts SELinux: initialized (dev devpts, type devpts), uses transition SIDs SELinux: initialized (dev eventpollfs, type eventpollfs), uses genfs_contexts SELinux: initialized (dev tmpfs, type tmpfs), uses transition SIDs SELinux: initialized (dev futexfs, type futexfs), uses genfs_contexts SELinux: initialized (dev pipefs, type pipefs), uses task SIDs SELinux: initialized (dev sockfs, type sockfs), uses task SIDs SELinux: initialized (dev cpuset, type cpuset), not configured for labeling SELinux: initialized (dev proc, type proc), uses genfs_contexts SELinux: initialized (dev bdev, type bdev), uses genfs_contexts SELinux: initialized (dev rootfs, type rootfs), uses genfs_contexts SELinux: initialized (dev sysfs, type sysfs), uses genfs_contexts INIT: version 2.85 booting /etc/rc.d/rc.sysinit: line 78: /dev/tty1: Read-only file system /etc/rc.d/rc.sysinit: line 78: /dev/tty2: Read-only file system /etc/rc.d/rc.sysinit: line 78: /dev/tty3: Read-only file system /etc/rc.d/rc.sysinit: line 78: /dev/tty4: Read-only file system /etc/rc.d/rc.sysinit: line 78: /dev/tty5: Read-only file system /etc/rc.d/rc.sysinit: line 78: /dev/tty6: Read-only file system /etc/rc.d/rc.sysinit: line 82: /dev/tty7: Read-only file system /etc/rc.d/rc.sysinit: line 83: /dev/tty8: Read-only file system Welcome to Fedora Core Press 'I' to enter interactive startup. Starting udev: MAKEDEV: mkdir: File exists [FAILED] Initializing hardware... storage network audio done[ OK ] Setting clock : Sat Aug 20 01:53:41 EDT 2005 [ OK ] Setting hostname localhost: [ OK ] Checking filesystems Checking all file systems. [/sbin/fsck.ext3 (1) -- /] fsck.ext3 -a /dev/sda1 /dev/sda1: clean, 27527/262656 files, 206966/524288 blocks [ OK ] Remounting root filesystem in read-write mode: [ OK ] Mounting local filesystems: [ OK ] Enabling local filesystem quotas: [ OK ] Enabling swap space: [ OK ] INIT: Entering runlevel: 4 Entering non-interactive startup Checking for new hardwaremodprobe: FATAL: Could not load /lib/modules/2.6.11-1.1369_FC4xenU/modules.dep: No such file or directory mmap /dev/mem: Resource temporarily unavailable mmap /dev/mem: Resource temporarily unavailable modprobe: FATAL: Could not load /lib/modules/2.6.11-1.1369_FC4xenU/modules.dep: No such file or directory [ OK ] Starting pcmcia: Starting PCMCIA services: FATAL: Could not load /lib/modules/2.6.11-1.1369_FC4xenU/modules.dep: No such file or directory [FAILED] Starting system logger: [ OK ] Starting kernel logger: [ OK ] Networking not configured - exiting Starting auditd: [ OK ] Can't open RFCOMM control socket: Address family not supported by protocol Starting automount: [ OK ] Starting cups: [ OK ] Generating SSH1 RSA host key: [ OK ] Generating SSH2 RSA host key: [ OK ] Generating SSH2 DSA host key: [ OK ] Starting sshd: [ OK ] Starting sendmail: [ OK ] Starting sm-client: [ OK ] Starting console mouse services: O0o.oops(): [console.c(253)]: Can't determine console device [FAILED] Starting crond: [ OK ] Starting anacron: [ OK ] Starting atd: [ OK ] Starting system message bus: [ OK ] Starting HAL daemon: [ OK ] Fedora Core release 4 (Stentz) Kernel 2.6.11-1.1369_FC4xenU on an i686 localhost login:途中で、エラーが出たりしていますが、とりあえず起動しました。
確認してみます。
# xm list Name Id Mem(MB) CPU State Time(s) Console Domain-0 0 256 0 r---- 437.2 FedoraCore4 7 128 0 -b--- 391.9 9607 #