# "oneimage create" without copying the image

**URL:** <https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831>\
**Category:** Product Support\
**Created:** [June 8, 2015, 10:36am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831 "2015-06-08T10:36:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andy](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/andy/32/4280_2.png) [@Andy](https://forum.opennebula.io/u/Andy)\
**Post date:** [June 8, 2015, 10:36am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/1 "2015-06-08T10:36:26Z")

</div>

I’m not sure which version it changed, but in 3.8 at least, we could do the following:

oneimage create --name … --type OS --source /var/lib/one/datastores/1/image\_file

This let us copy images between different clusters/environments, and create an image using the same image\_file filename, and avoiding it cloning the image file to a randomly generated filename like it does if you use --path in 4.x

If we can’t do that anymore, is there any way of setting the final filename that the image will clone to rather than random?

---

<div class="post-metadata">

**Author:** ![cmartin](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cmartin/32/4278_2.png) [@cmartin](https://forum.opennebula.io/u/cmartin)\
**Post date:** [June 9, 2015, 9:32am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/2 "2015-06-09T09:32:32Z")

</div>

Hi,

That command should still work as you described. What version are you using?

---

<div class="post-metadata">

**Author:** ![Andy](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/andy/32/4280_2.png) [@Andy](https://forum.opennebula.io/u/Andy)\
**Post date:** [June 9, 2015, 9:54am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/3 "2015-06-09T09:54:45Z")

</div>

opennebula-4.12.1-1

```
$ ls -l /var/lib/one/images/
total 5218564
-rw-rw-r-- 1 oneadmin oneadmin 5343805440 Jun 8 10:03 0cd903f65634b259006a9bab8eb56da5

$ oneimage create -d default --name "test-oneimage-create" --type OS --source /var/lib/one/images/0cd903f65634b259006a9bab8eb56da5
[ImageAllocate] Cannot determine Image SIZE. Wrong number or missing SIZE attribute.
```

---

<div class="post-metadata">

**Author:** ![VURoland](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vuroland/32/7682_2.png) [@VURoland](https://forum.opennebula.io/u/VURoland)\
**Post date:** [September 1, 2015, 10:10am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/4 "2015-09-01T10:10:40Z")

</div>

hi Andy,

seems like you’re missing the --size attribute ?

–size size Size in MB. Used for DATABLOCK type or SOURCE based images.

source: [http://docs.opennebula.org/doc/4.12/cli/oneimage.1.html](http://docs.opennebula.org/doc/4.12/cli/oneimage.1.html)

---

<div class="post-metadata">

**Author:** ![Andy](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/andy/32/4280_2.png) [@Andy](https://forum.opennebula.io/u/Andy)\
**Post date:** [September 1, 2015, 10:19am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/5 "2015-09-01T10:19:03Z")

</div>

Yes it works if you specify `SIZE` manually, but its a local file, we shouldn’t need to specify it since the tool has access to it, and we never needed to specify it in previous versions as it worked out the size itself, but somewhere along the line it now requires you to provide it.

---

<div class="post-metadata">

**Author:** ![VURoland](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/vuroland/32/7682_2.png) [@VURoland](https://forum.opennebula.io/u/VURoland)\
**Post date:** [September 1, 2015, 5:26pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/6 "2015-09-01T17:26:10Z")

</div>

hi Andy, just remembered I had seen the error before, in the (NFS-mounted) /var/lib/one folder.  
I wasnt able to add images from a directory like /var/lib/one/upload  
If I mounted that same dir as /mnt/upload it would work ok.

the error message was similar: [ImageAllocate] Cannot determine Image SIZE.

---

<div class="post-metadata">

**Author:** ![ruben](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ruben/32/19_2.png) [@ruben](https://forum.opennebula.io/u/ruben)\
**Post date:** [September 1, 2015, 5:34pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/7 "2015-09-01T17:34:15Z")

</div>

Hi

The need to set SIZE is a requirement of images registered providing SOURCE  
(as opposed to set PATH and let the drivers set the source). In this case  
(setting SOURCE) the stat action of the driver is not invoked. Using SOURCE  
is target to recovery situations.

Cheers

---

<div class="post-metadata">

**Author:** ![al3xxx](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/al3xxx/32/5985_2.png) [@al3xxx](https://forum.opennebula.io/u/al3xxx)\
**Post date:** [April 4, 2019, 3:22pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/8 "2019-04-04T15:22:20Z")

</div>

Hello,  
Sorry for resurrecting 4 years old thread but I am facing similar problem that becomes quite annoying.

Let me explain:

- I have recent OpenNebula 5.6 installation with NFS datastore and I am trying to migrate qcow2 images from old Archipel orchestration system via “oneimage create”. I have to nfs mount previous system under /var/tmp to be able to import old images.  
the command looks like this  
**oneimage create --name “os-oldvps1” --type OS --description “old vps1” --path=/var/tmp/vms1/vm/drives/e9757498-6926-11e4-9b45-001e67121b2c/vps1.qcow2 -d imgfsds --driver qcow2**  
(where /var/tmp/vms1 is NFS share mounted from old server)  
The problem is that oneimage creates temporary copy under /var/tmp first and /var/tmp size is quite limited - I have 100-500gb image files and /var/tmp has only 35Gb available. Not to mention the speed of the whole procedure - copy from NFS to local disk, only to copy it agan to another NFS share.

Is there a way to force the location of temporary files for oneimage? Ideally I’d point it somewhere else on the same NFS share where I have my datastore, so that temp image-\>ds image operation would be almost instant.

Could somebody please point me to right direction?

---

<div class="post-metadata">

**Author:** ![cgonzalez](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cgonzalez/32/7096_2.png) [@cgonzalez](https://forum.opennebula.io/u/cgonzalez)\
**Post date:** [April 5, 2019, 1:37pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/9 "2019-04-05T13:37:22Z")

</div>

Could you share the XML of your image datastore?

---

<div class="post-metadata">

**Author:** ![al3xxx](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/al3xxx/32/5985_2.png) [@al3xxx](https://forum.opennebula.io/u/al3xxx)\
**Post date:** [April 5, 2019, 2:39pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/10 "2019-04-05T14:39:10Z")

</div>

Sure

```
<DATASTORE>
  <ID>103</ID>
  <UID>0</UID>
  <GID>0</GID>
  <UNAME>oneadmin</UNAME>
  <GNAME>oneadmin</GNAME>
  <NAME>imgfsds</NAME>
  <PERMISSIONS>
    <OWNER_U>1</OWNER_U>
    <OWNER_M>1</OWNER_M>
    <OWNER_A>0</OWNER_A>
    <GROUP_U>1</GROUP_U>
    <GROUP_M>0</GROUP_M>
    <GROUP_A>0</GROUP_A>
    <OTHER_U>0</OTHER_U>
    <OTHER_M>0</OTHER_M>
    <OTHER_A>0</OTHER_A>
  </PERMISSIONS>
  <DS_MAD><![CDATA[fs]]></DS_MAD>
  <TM_MAD><![CDATA[qcow2]]></TM_MAD>
  <BASE_PATH><![CDATA[/var/lib/one//datastores/103]]></BASE_PATH>
  <TYPE>0</TYPE>
  <DISK_TYPE>0</DISK_TYPE>
  <STATE>0</STATE>
  <CLUSTERS>
    <ID>0</ID>
  </CLUSTERS>
  <TOTAL_MB>5364404</TOTAL_MB>
  <FREE_MB>5235688</FREE_MB>
  <USED_MB>128716</USED_MB>
  <IMAGES>
    <ID>39</ID>
    <ID>40</ID>
    <ID>41</ID>
    <ID>42</ID>
    <ID>43</ID>
    <ID>47</ID>
    <ID>49</ID>
    <ID>50</ID>
    <ID>51</ID>
    <ID>52</ID>
    <ID>53</ID>
    <ID>54</ID>
    <ID>55</ID>
    <ID>56</ID>
    <ID>57</ID>
    <ID>58</ID>
  </IMAGES>
  <TEMPLATE>
    <ALLOW_ORPHANS><![CDATA[NO]]></ALLOW_ORPHANS>
    <BRIDGE_LIST><![CDATA[10.0.5.1]]></BRIDGE_LIST>
    <CLONE_TARGET><![CDATA[SYSTEM]]></CLONE_TARGET>
    <CLONE_TARGET_SSH><![CDATA[SYSTEM]]></CLONE_TARGET_SSH>
    <DISK_TYPE><![CDATA[FILE]]></DISK_TYPE>
    <DISK_TYPE_SSH><![CDATA[FILE]]></DISK_TYPE_SSH>
    <DRIVER><![CDATA[qcow2]]></DRIVER>
    <DS_MAD><![CDATA[fs]]></DS_MAD>
    <LN_TARGET><![CDATA[NONE]]></LN_TARGET>
    <LN_TARGET_SSH><![CDATA[SYSTEM]]></LN_TARGET_SSH>
    <RESTRICTED_DIRS><![CDATA[/]]></RESTRICTED_DIRS>
    <SAFE_DIRS><![CDATA[/var/tmp /home]]></SAFE_DIRS>
    <TM_MAD><![CDATA[qcow2]]></TM_MAD>
    <TM_MAD_SYSTEM><![CDATA[SELF]]></TM_MAD_SYSTEM>
    <TYPE><![CDATA[IMAGE_DS]]></TYPE>
  </TEMPLATE>
</DATASTORE>

```

Any hope? if it needs to have transit temp copy it’s ok by me. how can I force oneimage to make this transit copy somewhere else? Why doesn’t it honor TMPDIR/TMP/TEMP environment variables?

---

<div class="post-metadata">

**Author:** ![cgonzalez](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/cgonzalez/32/7096_2.png) [@cgonzalez](https://forum.opennebula.io/u/cgonzalez)\
**Post date:** [April 9, 2019, 10:39am UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/11 "2019-04-09T10:39:35Z")

</div>

It seems that you are using a BRIDGE\_LIST so the STAGING\_DIR is been used as temp folder for copying the images. Default value for STAGING\_DIR is `/var/tmp` ([http://docs.opennebula.org/5.8/operation/host\_cluster\_management/datastore\_guide.html?highlight=staging\_dir#datastore-definition](http://docs.opennebula.org/5.8/operation/host_cluster_management/datastore_guide.html?highlight=staging_dir#datastore-definition)).

You can try defining the STAGING\_DIR for you datastores and set it to a convenient path.

---

<div class="post-metadata">

**Author:** ![al3xxx](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/al3xxx/32/5985_2.png) [@al3xxx](https://forum.opennebula.io/u/al3xxx)\
**Post date:** [May 10, 2019, 2:05pm UTC](https://forum.opennebula.io/t/oneimage-create-without-copying-the-image/831/12 "2019-05-10T14:05:28Z")

</div>

Thank you that works perfect.  
There was just some element of surprise - I assumed that **oneimage create** operations are async and independent, and started importing 2 images at the same time - 1st 3.7Gb and 2nd - 15Gb while watching the progress - to my surprise 3.7Gb image was created sooner, but tmp file was just sitting there waiting for 15Gb image to finish creating - why is it so?  
Upd:  
Delayed thought - for the BRIDGE\_LIST attribute of image datastore - if I will clear it will **oneimage create** import image file without staging copy?
