# Creating directories with \`mender-artifact install\` or \`mender-artifact cp\`

**URL:** <https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164>\
**Category:** General Discussions\
**Tags:** mender-artifact\
**Created:** [October 20, 2019, 2:29pm UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164 "2019-10-20T14:29:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mcampbellizo](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mcampbellizo/32/395_2.png) [@mcampbellizo](https://hub.mender.io/u/mcampbellizo)\
**Post date:** [October 20, 2019, 2:29pm UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164/1 "2019-10-20T14:29:52Z")

</div>

In our workflow we generate a mender update artifact from Yocto with our base operating system. We then compile our application code after and want to use `mender-artifact` to copy the application and its resources into the existing mender update. The problem I’m running into is that I can’t find a way to create new directories with `mender-artifact`. With either `cp` or `install` I get an error message when trying to copy into a path that doesn’t exist.

```auto
$ mender-artifact install -m 644 ./foo test.mender:/bar/foo
The directory: /bar does not exist in the image

```

I tried looking at the source for mender-artifact, but I’m not up to speed on golang, so I wasn’t able to get too far. Is there a way to pull this off that I’m missing?

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [October 20, 2019, 2:36pm UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164/2 "2019-10-20T14:36:12Z")

</div>

`mender-artifact install` is a very simple interface, primarily designed to update config files and primarily during evaluation. Do not think that there is a way to create directories.

So my recommendation would instead be:

- take the `ext4` image from your Yocto build
- loopback mount it and install your application and any other changes you would like to make
- use `mender-artifact` create a Mender Artifact based on above modified `ext4`image. You would use the`mender-artifact write rootfs-image` command for this.

Though I would recommend you to integrate the build of your application in Yocto as well to streamline the the workflow, but above should also work.

---

<div class="post-metadata">

**Author:** ![mcampbellizo](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mcampbellizo/32/395_2.png) [@mcampbellizo](https://hub.mender.io/u/mcampbellizo)\
**Post date:** [October 20, 2019, 2:46pm UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164/3 "2019-10-20T14:46:38Z")

</div>

Thanks for the quick reply! You all have blown me away with your community support at every turn.

I hadn’t thought of keeping around the ext4 as an artifact and modifying that, I like that idea. As for an all in-Yocto build, our firmware and application teams are decoupled in our workflows and we don’t want to bog down the app folks with the Yocto builds. We used to do it this way, but the seperation has worked out well for us so we don’t want to move off of it.

Another thought, if I made a PR for mender artifact that added a `mkdir` command, would that have a chance of being accepted?

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [October 20, 2019, 2:54pm UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164/4 "2019-10-20T14:54:32Z")

</div>

> Thanks for the quick reply! You all have blown me away with your community support at every turn.

Thank you for being part of the community as well

> We used to do it this way, but the separation has worked out well for us so we don’t want to move off of it.

👍

> [@mcampbellizo](#):
>
> Another thought, if I made a PR for mender artifact that added a `mkdir` command, would that have a chance of being accepted?

I will let @kacf and @oleorhagen comment on this as they have primarily worked on this tool.

A `mender-artifact install -d` option could also be a way to implement this, as this interface mimics the [install](https://linux.die.net/man/1/install) util.

---

<div class="post-metadata">

**Author:** ![kacf](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/kacf/32/146_2.png) [@kacf](https://hub.mender.io/u/kacf)\
**Post date:** [October 21, 2019, 5:09am UTC](https://hub.mender.io/t/creating-directories-with-mender-artifact-install-or-mender-artifact-cp/1164/5 "2019-10-21T05:09:01Z")

</div>

> [@mcampbellizo](#):
>
> Another thought, if I made a PR for mender artifact that added a `mkdir` command, would that have a chance of being accepted?

Yes, that sounds like a good addition to me. I would consider waiting a week or so to start though. There is a [big refactoring](https://tracker.mender.io/browse/MEN-2592) going on in that part of the tool, so you would risk conflicts. It’s due to be submitted very soon.
