===== Xen ===== ===== Command ===== * DomainU(ゲストOS)の起動 # xm create vt01 ## コンソール付 # xm create -c vt01 * DomainUシャットダウン # xm shutdown vt01 # xm shutdown -w vt01 * コンソール接続(アタッチ) # xm console vt01 * コンソール切断(デタッチ) # Ctrl+"]" * Domain一覧表示 # xm list * Domain topコマンド # xm top ===== Xen VMのディスク容量拡張 ===== DomainU(develop)を停止する # xm shutdown develop イメージファイルのディレクトリに移動(デフォルト:/var/lib/xen/images/) # cd /var/lib/xen/images/ イメージファイルをリネーム # mv develop.img develop.img.bak 4GBのnullのファイル作成 # dd if=/dev/zero bs=1M count=0 seek=4096 of=./zero_4gb.img イメージファイルにnullファイルを結合 # cat develop.img.bak2 zero_4gb.img > develop.img 空きloopbackデバイスを確認 # losetup -f /dev/loop0 loopbackデバイスを設定 # losetup /dev/loop0 develop.img 設定されたことを確認 # losetup -a /dev/loop0: [fd00]:102891628 (develop.img) ドライブの設定情報を確認 # fdisk -lu /dev/loop0 Disk /dev/loop0: 15.0 GB, 15032385536 bytes 255 heads, 63 sectors/track, 1827 cylinders, total 29360128 sectors Units = sectors of 1 * 512 = 512 bytes Device Boot Start End Blocks Id System /dev/loop0p1 * 2048 1026047 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/loop0p2 1026048 20964824 9969388+ 8e Linux LVM シリンダを再設定 # fdisk /dev/loop0 The number of cylinders for this disk is set to 1827. There is nothing wrong with that, but this is larger than 1024, and could in certain setups cause problems with: 1) software that runs at boot time (e.g., old versions of LILO) 2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK) Command (m for help): d(エンター) Partition number (1-4): 2(エンター) Command (m for help): n(エンター) Command action e extended p primary partition (1-4) p(エンター) Partition number (1-4): 2(エンター) First cylinder (64-1827, default 64): (空エンター) Using default value 64 Last cylinder or +size or +sizeM or +sizeK (64-1827, default 1827): (空エンター) Using default value 1827 Command (m for help): t(エンター) Partition number (1-4): 2(エンター) Hex code (type L to list codes): 8e(エンター) Changed system type of partition 2 to 8e (Linux LVM) Command (m for help): p(エンター) Disk /dev/loop0: 15.0 GB, 15032385536 bytes 255 heads, 63 sectors/track, 1827 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Device Boot Start End Blocks Id System /dev/loop0p1 * 1 64 512000 83 Linux Partition 1 does not end on cylinder boundary. /dev/loop0p2 64 1827 14162353+ 8e Linux LVM Command (m for help): w(エンター) The partition table has been altered! Calling ioctl() to re-read partition table. WARNING: Re-reading the partition table failed with error 22: Invalid argument. The kernel still uses the old table. The new table will be used at the next reboot. Syncing disks. 使ったloopbackを削除 # losetup -d /dev/loop0 DomainU起動 # xm create develop Using config file "/etc/xen/develop". Using to parse /grub/menu.lst Started domain develop # ssh develop Last login: Tue Aug 20 09:56:41 2013 from galaga 以下、DomainUで作業 空き容量がない(0 free)ことを確認 # pvscan PV /dev/xvda2 VG VolGroup lvm2 [9.50 GiB / 0 free] Total: 1 [9.50 GiB] / in use: 1 [9.50 GiB] / in no VG: 0 [0 ] PVをリサイズ # pvresize /dev/xvda2 Physical volume "/dev/xvda2" changed 1 physical volume(s) resized / 0 physical volume(s) not resized 空き容量が増えている(4.02 GiB free)ことを確認 # pvscan PV /dev/xvda2 VG VolGroup lvm2 [13.50 GiB / 4.02 GiB free] Total: 1 [13.50 GiB] / in use: 1 [13.50 GiB] / in no VG: 0 [0 ] 論理ボリュームを確認 # lvscan ACTIVE '/dev/VolGroup/lv_root' [7.51 GiB] inherit ACTIVE '/dev/VolGroup/lv_swap' [1.97 GiB] inherit # df Filesystem 1K-blocks Used Available Use% Mounted on /dev/mapper/VolGroup-lv_root 7752828 4190860 3172672 57% / tmpfs 508356 0 508356 0% /dev/shm /dev/xvda1 495844 52690 417554 12% /boot # lvdisplay /dev/VolGroup/lv_root --- Logical volume --- LV Path /dev/VolGroup/lv_root LV Name lv_root VG Name VolGroup LV UUID RcqjQY-SEnk-ga6k-WeML-9FB3-RAma-ezZyhi LV Write Access read/write LV Creation host, time localhost.localdomain, 2012-10-09 16:57:43 +0900 LV Status available # open 1 LV Size 7.51 GiB Current LE 1923 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 256 Block device 253:0 論理ボリュームを4GB(先に確認したfree分)追加 # lvresize -L +4.02G /dev/VolGroup/lv_root Rounding size to boundary between physical extents: 4.02 GiB Extending logical volume lv_root to 11.54 GiB Logical volume lv_root successfully resized スライスを拡張 # resize2fs /dev/VolGroup/lv_root resize2fs 1.41.12 (17-May-2010) Filesystem at /dev/VolGroup/lv_root is mounted on /; on-line resizing required old desc_blocks = 1, new_desc_blocks = 1 Performing an on-line resize of /dev/VolGroup/lv_root to 3023872 (4k) blocks. The filesystem on /dev/VolGroup/lv_root is now 3023872 blocks long. LV Sizeが増えていることを確認 # lvdisplay /dev/VolGroup/lv_root | grep "LV Size" LV Size 11.54 GiB ディスク容量が増えていることを確認 # df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup-lv_root 12G 4.0G 6.8G 38% / tmpfs 497M 0 497M 0% /dev/shm /dev/xvda1 485M 52M 408M 12% /boot 全ての空き容量が割りあたったこと(0 Free)を確認 # pvscan PV /dev/xvda2 VG VolGroup lvm2 [13.50 GiB / 0 free] Total: 1 [13.50 GiB] / in use: 1 [13.50 GiB] / in no VG: 0 [0 ] ===== Link ===== * CENTOS5.7にXEN SERVERをインストールする(ホストOS) http://webcache.googleusercontent.com/search?q=cache:sb7d7q4wwO0J:www.s-quad.com/wordpress/%3Fp%3D1423+&cd=7&hl=ja&ct=clnk&gl=jp - http://webcache.googleusercontent.com/search?q=cache:AlcmODtUMOMJ:www.system-act.com/server/xen.html+&cd=1&hl=ja&ct=clnk&gl=jp - http://webcache.googleusercontent.com/search?q=cache:CwGAmPxOyRsJ:www.linuxmania.jp/xen_centos5.1.html+&cd=4&hl=ja&ct=clnk&gl=jp * VMWare上のCentOS 5 にXenゲストをインストールする http://webcache.googleusercontent.com/search?q=cache:J94F2P-1WmcJ:krakenbeal.blogspot.com/2011/02/vmwarecentos-5.html+&cd=16&hl=ja&ct=clnk&gl=jp * make seed http://webcache.googleusercontent.com/search?q=cache:v9MoQW1Vz_EJ:rewse.jp/blog/p/993+&cd=2&hl=ja&ct=clnk&gl=jp * from seed http://www.atmarkit.co.jp/flinux/rensai/xen04/xen04a.html