# Using OCaml compiler from external drive

**URL:** <https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122>\
**Category:** Ecosystem\
**Created:** [January 20, 2021, 2:22pm UTC](https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122 "2021-01-20T14:22:34Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![idkjs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/idkjs/32/675_2.png) [@idkjs](https://discuss.ocaml.org/u/idkjs)\
**Post date:** [January 20, 2021, 2:22pm UTC](https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122/1 "2021-01-20T14:22:34Z")

</div>

I have a machine with limited space. I have an external ssd so I can work with OCaml/ReasonML native compilation projects.

How would I use opam/ocaml from this disk so it doesnt eat up my primary limited hard drive space?

Thank you.

---

<div class="post-metadata">

**Author:** ![EduardoRFS](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/eduardorfs/32/2259_2.png) [@EduardoRFS](https://discuss.ocaml.org/u/EduardoRFS)\
**Post date:** [January 20, 2021, 2:44pm UTC](https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122/2 "2021-01-20T14:44:45Z")

</div>

On Linux and macOS you can mount the drive to your `.opam`.

If it’s a subfolder of your drive you can use `mount --bind`

---

<div class="post-metadata">

**Author:** ![emillon](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/emillon/32/1206_2.png) [@emillon](https://discuss.ocaml.org/u/emillon)\
**Post date:** [January 20, 2021, 3:01pm UTC](https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122/3 "2021-01-20T15:01:24Z")

</div>

You can also set the `OPAMROOT` variable to something that points to your SSD. It will be used as the “opam root” instead of `$HOME/.opam`.

---

<div class="post-metadata">

**Author:** ![idkjs](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ocaml.org/idkjs/32/675_2.png) [@idkjs](https://discuss.ocaml.org/u/idkjs)\
**Post date:** [January 20, 2021, 6:28pm UTC](https://discuss.ocaml.org/t/using-ocaml-compiler-from-external-drive/7122/4 "2021-01-20T18:28:39Z")

</div>

Very helpful gentleman. Thank you.

For the record, these are the commands I have run to get my opam and esy setup on the external ssd.

```bash
~/Downloads
 [I] ➜ set -xg ESY__PREFIX /Volumes/external/.esy
~/Downloads
 [I] ➜ echo $ESY__PREFIX
/Volumes/external/.esy

~/Downloads
 [I] ➜set -xg OPAMROOT /Volumes/external/.opam
~/Downloads took 2m 52s 87ms
 [I] ➜ echo $OPAMROOT
/Volumes/external/.opam

```

Then run `opam init` per instructions.

Running `esy` in projects is using the external ssd `%EXTERNAL/.esy` for caching. Opam is use `.opam` in same.

Thanks again.
