# Understanding init scripts Opennebula (Files for VM)

**URL:** <https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430>\
**Category:** Product Support\
**Created:** [July 9, 2019, 10:40am UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430 "2019-07-09T10:40:28Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingbuffalo](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kingbuffalo/32/5672_2.png) [@kingbuffalo](https://forum.opennebula.io/u/kingbuffalo)\
**Post date:** [July 9, 2019, 10:40am UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/1 "2019-07-09T10:40:28Z")

</div>

hello,

I am wondering if anyone can help with understanding how the files section of a VM template works.

I ussually used the startup script which worked fine, but for a common startup script I would prefer to attach this as a file.

I have created init.sh and uploaded it, I have then typed in the name init.sh for the VM’s file.

When the VM boots it doesn’t run the init.sh file (I have tested the script works fine).

Am I doing something wrong with this?

EDIT: i can see its trying to access this file

## /var/log/syslog

Jul 9 10:37:43 Test one-contextd[1487]: chmod: cannot access ‘/tmp/one-context. 6M7wqE/init.sh’: No such file or directory

### VM config

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/6/6d4fc0d51b808f906b0848a5fa744adfdfd538fe.png)

## File in datastore

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/opennebula/original/2X/b/b5fdffb1573229a752088f7b9eeee97a08f6eb0f.png)

---

<div class="post-metadata">

**Author:** ![ahuertas](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ahuertas/32/7487_2.png) [@ahuertas](https://forum.opennebula.io/u/ahuertas)\
**Post date:** [July 9, 2019, 11:15am UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/2 "2019-07-09T11:15:30Z")

</div>

Hello @kingbuffalo

I tested and it works for me, could you please send me the template and `oneimage show init.sh -x` so I can help you.

---

<div class="post-metadata">

**Author:** ![kingbuffalo](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kingbuffalo/32/5672_2.png) [@kingbuffalo](https://forum.opennebula.io/u/kingbuffalo)\
**Post date:** [July 9, 2019, 12:06pm UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/3 "2019-07-09T12:06:35Z")

</div>

Thanks, output is here:

bash-4.2$ oneimage show init.sh -x  
  
135  
0  
105  
oneadmin  
SHARED\_TEMPLATES  
init.sh  
  
\<OWNER\_U\>1\</OWNER\_U\>  
\<OWNER\_M\>1\</OWNER\_M\>  
\<OWNER\_A\>1\</OWNER\_A\>  
\<GROUP\_U\>1\</GROUP\_U\>  
\<GROUP\_M\>1\</GROUP\_M\>  
\<GROUP\_A\>1\</GROUP\_A\>  
\<OTHER\_U\>1\</OTHER\_U\>  
\<OTHER\_M\>1\</OTHER\_M\>  
\<OTHER\_A\>1\</OTHER\_A\>  
  
5  
\<DISK\_TYPE\>0\</DISK\_TYPE\>  
0  
1562667715

 1 1 0 0 -1 -1 2 files

---

<div class="post-metadata">

**Author:** ![ahuertas](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ahuertas/32/7487_2.png) [@ahuertas](https://forum.opennebula.io/u/ahuertas)\
**Post date:** [July 9, 2019, 1:55pm UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/4 "2019-07-09T13:55:30Z")

</div>

Try to give execution permission (`chmod u+x init.sh`) before uploading it to OpenNebula and then upload it and test again.

---

<div class="post-metadata">

**Author:** ![kingbuffalo](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/kingbuffalo/32/5672_2.png) [@kingbuffalo](https://forum.opennebula.io/u/kingbuffalo)\
**Post date:** [July 10, 2019, 7:45pm UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/5 "2019-07-10T19:45:47Z")

</div>

Thanks I’ll give that a go , I created the .sh in sublime on windows so no Unix permissions will have been set , surely opennebula would chnod the file on upload ?

---

<div class="post-metadata">

**Author:** ![ahuertas](https://yyz1.discourse-cdn.com/flex031/user_avatar/forum.opennebula.io/ahuertas/32/7487_2.png) [@ahuertas](https://forum.opennebula.io/u/ahuertas)\
**Post date:** [July 11, 2019, 1:06pm UTC](https://forum.opennebula.io/t/understanding-init-scripts-opennebula-files-for-vm/7430/6 "2019-07-11T13:06:05Z")

</div>

It depends on your datastore tm\_mad, but it will copy the file as it is.
