Linux Containers (LXC) is a lightweight virtualization technology and operating system level virtualization method for running multiple isolated Linux systems (containers) on a single control host.
Here’s how to support persistent storage in LXC:
1. Create a directory on the host instantiating the container:
```
sudo mkdir /var/lib/lxc/YOUR_CONTAINER/rootfs/storage
```
(In this example, “/storage” will be the persistent storage directory)
1. Mount a physical drive to the persistent storage directory:
```
sudo mount /dev/YOUR_DEVICE /var/lib/lxc/YOUR_CONTAINER/rootfs/storage
```
(Replace YOUR\_DEVICE with the path to the block device you wish to use as storage)
1. Edit your container config file (usually at /var/lib/lxc/YOUR\_CONTAINER/config) and add the following to automatically mount the drive when the container starts:
```
lxc.mount.entry = /dev/YOUR_DEVICE storage none bind,create=dir 0 0
```
Remember to replace YOUR_DEVICE and YOUR_CONTAINER with your configurations.
1. To verify the persistent storage setup, start the container:
```
lxc-start -n YOUR_CONTAINER
```
1. After this, attach to the container:
```
lxc-attach -n YOUR_CONTAINER
```
In the container, navigate to the /storage directory. This is the persistent storage!
Note: Make sure that the drive you are using for persistent storage is not mounted anywhere else. This setup presumes that you are using LXC with a directory as the container’s root file system. The instructions may need some adjustments depending on specific use-cases or different configurations.