Dino Geek, try to help you

How to support persistent storage in LXC?


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.


Simply generate articles to optimize your SEO
Simply generate articles to optimize your SEO





DinoGeek offers simple articles on complex technologies

Would you like to be quoted in this article? It's very simple, contact us at dino@eiki.fr

CSS | NodeJS | DNS | DMARC | MAPI | NNTP | htaccess | PHP | HTTPS | Drupal | WEB3 | LLM | Wordpress | TLD | Domain name | IMAP | TCP | NFT | MariaDB | FTP | Zigbee | NMAP | SNMP | SEO | E-Mail | LXC | HTTP | MangoDB | SFTP | RAG | SSH | HTML | ChatGPT API | OSPF | JavaScript | Docker | OpenVZ | ChatGPT | VPS | ZIMBRA | SPF | UDP | Joomla | IPV6 | BGP | Django | Reactjs | DKIM | VMWare | RSYNC | Python | TFTP | Webdav | FAAS | Apache | IPV4 | LDAP | POP3 | SMTP

| Whispers of love (API) | Déclaration d'Amour |






Legal Notice / General Conditions of Use