How EXACTLY to use dev DATASTORE?

I’ve read every doc but cannot on earth understand - how can I use dev datastore in opennebula?
When I add it through Sunstone’s web interface I can see it:

ID 	106 	
Name 	dev-test 	
Cluster 	- 	
Base path 	/home/datastores/106 	
Capacity 	0MB / 1MB (0%)
Limit 	-
Permissions: 	Use 	Manage 	Admin

Attributes
BASE_PATH 	/home/datastores/ 	 
CLONE_TARGET 	NONE 	 
DISK_TYPE 	BLOCK 	 
DS_MAD 	dev 	 
LN_TARGET 	NONE 	 
TM_MAD 	dev 	 
TYPE 	IMAGE_DS

But what now?
First, there in NO such directory “106” in /home/datastores. Probably it shouldn’t be created at this step?
I don’t know, because there is not a single word about it in manual.
Ok, I created directory 106 manually and chowned it to oneadmin. Now if I get it right I can add some device there.
I tried to mount a disk from my Qnap storage which I get through iSCSI to /home/datastores/106, but obviously it is impossible, because this disk doesn’t contain a FS yet. If I create a fs there I would be able to mount it, but it would be a FS-storage, not BLOCK!
How can one use dev datastorage to “attach existing block devices directly to the VMs”?
The same stalemate situation with iSCSI DATASTORE :frowning:
Please, guide me in right direction as I’m lost here…

upd: ok, I’ve managed to add an Image with pat=/dev/sde1 to dev datastore, but for opennebula could use it one have to change owner of created link (in my case it is ‘/home/datastores/0/72/disk.0’) to oneadmin or you’ll get this error:

Mon Feb 16 11:04:29 2015 [Z0][VMM][I]: error: Failed to create domain from /home/datastores/0/72/deployment.2
Mon Feb 16 11:04:29 2015 [Z0][VMM][I]: error: Failed to open file '/home/datastores/0/72/disk.0': No such file or directory

It works the same as the rest of the datastores. If you want this datastore to be available in all the nodes then you must create it and mount nfs or any other shared filesystem in every node. If it’s not shared or you only have one node the directory should be created when the first image is added to the datastore.

You can get more general information about datastores at The Filesystem Datastore — OpenNebula 4.10.2 documentation

When you are using dev datastore you are attaching a system device to a VM, not a filesystem. You should make sure that the device already exists in the node the VM is going to run. You can do it adding scheduler options in the template.

The problem you have could be caused by two things:

  • You are using a shared datastore and the directory /home/datastores/0 is not shared between hosts.

  • The file is there and is a symlink to a device that does not exist in the node. You can check executing in the host:

      ls -l /home/datastores/0/72/disk.0
    

I cannot unbderstand this, sorry.
How can I attach a system device directly to VM, bypassing attaching it to file system? To use a system device I have to attach it to any working host, don’t I? If my VM is not working yet, how a system device could be attached to it?

Hi,

We already use the device datastore to give physical SSDs directly to our MongoDB virtual machines.
I used the guide in the Opennebula docs and it worked pretty straight forward -> http://docs.opennebula.org/4.10/administration/storage/dev_ds.html

So thats what I did (on Ubuntu 14.04 host with KVM as hypervisor)

  1. I created a partition on the SSD
  2. I created a filesystem (could also be done from inside the VM I assume)
  3. I added oneadmin to the disk group (else oneadmin would not be allowed to access the disk): usermod -G disk -a oneadmin
  4. created the datastore in Opennebula (I used sunstone) with these settings (output of one datastore show)
    DATASTORE 138 INFORMATION
    ID : 138
    NAME : mongodb_device
    USER : oneadmin
    GROUP : oneadmin
    CLUSTER : -
    TYPE : IMAGE
    DS_MAD : dev
    TM_MAD : dev
    BASE PATH : /var/lib/one//datastores/138
    DISK_TYPE : BLOCK

DATASTORE CAPACITY
TOTAL: : 1M
FREE: : 1M
USED: : 0M
LIMIT: : -

PERMISSIONS
OWNER : um-
GROUP : u–
OTHER : —

DATASTORE TEMPLATE
BASE_PATH="/var/lib/one//datastores/"
CLONE_TARGET="NONE"
DISK_TYPE="BLOCK"
DS_MAD="dev"
LN_TARGET="NONE"
TM_MAD="dev"
TYPE=“IMAGE_DS”

  1. I created an image representing the physical disk. (again output of oneimage show)
    IMAGE 582 INFORMATION
    ID : 582
    NAME :
    USER : oneadmin
    GROUP : oneadmin
    DATASTORE : mongodb_device
    TYPE : DATABLOCK
    REGISTER TIME : 12/09 09:49:38
    PERSISTENT : Yes
    SOURCE : (eg.: /dev/sdb1)
    PATH : (eg.: /dev/sdb1)
    SIZE : 0M
    STATE : used
    RUNNING_VMS : 1

PERMISSIONS
OWNER : um-
GROUP : —
OTHER : —

IMAGE TEMPLATE
DEV_PREFIX=“vd”

  1. then I added the image to a VM and bootet
  2. finished.

I have to add, that I use it as datadisk and not for booting, but I guess this could be done as well …

1 Like

What the dev datastore does is to use a device instead of a file as a disk. Before the VM is started it makes a symlink from the desired device to the disk in the system datastore, for example:

ln -s /dev/sdj /var/lib/one/datastores/0/disk.0

That way the VM will use /dev/sdj as the first disk.

You must make sure that the device exists in the host that is going to start the VM or it will fail. You can force the deployment of a VM in an specific host using scheduler requirements in the VM template. That can be done in the placement section of the VM template in sunstone.

Right, forgot to mention that you need to force the VM to the host with the device …