CRUX : Home

Home :: Documentation :: Download :: Development :: Community :: Wiki :: Ports :: Bugs :: Links :: About

Back to wiki start page

Docker on LVM2

Danny Rawlins

Setup Docker on Logical volumes in LVM2

Instead of Docker using devicemapper files which are loop mounted in /var/lib/docker/devicemapper/devicemapper/ we will setup real Logical Volumes (LVs) inside our existing LVM2 Volume Group (VG).

We do this by first creating two LVs

I chose 200GB for data and metadata is 5% of that at 10GB

$ sudo /sbin/lvcreate --wipesignatures y -n data direct-lvm -L 200G

  Logical volume "data" created

$ sudo /sbin/lvcreate --wipesignatures y -n metadata direct-lvm -L 10G

  Logical volume "metadata" created

Its best to blank the start of the metadata area:

$ sudo dd if=/dev/zero of=/dev/data/metadata bs=1M count=10 10+0 records in 10+0 records out 10485760 bytes (10 MB) copied, 0.901407 s, 11.6 MB/s

Be sure docker is stopped:

sudo /etc/rc.d/docker stop

Now edit /etc/docker.conf and add:

--storage-opt dm.datadev=/dev/direct-lvm/data --storage-opt dm.metadatadev=/dev/direct-lvm/metadata


Be sure to remove the old storage, especially json.migrated, else you will get errors and docker will not start.

$ rm /var/lib/docker/devicemapper/devicemapper/{data,metadata,json.migrated}

Now start docker: $ sudo /etc/rc.d/docer start