Adding Additional Storage for Docker

NOTE: I added an additional 128G disk via VMware which is seen as: /dev/sdb
I created (1) 25G partition to be allocated for the /var/log/ciena partition
# fdisk -l Disk /dev/sdb: 134.2 GB, 134217728000 bytes, 262144000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes
Create 1 partition for Ciena logs and one partition for Docker
# fdisk /dev/sdb Welcome to fdisk (util-linux 2.23.2). Changes will remain in memory only, until you decide to write them. Be careful before using the write command. Device does not contain a recognized partition table Building a new DOS disklabel with disk identifier 0xf46fc9f5. Command (m for help): n Partition type: p primary (0 primary, 0 extended, 4 free) e extended Select (default p): p Partition number (1-4, default 1): 1 First sector (2048-262143999, default 2048): Using default value 2048 Last sector, +sectors or +size{K,M,G} (2048-262143999, default 262143999): +25G Partition 1 of type Linux and of size 25 GiB is set Command (m for help): n Partition type: p primary (1 primary, 0 extended, 3 free) e extended Select (default p): p Partition number (2-4, default 2): 2 First sector (52430848-262143999, default 52430848): Using default value 52430848 Last sector, +sectors or +size{K,M,G} (52430848-262143999, default 262143999): Using default value 262143999 Partition 2 of type Linux and of size 100 GiB is set Command (m for help): p Disk /dev/sdb: 134.2 GB, 134217728000 bytes, 262144000 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk label type: dos Disk identifier: 0xf46fc9f5 Device Boot Start End Blocks Id System /dev/sdb1 2048 52430847 26214400 8e Linux LVM /dev/sdb2 52430848 262143999 104856576 8e Linux LVM Command (m for help): w The partition table has been altered!
Create a physical volume from /dev/sdb1
# pvcreate /dev/sdb1 Physical volume "/dev/sdb1" successfully created. # pvcreate /dev/sdb2 Physical volume "/dev/sdb2" successfully created
Create the vg_logs and lv_logs for /var/log/ciena
# pvs PV VG Fmt Attr PSize PFree /dev/sda2 rhel lvm2 a-- 78.00g 0 /dev/sda3 vg_sys lvm2 a-- 420.99g <100.15g /dev/sdb1 lvm2 --- 25.00g 25.00g /dev/sdb2 lvm2 --- <100.00g <100.00g # vgs VG #PV #LV #SN Attr VSize VFree rhel 1 2 0 wz--n- 78.00g 0 vg_sys 1 3 0 wz--n- 420.99g <100.15g # vgcreate vg_logs /dev/sdb1 Volume group "vg_logs" successfully created # vgdisplay vg_logs --- Volume group --- VG Name vg_logs System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 1 VG Access read/write VG Status resizable MAX LV 0 Cur LV 0 Open LV 0 Max PV 0 Cur PV 1 Act PV 1 VG Size <25.00 GiB PE Size 4.00 MiB Total PE 6399 Alloc PE / Size 0 / 0 Free PE / Size 6399 / <25.00 GiB VG UUID O8DkXu-bkqE-cHuQ-gdmj-gZdn-nY9c-7mHA3I # lvcreate -n lv_logs --size 25G vg_logs Volume group "vg_logs" has insufficient free space (6399 extents): 6400 required.
Let’s try this again but using the extents vs. size:
# vgs -o +vg_free_count,vg_extent_count VG #PV #LV #SN Attr VSize VFree Free #Ext rhel 1 2 0 wz--n- 78.00g 0 0 19968 vg_logs 1 0 0 wz--n- <25.00g <25.00g 6399 6399 vg_sys 1 3 0 wz--n- 420.99g <100.15g 25638 107774 # lvcreate -l6399 -n lv_logs vg_logs Logical volume "lv_logs" created.
Make a file system and mount new volume
# mkfs.ext4 /dev/vg_logs/lv_logs mke2fs 1.42.9 (28-Dec-2013) Filesystem label= OS type: Linux Block size=4096 (log=2) Fragment size=4096 (log=2) Stride=0 blocks, Stripe width=0 blocks 1638400 inodes, 6552576 blocks 327628 blocks (5.00%) reserved for the super user First data block=0 Maximum filesystem blocks=2155872256 200 block groups 32768 blocks per group, 32768 fragments per group 8192 inodes per group Superblock backups stored on blocks: 32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 4096000 Allocating group tables: done Writing inode tables: done Creating journal (32768 blocks): done Writing superblocks and filesystem accounting information: done
Add new volumes to fstab & Verify your filesystem type (example):
# file -s /dev/dm-7 /dev/dm-7: Linux rev 1.0 ext4 filesystem data, UUID=e31011c0-0d03-445e-ba03-81ef7bbbe803 (extents) (64bit) (large files) (huge files)
It should look something like this:
# /etc/fstab # Created by anaconda on Mon Apr 30 20:35:04 2018 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/rhel-root / xfs defaults 0 0 UUID=52ea678a-e4d5-4f2b-9619-835421bb9527 /boot xfs defaults 0 0 /dev/mapper/rhel-swap swap swap defaults 0 0 # /dev/mapper/vg_sys-bp2 /opt/ciena/bp2 ext4 rw,relatime,x-gvfs-name=bp2 0 2 /dev/mapper/vg_sys-loads /opt/ciena/loads ext4 rw,relatime,x-gvfs-name=loads 0 2 /dev/mapper/vg_logs-lv_logs /var/log/ciena ext4 rw,relatime,x-gvfs-name=lv_logs 0 2
Move all logs from the current location to a temporary location
# cd /var/log # mv ciena ciena-orig
Make new mount point, change ownership from root:root to bpuser:docker:
# mkdir ciena; chown bpuser:docker ciena # ls -l |grep ciena drwxr-xr-x 3 bpuser docker 4096 Jan 29 21:41 ciena drwxr-xr-x 2 bpuser docker 8192 Jan 29 18:01 ciena-orig
Mount new filesystem and move files over:
# mount -a # mv ciena-orig/* ciena # rmdir ciena-orig
Add storage to Existing Logical Volume docker-pool (a thin pool) in volume group vg_sys
# vgs vg_sys VG #PV #LV #SN Attr VSize VFree vg_sys 1 3 0 wz--n- 420.99g <100.15g # lvdisplay vg_sys --- Logical volume --- LV Path /dev/vg_sys/bp2 LV Name bp2 VG Name vg_sys LV UUID UazWpM-qLSi-b6Wk-JgZp-ItAj-CQPK-W2gpuO LV Write Access read/write LV Creation host, time dalblueplanet01.int.logixcom.net, 2018-05-04 12:43:49 -0500 LV Status available # open 1 LV Size 120.00 GiB Current LE 30720 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:2 --- Logical volume --- LV Path /dev/vg_sys/loads LV Name loads VG Name vg_sys LV UUID 8BSI5Q-Hd8R-jHFv-kBWv-MthZ-XC3k-4rtkul LV Write Access read/write LV Creation host, time dalblueplanet01.int.logixcom.net, 2018-05-04 13:02:12 -0500 LV Status available # open 1 LV Size 100.00 GiB Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:3 --- Logical volume --- LV Name docker-pool VG Name vg_sys LV UUID rpYux1-5WAr-rCbK-dhQU-gu0r-N4c0-Y52exj LV Write Access read/write LV Creation host, time dalblueplanet01.int.logixcom.net, 2018-05-07 11:15:25 -0500 LV Pool metadata docker-pool_tmeta LV Pool data docker-pool_tdata LV Status available # open 0 LV Size 100.00 GiB Allocated pool data 49.18% Allocated metadata 8.47% Current LE 25600 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:6
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 70.00g swap rhel -wi-ao---- 8.00g lv_logs vg_logs -wi-ao---- <25.00g bp2 vg_sys -wi-ao---- 120.00g docker-pool vg_sys twi-a-t--- 100.00g 49.18 8.47 loads vg_sys -wi-ao---- 100.00g
The docker-pool is a thin pool, to extend a thin pool with the new 100G, we do:
# lvextend -L+100G vg_sys/docker-pool Size of logical volume vg_sys/docker-pool_tdata changed from 100.00 GiB (25600 extents) to 200.00 GiB (51200 extents). Logical volume vg_sys/docker-pool_tdata successfully resized.
Let’s see if space is allocated now:
# lvs LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert root rhel -wi-ao---- 70.00g swap rhel -wi-ao---- 8.00g lv_logs vg_logs -wi-ao---- <25.00g bp2 vg_sys -wi-ao---- 120.00g docker-pool vg_sys twi-a-t--- 200.00g 24.59 8.49 loads vg_sys -wi-ao---- 100.00g
# blkid -o list device fs_type label mount point UUID -------------------------------------------------------------------------------------------------------- /dev/mapper/rhel-root xfs / de350e40-a78e-4121-a20c-811e1ba09fbe /dev/sda2 LVM2_member (in use) UTl9SH-ASsa-0shU-g2Z3-kNp1-CRkn-nbRi4i /dev/sda1 xfs /boot 52ea678a-e4d5-4f2b-9619-835421bb9527 /dev/sda3 LVM2_member (in use) RVj7ay-rZTV-qZax-XimA-qceW-N3KK-avvP3l /dev/mapper/rhel-swap swap <swap> 05882676-dbf4-40b3-beb2-fe17d426931d /dev/mapper/vg_sys-bp2 ext4 /opt/ciena/bp2 b421a53e-83a9-48c9-9ab6-b4594c83dfe3 /dev/mapper/vg_sys-loads ext4 /opt/ciena/loads cfd6c1c9-e3d1-4666-b268-508f0df128ea /dev/sdb1 (not mounted) /dev/sdb2 (not mounted)