# Client -d global option not working

**URL:** <https://hub.mender.io/t/client-d-global-option-not-working/3563>\
**Category:** General Discussions\
**Tags:** mender-client\
**Created:** [April 27, 2021, 8:19pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563 "2021-04-27T20:19:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![grantviolet](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/grantviolet/32/1148_2.png) [@grantviolet](https://hub.mender.io/u/grantviolet)\
**Post date:** [April 27, 2021, 8:19pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/1 "2021-04-27T20:19:09Z")

</div>

Hi folks, I’m using the -d option to set the client data store directory but it doesn’t seem to be working as I expected (or as I need it to).

I’m running the client as:  
`/usr/bin/mender -d /userdata/temp daemon`

and then expecting data files to be written to /userdata/temp. However, on starting up the client I see the following in these 2 different locations:

```shell
/ # ls -al /var/lib/mender
drwx------ 2 root root 1024 Apr 27 20:23 .
drwxr-xr-x 7 root root 1024 Apr 27 18:48 ..
-rw------- 1 root root 8192 Apr 27 20:23 mender-store
-rw------- 1 root root 8192 Apr 27 20:24 mender-store-lock

```

```shell
/ # ls -al /userdata/temp
drwx------ 2 root root 1024 Apr 27 20:23 .
drwxr-xr-x 7 root root 1024 Apr 27 18:48 ..
-rw------- 1 root root 12288 Apr 27 20:23 mender-store
-rw------- 1 root root 8192 Apr 27 20:24 mender-store-lock

```

After doing a test single-file update then I see the following in these directories:

```shell
/ # ls -al /var/lib/mender
drwx------ 4 root root 1024 Apr 27 20:29 .
drwxr-xr-x 8 root root 1024 Apr 27 20:29 ..
-rw------- 1 root root 8192 Apr 27 20:23 mender-store
-rw------- 1 root root 8192 Apr 27 20:29 mender-store-lock
drwx------ 3 root root 1024 Apr 27 20:29 modules
drwxr-xr-x 2 root root 1024 Apr 27 20:29 scripts

```

```shell
/ # ls -al /userdata/temp
drwx------ 2 root root 1024 Apr 27 20:29 .
drwxr-xr-x 8 root root 1024 Apr 27 20:29 ..
-rw------- 1 root root 1508 Apr 27 20:29 deployments.0001.6769bb70-b614-4844-a684-39ba1177aca4.log
-rw------- 1 root root 32768 Apr 27 20:29 mender-store
-rw------- 1 root root 8192 Apr 27 20:29 mender-store-lock

```

So, at startup it seems to write to `mender-store` and `mender-store-lock` in **both** directories.  
During the update process it seems to write to `mender-store-lock` in **both** directories but only `mender-store` in the overridden -d directory.  
It writes the deployments log file to the overridden -d directory.  
It writes the artifact scripts to the scripts sub dir in the **default** directory.  
It writes the downloaded payload to the modules sub dir in the **default** directory.

This is significant as the location for the downloaded payload has to be in an area which is large enough to hold it, therefore it _must_ be possible to control where that location is otherwise the download will fail.

Can anyone shed any light on this?

Many thanks,  
Grant

---

<div class="post-metadata">

**Author:** ![Pat\_Honeycutt](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Pat\_Honeycutt](https://hub.mender.io/u/Pat_Honeycutt)\
**Post date:** [April 27, 2021, 9:49pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/2 "2021-04-27T21:49:05Z")

</div>

/var/lib/mender is symlinked to your data directory. Here is one of my devices:

![image](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/2X/f/fd12e3b5a1334273bdd847495d7f72b0f97de27f.png)

---

<div class="post-metadata">

**Author:** ![grantviolet](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/grantviolet/32/1148_2.png) [@grantviolet](https://hub.mender.io/u/grantviolet)\
**Post date:** [April 27, 2021, 10:02pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/3 "2021-04-27T22:02:29Z")

</div>

Thanks Pat. I expect my device is different to yours, I don’t have that symlink on mine. But regardless of that, as shown in my post, 2 different directories are being written to when I specify one using the -d option.

---

<div class="post-metadata">

**Author:** ![drewmoseley](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/drewmoseley/32/47_2.png) [@drewmoseley](https://hub.mender.io/u/drewmoseley)\
**Post date:** [April 27, 2021, 10:03pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/4 "2021-04-27T22:03:42Z")

</div>

@oleorhagen can you comment here?

---

<div class="post-metadata">

**Author:** ![Pat\_Honeycutt](https://avatars.discourse-cdn.com/v4/letter/p/7bcc69/32.png) [@Pat\_Honeycutt](https://hub.mender.io/u/Pat_Honeycutt)\
**Post date:** [April 27, 2021, 10:18pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/5 "2021-04-27T22:18:23Z")

</div>

Ok. Not sure if this is helpful, but I’m using mender with Yocto and that is the default setup as far as I know. I did not create that symlink and we map the data directory as follows.

`MENDER_DATA_PART = "${MENDER_STORAGE_DEVICE_BASE}7"`

we have additional partitions from the standard which is usually

`MENDER_DATA_PART = "${MENDER_STORAGE_DEVICE_BASE}4"`

I assume internally mender would use a symlink to the data location for ease of use, but in your case that appears to not be the case.

---

<div class="post-metadata">

**Author:** ![grantviolet](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/grantviolet/32/1148_2.png) [@grantviolet](https://hub.mender.io/u/grantviolet)\
**Post date:** [April 28, 2021, 6:36am UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/6 "2021-04-28T06:36:21Z")

</div>

Thanks Pat. My device isn’t Yocto, so that mapping doesn’t apply to me.

Internally, from the source code, the client defaults to using `/var/lib/mender` for the data directory. It’s up to the OS if that is actually a symlink or not.

However, the main issue here is that the -d option isn’t overriding that default in all cases and **both** directories are being written to, which I think might be a bug as it doesn’t make sense.

---

<div class="post-metadata">

**Author:** ![oleorhagen](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/oleorhagen/32/297_2.png) [@oleorhagen](https://hub.mender.io/u/oleorhagen)\
**Post date:** [April 28, 2021, 11:17am UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/7 "2021-04-28T11:17:22Z")

</div>

Looks like a bug to me!

Ticket: [https://tracker.mender.io/browse/MEN-4669](https://tracker.mender.io/browse/MEN-4669)

---

<div class="post-metadata">

**Author:** ![grantviolet](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/grantviolet/32/1148_2.png) [@grantviolet](https://hub.mender.io/u/grantviolet)\
**Post date:** [April 28, 2021, 1:17pm UTC](https://hub.mender.io/t/client-d-global-option-not-working/3563/8 "2021-04-28T13:17:02Z")

</div>

Many thanks @oleorhagen
