This guide helps you to mount external directory inside the Linux container.If you are yet to setup Linux container in your environment, here are the guides you should take a look.
Step 1: Create a mounting directory on the host. Ex: raj, if you want to mount the device under the mount point “/raj” inside the Linux container.
sudo mkdir /var/lib/lxc/ubuntu_lxc/rootfs/raj
Step 2: Mount the device on the above directory.
sudo mount /dec/sda1 /var/lib/lxc/ubuntu_lxc/rootfs/raj
You should run the above commands on the Linux host, i.e., host operating system.
raj – Mount point
/dev/sda1 – Device you want to mount
ubuntu_lxc – Name of the Linux container
Step 3: Take a console or log in to Linux container and use df command to see the external directory.
sudo lxc-console -n ubuntu_lxc
The output of mounted external directory:
[email protected]_lxc:~$ df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/server--vg-root 97G 2.8G 90G 3% / none 492K 0 492K 0% /dev tmpfs 488M 0 488M 0% /dev/shm tmpfs 488M 6.2M 482M 2% /run tmpfs 5.0M 0 5.0M 0% /run/lock tmpfs 488M 0 488M 0% /sys/fs/cgroup /dev/sda1 472M 148M 300M 33% /raj [email protected]_lxc:~$