You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
IoT Edge modules can use storage on the host IoT Edge device itself for improved reliability, especially when operating offline.
20
+
21
+
## Configure system modules to use persistent storage
22
+
23
+
By default, IoT Edge system modules, IoT Edge agent and IoT Edge hub, store state in the ephemeral file system of their container instance. This state is lost when the container instance is recycled, for example, when module image version or createOptions is updated.
24
+
25
+
For production scenarios, use a persistent storage location on the host filesystem to store system module state. Doing so improves solution robustness and cloud message delivery guarantees.
26
+
27
+
To set up system modules to use persistent storage:
28
+
29
+
1. For both IoT Edge hub and IoT Edge agent, add an environment variable called **storageFolder** that points to a directory in the module.
30
+
1. For both IoT Edge hub and IoT Edge agent, add binds to connect a local directory on the host machine to a directory in the module. For example:
31
+
32
+

33
+
34
+
Or, you can configure the local storage directly in the deployment manifest. For example:
Replace `<HostStoragePath>` and `<ModuleStoragePath>` with your host and module storage path; both values must be an absolute path and `<HostStoragePath>` must exist.
75
+
76
+
### Automatic host system permissions management
77
+
78
+
On version 1.4 and newer, there's no need for manually setting ownership or permissions for host storage backing the `storageFolder`. Permissions and ownership are automatically managed by the system modules during startup.
79
+
80
+
> [!NOTE]
81
+
> Automatic permission management of host bound storage only applies to system modules, IoT Edge agent and Edge hub. For custom modules, manual management of permissions and ownership of bound host storage is required if the custom module container is not running as `root` user.
82
+
83
+
84
+
85
+
## Link module storage to device storage for custom modules
86
+
87
+
If your custom module requires access to persistent storage on the host file system, use the module's create options to bind a storage folder in module container to a folder on the host machine. For example:
88
+
89
+
```json
90
+
{
91
+
"HostConfig": {
92
+
"Mounts": [
93
+
{
94
+
"Target": "<ModuleStoragePath>",
95
+
"Source": "<HostStoragePath>",
96
+
"Type": "bind",
97
+
"ReadOnly": false
98
+
}
99
+
]
100
+
}
101
+
}
102
+
```
103
+
104
+
105
+
Replace `<HostStoragePath>` and `<ModuleStoragePath>` with your host and module storage path; both values must be an absolute path. Refer to the [Docker Engine Mount specification](https://any-api.com/docker_com/engine/docs/Definitions/Mount) for option details.
106
+
107
+
108
+
109
+
### Host system permissions
110
+
111
+
Make sure that the user profile your module is using has the required read, write, and execute permissions to the host system directory. By default, containers run as `root` user that already has the required permissions. But your module's Dockerfile might specify use of a non-root user in which case host storage permissions must be manually configured.
112
+
113
+
There are several ways to manage directory permissions on Linux systems, including using `chown` to change the directory owner and then `chmod` to change the permissions. For example to allow host storage access to a module running as non-root user ID 1000, use the following commands:
114
+
115
+
```bash
116
+
sudo chown 1000 <HostStoragePath>
117
+
sudo chmod 700 <HostStoragePath>
118
+
```
119
+
::: moniker-end
120
+
121
+
::: moniker range="<=iotedge-2020-11"
122
+
17
123
In addition to storing data using Azure storage services or in your device's container storage, you can also dedicate storage on the host IoT Edge device itself for improved reliability, especially when operating offline.
When modules invoke the IoT Edge daemon's workload API to encrypt data, the encryption key is derived using the module ID and module's generation ID. A generation ID is used to protect secrets if a module is removed from the deployment and then another module with the same module ID is later deployed to the same device. You can view a module's generation id using the Azure CLI command [az iot hub module-identity show](/cli/azure/iot/hub/module-identity).
203
+
When modules invoke the IoT Edge daemon's workload API to encrypt data, the encryption key is derived using the module ID and module's generation ID. A generation ID is used to protect secrets if a module is removed from the deployment and then another module with the same module ID is later deployed to the same device. You can view a module's generation ID using the Azure CLI command [az iot hub module-identity show](/cli/azure/iot/hub/module-identity).
97
204
98
205
If you want to share files between modules across generations, they must not contain any secrets or they will fail to be decrypted.
0 commit comments