Dmcache

From wiki.mikejung.biz
Jump to: navigation, search

Liquidweb 728x90.jpg

DMcache Setup

Get the size of the SSD

1) Get the size of the SSD that will be used by DMcache by using the blockdev command that is shown below.

blockdev --getsize64 /dev/sd$

256060514304

Calculate the ssd-metadata size

2) Calculate the ssd-metadata size that will be needed (in bytes) to keep track of any file changes.

4 MB + ( 16 bytes + nr_blocks )
4194304 + (16 * 256060514304 / 262144)

19822998 = ssd-metadata size in bytes

Convert this number to sectors (divide by 512)

19822998 / 512

38717 = ssd-metadata size in sectors

Create ssd-metadata device for DMcache to use

3) Create the ssd-metadata device, then zero it out to make sure it's clean

dmsetup create ssd-metadata --table '0 38717 linear /dev/sdb 0'

4) Calculate the remaining size available for ssd blocks

256060514304 / 512 - 38717

500079475 = SSD blocks remaining for cache

Create ssd-blocks device

5) Create the ssd-blocks dm device:

dmsetup create ssd-blocks --table '0 500079475 linear /dev/sdb 38717'

6) Determine the number of sectors on the device you want to cache

blockdev --getsz /dev/sdc1

976771120

Create the DMcache device

7) Create the dm-cache device with 256KB cache blocks

dmsetup create home-cached --table '0 976771120 cache /dev/mapper/ssd-metadata /dev/mapper/ssd-blocks /dev/sdc1 512 1 writeback default 0'

Verify that DMcache works

8) Verify this works:

ls -l /dev/mapper/home-cached

dmsetup status /dev/mapper/home-cached

Mount and utilize the DMcache device

9) Mount it

mkdir /mnt/cache

mount /dev/mapper/home-cached /mnt/cache