Create a RAID volume for docker

I had 2 hard drives and wanted to create a RAID volume and format it it with btrfs and use it for docker.

  • Use lsblk comand to identify the disks to use

lsblk

sda 8:0 0 931.5G 0 disk
├─sda1 8:1 0 39.2M 0 part
├─sda2 8:2 0 10.2G 0 part
└─sda3 8:3 0 921.3G 0 part
sdb 8:16 0 465.8G 0 disk
sdd 8:48 0 465.8G 0 disk

sdb and sdd are the disks I want to use for raid.

  • Use fdisk to create “Linux Raid Autodetect” partitions on the disks

fdisk /dev/sdb

#Command: n  - new partition

#Command t - Change fs type to  fd

#Command w - write the partition to disk

Then do the same for /dev/sdd

  • Now, you can see the partitions with  lsblk

sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part

  • create theRAID volume

mdadm --create /dev/md128 --level=0 --raid-disk=2 /dev/sdb1 /dev/sdd1

  • Now you can see the RAID volume with  lsblk

sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0

  • Create a file system on the new RAID volume

mkfs.btrfs -f /dev/md128

  • Add a mount point in  /etc/fstab

vi /etc/fstab

#add this line

/dev/md128     /var/lib/docker      btrfs       defaults 1 2

  •  mount the docker folder

mount /var/lib/docker

  • Now you can see the mount point on the RAID volume with lsblk

lsblk

sdb 8:16 0 465.8G 0 disk
└─sdb1 8:17 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0 /var/lib/docker

sdd 8:48 0 465.8G 0 disk
└─sdd1 8:49 0 465.8G 0 part
└─md128 9:128 0 931.3G 0 raid0 /var/lib/docker

We’re done, enjoying the big docker RAID volume.

 

 

 

 

 

Advertisements
This entry was posted in docker, linux. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s