XM Commands

XM Commands

http://www.techotopia.com/index.php/Managing_Xen_using_the_xm_Command-line_Tool
List which virtual machines are running right now.
# xm list

Start the vm. By convention we will always have a file called vm.cfg
# xm create vm.cfg

Kill the power to vm: vm01, i.e. a hard shutdown
# xm destroy vm01

Monitors a host and its domains in real time # xm top 

Send the vm: vm01 the shutdown command, like doing a shutdown inside the vm
# xm shutdown vm01

Current status of the guest operating system is written to disk and removed from system memory
# xm suspend vm01

restore vm01 (any time including after a host system reboot)
# xm resume vm01

Not Finished:
add a disk to a running vm:   xm block-attach <Domain Id> <Backend Device> <Frontend Device> <Mode>. Domain Id is got from xm list command under the id column,  
# xm block-attach 3 phy:/dev/sr0 /dev/xvda2 r

Split / Join files

Sometime the files are too big to put on FAT32 thumbdrives. Use the split and cat commands here:

Split the file system.img into 3Gig chunks
# split --bytes=3000m system.img

Join up the files system.img.part1, system.img.part2, etc... into the file system.img
# cat system.img.part* > system.img

Make an extra Linux file system for your VM

Make a blank file 2 gigs large named stellent.img that will serve as our new disk
# dd if=/dev/zero of=stellent.img bs=1M count=2048

Edit the configuration file (/etc/xen/vm03), like below, adding the second line, notice xvda goes to xvdb
disk = [ 'file:/OVS/running_pool/vm03/system.img,xvda,w', 'file:/OVS/running_pool/vm03/stellent.img,xvdb,w']

The above line may also look like, the following, in that case use hdb in place ov xvdb.
disk = [ 'file:/OVS/running_pool/ucm1/system.img,hda,w','file:/OVS/running_pool/ucm1/stellent.img,hdb,w' ]

(NOTE) don't think you can use 'hdc' (only a and b), so you can use a combo of hd and xvd!

The following instructions came from the following link, use it as a reference if these instructions don't make sense
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch27_:_Expanding_Disk_Capacity#Expanding_Partitions_With_LVM

Here we created a new device, /dev/xvdb. Now we start up the vm and run fdisk  
# fdisk /dev/xvdb

You'll get some error messages saying you don't have a valid partition table. Create a new partition, ' n', primary =   'p', partition number =   '1',  default first and last cylinders.

List this partition table 'p' now and notice the Id type is 83 or something. Change this to 8e.   't', '8e'. List the partition table  'p', again, notice the new Id type is 8e. Save partition table  'w'.

Create a physical volume from this device
# pvcreate /dev/xvdb1

Create the logical volume group from the physical device
# vgcreate lvm-oracledb /dev/xvdb1

Create the logical volume using 100% of the free space in the logical group lvm-oracledb
# lvcreate -l 100%FREE lvm-oracledb -n lvm0

Format the file system
# mkfs -t ext3 /dev/lvm-oracledb/lvm0 

Create a mount point
# mkdir /oracledb

Add the following to /etc/fstab to automatically mount the volume when the computer starts up
/dev/lvm-oracledb/lvm0 /oracledb ext3 defaults 1 2
Mount the volume
# mount -a

DONE!!!

Remove a Disk (LVM)

Remove /etc/fstab entry
[root@vl-ucm1 ~]# vi /etc/fstab

Unmount the device, get device name with:   lvdisplay
# umount /dev/lvm-stellent/lvm0

OR

[root@vl-ucm1 /]# ls /u01
downloads lost+found oracle
[root@vl-ucm1 /]# umount /u01
[root@vl-ucm1 /]# ls /u01
[root@vl-ucm1 /]# 


If you get:  
[root@vl-ucm1 /]# umount /dev/lvm-stellent/lvm0
umount: /u01: device is busy


Find out what is using the device with:  
[root@vl-ucm1 /]# fuser -m /dev/lvm-stellent/lvm0
/dev/lvm-stellent/lvm0: 3557m 3620m 3621m 3622m 3623m 3624m 3625m 3626m 3627m
[root@vl-ucm1 /]# ps auxw| grep 3557
root 3557 0.0 0.5 10856 3104 ? Ss 10:55 0:00 /usr/sbin/httpd

[root@vl-ucm1 /]# service httpd stop
Stopping httpd: [ OK ]
[root@vl-ucm1 /]# umount /dev/lvm-stellent/lvm0
[root@vl-ucm1 /]# df -h

And you should no longer see the disk with 'df'

Remove any entries from /etc/httpd/conf/httpd.conf that refer to this disk.

use lvremove to remove the logical volume
[root@vl-ucm1 /]# lvremove /dev/lvm-stellent/lvm0
Do you really want to remove active logical volume "lvm0"? [y/n]: y
Logical volume "lvm0" successfully removed


use lgdisplay and lgremove to remove logical group
[root@vl-ucm1 /]# vgremove lvm-stellent
Volume group "lvm-stellent" successfully removed


use pvdisplay and pvremove to remove physical volume
[root@vl-ucm1 /]# pvremove /dev/hdb1
Labels on physical volume "/dev/hdb1" successfully wiped


remove partition with fdisk /dev/hdb, 'd', enter, 'w' = write partition and exit
# fdisk /dev/hdb

Remove the disk entry from the vm.cfg file, and restart the vm.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值