How to make a drive mount avaialble inside a container

containerslxc

I intend to use the mount inside the container for a postgres database.

I have been unable to make the drive available inside the container.
So far I have:

  1. mounted /dev/sdb to /mnt/psql on the host device.
  2. created /mnt/psql directory in the container.
  3. added lxc.mount.entry = /mnt/psql mnt/psql none bind 0 0 to the lxc container config files.

Upon restarting the container, the mount was still not available.
How do I go about making it available?

Best Answer

You can use fstab to declare mount points using:

lxc.mount = /PATH/TO/fstab

This is an extension to LXC's config file. I usually put them together, outside the container's rootfs. Then, inside that fstab, you put entries like the normal /etc/fstab but the mount point is relative to the container's rootfs. For example:

/mnt/psql mnt/psql none bind,rw 0 0

See you!

Related Topic