X

An Oracle blog about Exadata

  • January 10, 2009

Adding a block device online to an Oracle VM

Rene Kundersma
Software Engineer



In a previous blog posting an example has been given how to resize the root filesystem of your Oracle VM template. In a comment on this blog someone asked how to add a block device to a running Oracle VM. This block device could then be used to put the filesystem on.

Here is the answer.




My Oracle VM Server indicates there are 4 guests running (without Dom0):


[root@ovms1 ]# xm list

Name ID Mem VCPUs State Time(s)

Domain-0 0 667 4 r----- 1905.1

oel-repos 1 1400 2 -b---- 62.1

openfiler1 2 256 1 -b---- 122.5

vdb11a 10 1400 1 -b---- 24.3

vsupp1 6 1500 2 -b---- 984.3




So, for the vdb11a we want to add a block device online. First we create a file which we will use as 'block device".


[root@ovms1 ]# dd if=/dev/zero of=extradisk01.img bs=1M count=100

100+0 records in

100+0 records out

104857600 bytes (105 MB) copied, 0.194952 seconds, 538 MB/s




Then, we attach this file as a block to the VM with ID 10 (vdb11a):


[root@ovms1 ]# xm block-attach 10 file:`pwd`/extradisk01.img /dev/xvdc1 w




The 'w' indicates the disk is read/write available, but other options are available, this is the syntax:


xm block-attach domain-id be-dev fe-dev mode [bedomain-id]

Create a new virtual block device. This will trigger a hotplug event for the guest.

OPTIONS

domain-id The domain id of the guest domain that the device will be attached to.

be-dev The device in the backend domain (usually domain 0) to be exported.

This can be specified as a physical partition (phy:sda7) or as a file

mounted as loopback (file://path/to/loop.iso).

fe-dev How the device should be presented to the guest domain. It can be specified

as either a symbolic name, such as /dev/hdc, for common devices, or by

device id, such as 0x1400 (/dev/hdc device id in hex).

mode The access mode for the device from the guest domain.

Supported modes are w (read/write) or r (read-only).

w! will make the hypervisor think the vbd attached to multiple domains to be ok.

bedomain-id The back end domain hosting the device. This defaults to domain 0.








In the syslog of the VM guest you see the disk coming in:


Jan 10 20:52:58 vdb11a kernel: Registering block device major 202




Let's double check if this is our disk, it should be about 100M


[root@vdb11a ~]# fdisk -l /dev/xvdc1

Disk /dev/xvdc1: 104 MB, 104857600 bytes

255 heads, 63 sectors/track, 12 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes

Disk /dev/xvdc1 doesn't contain a valid partition table

[root@vdb11a ~]#





There is also an option to detach the block device

Please note also to add the file to the vm.cfg because if you forget, the next time you wonder where the device is.




Rene Kundersma

Oracle Expert Services, The Netherlands

Join the discussion

Comments ( 1 )
  • Peter Sunday, January 11, 2009
    Rene,
    Execellent job! That is exactly what I was looking for.
    Thank you.
    regards
    /Peter
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.