# Bug? Convert a raw disk image in MacOS fails (mktemp: illegal option -- p)

**URL:** <https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428>\
**Category:** General Discussions\
**Tags:** bug, macos\
**Created:** [December 24, 2021, 9:01am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428 "2021-12-24T09:01:31Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![BSBoatia](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bsboatia/32/1456_2.png) [@BSBoatia](https://hub.mender.io/u/BSBoatia)\
**Post date:** [December 24, 2021, 9:01am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428/1 "2021-12-24T09:01:31Z")

</div>

Hello,

I am trying to convert a raw disk image using MacOS. I followed the instructions on [Convert a Mender Debian image | Mender documentation](https://docs.mender.io/system-updates-debian-family/convert-a-mender-debian-image)

I’m unclear about

> Use the mender-convert container image  
> Run mender-convert from inside the container with your desired options, e.g.

When I run `MENDER_ATRIFACT_NAME=my_release-1 ./docker-mender-convert --disk-image input/golden-0.1.img --config configs/raspberrypi4_config` I’m getting the following error:

```auto
mktemp: illegal option -- p
usage: mktemp [-d] [-q] [-t prefix] [-u] template ...
       mktemp [-d] [-q] [-u] -t prefix 

```

What did I miss?

Thank you very much for your help!

---

<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:** [December 24, 2021, 10:25am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428/2 "2021-12-24T10:25:13Z")

</div>

Hi @BSBoatia

> [@BSBoatia](#):
>
> I’m unclear about
> 
> > Use the mender-convert container image  
> > Run mender-convert from inside the container with your desired options, e.g.

This simply means that the convertion script is run in a container, which is what is done when you do `docker-mender-convert`, like you have done above.

I would think the error stems from here:

> <https://github.com/mendersoftware/mender-convert/blob/master/docker-mender-convert#L29>

This is the `-p` option on linux:

```auto
 -p DIR, --tmpdir[=DIR]
              interpret TEMPLATE relative to DIR; if DIR is not specified, use $TMPDIR if set, else /tmp. With this option, TEM‐
              PLATE must not be an absolute name; unlike with -t, TEMPLATE may contain slashes, but mktemp creates only the final
              component

```

To make the tempdir locate in the current directory.

If you can provide me with the `Mac OS` option, then I will fix this right now for you 🙂

---

<div class="post-metadata">

**Author:** ![BSBoatia](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/bsboatia/32/1456_2.png) [@BSBoatia](https://hub.mender.io/u/BSBoatia)\
**Post date:** [December 26, 2021, 10:10am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428/3 "2021-12-26T10:10:41Z")

</div>

Thanks @oleorhagen, your input was very helpful. There doesn’t necessarily seem an equivalent to -p on OS-X. However, replaced the line with

```auto
WORK_DIR=$(mktemp -d 2>/dev/null || mktemp -d -t 'mytmpdir')

```

which Im copied from [https://newbedev.com/fix-or-alternative-for-mktemp-in-os-x](https://newbedev.com/fix-or-alternative-for-mktemp-in-os-x)

and it’s doing the trick.

---

<div class="post-metadata">

**Author:** ![edpgcooper](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/edpgcooper/32/1496_2.png) [@edpgcooper](https://hub.mender.io/u/edpgcooper)\
**Post date:** [February 10, 2022, 2:41am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428/4 "2022-02-10T02:41:41Z")

</div>

Just a nudge that I’ve experienced this issue just now, and the fix above works.

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [February 24, 2022, 7:51am UTC](https://hub.mender.io/t/bug-convert-a-raw-disk-image-in-macos-fails-mktemp-illegal-option-p/4428/5 "2022-02-24T07:51:17Z")

</div>

@BSBoatia @edpgcooper

the mktemp issue is fixed in [https://github.com/mendersoftware/mender-convert/pull/430](https://github.com/mendersoftware/mender-convert/pull/430).

However please be aware that macOS is not an actively supported platform for mender-conver at the moment, and especially the AArch64 variants are mostly uncharted territory.

Greetz,  
Josef
