---
title: Mounting your home directory in LXD
description: 'As of LXD stable 2.0.8 and feature release 2.6, LXD has support for
  various UID and GID map related manipulaions. A common question is: “How do I bind-mount
  my home directory into a container?” and before the answer was “well, it’s complicated
  but you can do it; it’s slightly less complicated if you do it  […]'
url: https://canonical.com/blog/mounting-your-home-directory-in-lxd?format=md
---

1. [Blog](https://canonical.com/blog)
2. Article

---

[Canonical](https://canonical.com/blog/author/canonical "More about Canonical")

8 December 2016

# Mounting your home directory in LXD

[containers](https://canonical.com/blog/tag/containers)
[LXD](https://canonical.com/blog/tag/lxd)

---

Share the article

As of LXD stable 2.0.8 and feature release 2.6, LXD has support for various UID and GID map related manipulaions. A common question is: “How do I bind-mount my home directory into a container?” and before the answer was “well, it’s complicated but you can do it; it’s slightly less complicated if you do it in privleged containers”. However, with this feature, now you can do it very easily in unprivileged containers.

First, find out your uid on the host:

```
$ id
uid=1000(tycho) gid=1000(tycho) groups=1000(tycho),4(adm),24(cdrom),27(sudo),30(dip),46(plugdev),112(lpadmin),124(sambashare),129(libvirtd),149(lxd),150(sbuild)
```

On standard Ubuntu hosts, the uid of the first user is 1000. Now, we need to allow LXD to remap to remap this id; you’ll need an additional entry for root to do this:

```
$ echo 'root:1000:1' | sudo tee -a /etc/subuid /etc/subgid
```

Now, create a container, and set the idmap up to map both uid and gid 1000 to uid and gid 1000 inside the container.

```
$ lxc init ubuntu-daily:z zesty
```

Creating zesty

```
$ lxc config set zesty raw.idmap 'both 1000 1000'
```

Finally, set up your home directory to be mounted in the container:

```
$ lxc config device add zesty homedir disk source=/home/tycho path=/home/ubuntu
```

And leave an insightful message for users of the container:

```
$ echo 'meshuggah rocks' >> message
```

Finally, start your container and read the message:

```
$ lxc start zesty
$ lxc exec zesty cat /home/ubuntu/message
meshuggah rocks
```

And enjoy the insight offered to you by your home directory 🙂

## Sign up for our newsletter

Get the latest Canonical news and updates in your inbox.

Work email:

\*I agree to receive information about Canonical's
products and services.

By submitting this form, I confirm that I have read and agree to [Canonical's Privacy Policy](https://canonical.com/legal/dataprivacy).

Sign up

## Share on

---

## Related posts

[### Ubuntu Server: a platform made for enterprise scale](https://canonical.com/blog/ubuntu-server-a-platform-made-for-enterprise-scale)

A platform is an environment that allows software to run smoothly across the infrastructure, runtime, and application layers. The key word there is “smoothly”: a good platform...

[Rhys Knipe](https://canonical.com/blog/author/rhysknipe)

7 July 2026

[### Canonical partners with Snyk for scanning chiseled Ubuntu containers](https://canonical.com/blog/canonical-partners-with-snyk-for-scanning-chiseled-ubuntu-containers)

Canonical, the publisher of Ubuntu, is pleased to announce a new partnership with developer-focused cybersecurity company Snyk. Snyk Container, Snyk’s container security...

[Canonical](https://canonical.com/blog/author/canonical)

20 March 2026

[### Introducing MicroCloud Cluster Manager](https://canonical.com/blog/introducing-microcloud-cluster-manager)

Canonical introduces the beta release of MicroCloud Cluster Manager, a new way to discover, organize, and operate your MicroCloud environments from a single, unified interface.

[Miona Aleksic](https://canonical.com/blog/author/mionaalex)

20 March 2026

[### Native integration available between Canonical LXD and HPE Alletra MP B10000](https://canonical.com/blog/canonical_lxd_hpe_alletra)

Native integration available between Canonical LXD and HPE Alletra MP B10000. The integration combines efficient open source virtualization with high performance,...

[Miona Aleksic](https://canonical.com/blog/author/mionaalex)

15 December 2025
