Xen Notes


Dynamically add device to running DOMU

xm block-attach domain block/device/on/dom0 ''/device/on/domu' 1

Example, you want running domain fileserver to have access to device /dev/sdc1 and be able to read and write to it. You want it to be called xvdb1 on the domu

xm block-attach fileserver phy:/dev/sdc1 xvdb1 w

From the DOMU, you can now issue the command

mount /dev/xvdb1 /mnt

and write to it

Dynamically Remove device from running DOMU

First, you must list all devices attached so you can find the correct device id

xm block-list fileserver

This will return a list similar to:

Vdev  BE handle state evt-ch ring-ref BE-path
51714  0    0     4      8      8     /local/domain/0/backend/vbd/9/51714  
51715  0    0     4      10     770   /local/domain/0/backend/vbd/9/51715  
51713  0    0     4      11     771   /local/domain/0/backend/vbd/9/51713  
51729  0    0     4      12     870   /local/domain/0/backend/vbd/9/51729  

The value on the left is the device id. Of course, the rest is very cryptic. First, you need to know the ID of your DOMU. Just do an

xm list

and see the correct ID for your running DOM. Now, to find which drive is what, execute the command:

xenstore-ls | less

and search for your domainID. This is fairly simple as, in Xen4, the output is of the form:

domid = ""

where domid is the numeric ID of your domain. So, search for that. Underneath, you will find a list of all hard drives with more information than you ever needed. So, in this case, we know we are looking for a USB drive, sdb, and we mounted the first partition. Find a line that says"

params = "/dev/sdb1"

and see what section it is in (in this case, 51729)

Now, remove it from the DOMU

xm block-detach domain-id 51729
Last update:
2012-02-10 05:31
Author:
Rod
Revision:
1.2
Average rating:0 (0 Votes)

You cannot comment on this entry

Chuck Norris has counted to infinity. Twice.