<a id="devices-unix-char"></a>

# Type: `unix-char`


            <p class="youtube_link">
              <a href="https://www.youtube.com/watch?v=C2e3LD5wLI8" target="_blank">
                <span title="LXD Unix devices - YouTube" class="play_icon">▶</span>
                <span title="LXD Unix devices - YouTube">Watch on YouTube</span>
              </a>
            </p>
        
#### NOTE
The `unix-char` device type is supported for containers.
It supports hotplugging.

Unix character devices make the specified character device appear as a device in the container (under `/dev`).
You can read from the device and write to it.

## Device options

`unix-char` devices have the following device options:

<!-- Include content from [../metadata.txt](../metadata.txt) -->

<a id="device-unix-char-device-conf:gid"></a>
`gid`

GID of the device owner in the container

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:gid)

| **Key:**     | `gid`   |
|--------------|---------|
| **Type:**    | integer |
| **Default:** | `0`     |

<a id="device-unix-char-device-conf:major"></a>
`major`

Device major number

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:major)

| **Key:**     | `major`        |
|--------------|----------------|
| **Type:**    | integer        |
| **Default:** | device on host |

<a id="device-unix-char-device-conf:minor"></a>
`minor`

Device minor number

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:minor)

| **Key:**     | `minor`        |
|--------------|----------------|
| **Type:**    | integer        |
| **Default:** | device on host |

<a id="device-unix-char-device-conf:mode"></a>
`mode`

Mode of the device in the container

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:mode)

| **Key:**     | `mode`   |
|--------------|----------|
| **Type:**    | integer  |
| **Default:** | `0660`   |

<a id="device-unix-char-device-conf:path"></a>
`path`

Path inside the container

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:path)

| **Key:**      | `path`                                |
|---------------|---------------------------------------|
| **Type:**     | string                                |
| **Required:** | either `source` or `path` must be set |

<a id="device-unix-char-device-conf:required"></a>
`required`

Whether this device is required to start the container

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:required)

| **Key:**     | `required`   |
|--------------|--------------|
| **Type:**    | bool         |
| **Default:** | `true`       |

See [Hotplugging](#devices-unix-char-hotplugging) for more information.

<a id="device-unix-char-device-conf:source"></a>
`source`

Path on the host

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:source)

| **Key:**      | `source`                              |
|---------------|---------------------------------------|
| **Type:**     | string                                |
| **Required:** | either `source` or `path` must be set |

<a id="device-unix-char-device-conf:uid"></a>
`uid`

UID of the device owner in the container

[<i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i>](#device-unix-char-device-conf:uid)

| **Key:**     | `uid`   |
|--------------|---------|
| **Type:**    | integer |
| **Default:** | `0`     |

## Configuration examples

Add a `unix-char` device to a container by specifying its source and path:

```none
lxc config device add <instance_name> <device_name> unix-char source=<path_on_host> path=<path_on_instance>
```

If you want to use the same path on the container as on the host, you can omit the `source` option:

```none
lxc config device add <instance_name> <device_name> unix-char path=<path_to_the_device>
```

See [Configure devices](https://canonical.com/lxd/docs/latest/howto/instances_configure/index.html.md#instances-configure-devices) for more information.

<a id="devices-unix-char-hotplugging"></a>

## Hotplugging

<!-- Include content from [devices_unix_block.md](device_unix_block.md) -->

Hotplugging is enabled if you set `required=false` and specify the `source` option for the device.

In this case, the device is automatically passed into the container when it appears on the host, even after the container starts.
If the device disappears from the host system, it is removed from the container as well.
