Wednesday, April 3, 2019

Oracle Linux 6 -- Setup the File System for Linux Containers

Problem

You need to setup the /container file system, as the containers are created in this directory by default.

Solution

First prepare a physical device to be used for the file system, this can also be a logical volume:

# pvcreate -v /dev/sd[cd]
# vgcreate -v containersvg /dev/sdc /dev/sdd
# lvcreate -l 100%VG --name containerslv containersvg

Format the device with btrf file system:

# mkfs.btrfs /dev/containersvg/containerslv

Create the mount point:

# mkdir /container

Mount the file system:

# mount /dev/mapper/containersvg-containerslv /container/

Add and entry to /etc/fstab:

/dev/mapper/containersvg-containerslv /container btrfs defaults 0 0

No comments: