Xen shell commands
Xen shell commands
精选 转载Some more or less commonly used shell commands for managing Xen Virtual Machines (VM, also called Domains). Tested on Xen 3.0, should work also in other versions.
Basic commands
Show the running Virtual Machines: xm list
Start a virtual machine (myhost): xm create myhost
Gracefully shutdown (soft-reset) a virtual machine: xm shutdown myhost
Forced power Off (hard-reset) of a virtual machine: xm destroy myhost
Reboot a VM : xm reboot myhost
Using the console
Start a virtual machine and attach immediately a console: xm create -c myhost
Attach to the console of a VM (sample ID=4 for myhost, as shown in xm list):
xm console myhost or xm console 4
To leave / detach from the xen console press CTRL+5
Resources management and usage
To alter the RAM assigned to a VM (sample 256 Mb): xm mem-set myhost 256
To alter the CPUs assigned to a VM (sample 2 CPUs or cores): xm vcpu-set myhost 2
Shows resource utilization of the running hosts: xm top or xentop
Shows Virtual Machines uptimes: xm uptime
Saving and Restoring
Virtual Machines state can be saved on a file and later restored (sample destination file /var/tmp/myhost.save)
xm save myhost /var/tmp/myhost.save
Note that after this command the VM is no longer active: you can reboot from start it with xm create myhost or restore the saved machine state with xm restore /var/tmp/myhost.save
Note also that the save file ( /var/tmp/myhost.save ) is only the dump on the VM memory, for backups it's of no use if you copy it to another physical host without copying also the VM config file and the file/LVM/partition used for the disk) .
Block Devices management
It's is possible to add block devices (disks) to a running VM:
To add a local file ( /var/tmp/data.disk ) as /dev/xvdc to the myhost paravirtualized VM, in write mode:
xm block-attach myhost file://var/tmp/data.disk /dev/xvdc w
Mode can be: w (read/write), r (read only), w! (shared read/write, when the samer device is attached to two different VMs).
The above file can be created (here 4 Gb) with:
dd if=/dev/zero of=/var/tmp/data.disk bs=1024k count=4096
To add a local physical disk, partition or LVM (for example an USB stick):
xm block-attach myhost phy://dev/sda /dev/xvdc w
Note that I/O performances are much better when using physical devices or LVM instead of plain files as block devices for the VMs.
To list the currently attached block devices to a VM:
xm block-list myhost --long or xm block-list myhost
To detach a block device (51744 is the Vdev in xm block-list)
xm block-detach myhost 51744
Bridging management
On Linux the bridge utils can be used to show and manage bridging:
brctl show
brctl showmacs xenbr0
To manually create a new xen bridge interface and associate it a physical device.
brctl addbr xenbr2
brctl addif peth3
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
Shell built-in commands
shell有许多内置命令,我将它们罗列于此,以方便查找。
职场 shell 休闲 commands built-in -
android开发笔记之ADB Shell Commands
对于android开发来说,adb shell 命令是我们经常使用的开发命令,下面对这些常用的关键adb shell 命令进行一些说明
android shell 数据 android开发 -
git commands
git 常用命令
仓库 git 远程版本库 -
linux commands
工作中有时候回碰到一些命令符号,收集了一部分Linux command符号,希望对大家有所帮助。
linux 职场 Linux 休闲