I would like to use digitalocean's block storage decive as a dedicated file system to manage Docker containers. The plan is to have this file system mounted at /var/lib/docker at boot time, before the Docker service is started.
My attemps to do so thus far have been unsuccessful. While my playbook does not report an error, running ls -la /var/lib/docker
after formatting and partitioning DO's block storage device indicates that I might have a problem:
drwxr-xr-x 3 root root 4096
drwx--x--x 14 root root 4096
drwx------ 2 root root 16384 Jan 25 16:47 lost+found
After reading this, this, and this, I can't decipher what lost+found
means but I do grasp that it isn't a good sign.
I would like to understand why and fix it of course. My playbook is below (please note that playbook below is using static/explicit values due to needing to debug):
---
- name: mount point of attached volume
stat:
path: /mnt/name_of_attached_volume
- name: get digital_ocean_volume_path_by_name
stat:
path: /dev/disk/by-id/scsi-0DO_Volume_name_of_attached_volume
- name: unmount images volume
command: umount /mnt/name_of_attached_volume
- name: Label the volume
command: parted -s /dev/disk/by-id/scsi-0DO_Volume_name_of_attached_volume mklabel gpt
- name: Create an ext4 partition
command: parted -s -a opt /dev/disk/by-id/scsi-0DO_Volume__name_of_attached_volume mkpart primary ext4 0% 100%
- name: Build the ext4 metadata
command: mkfs.ext4 /dev/disk/by-id/scsi-0DO_Volume__name_of_attached_volume-part1
####################################################################
# since the mount point -- `/var/lib/docker` -- already exists #
# by virtue of docker being installed on the host, no need to #
# create a mount point but I do need stop docker running #
####################################################################
- name: stop docker service
service:
name: docker
state: stopped
- name: mount volume read-write
mount:
path: /var/lib/docker
src: /dev/disk/by-id/scsi-0DO_Volume__name_of_attached_volume-part1
fstype: ext4
opts: defaults,discard
dump: 0
passno: 2
state: mounted
- name: remove mount point for images volume
command: rmdir /mnt/name_of_attached_volume
- name: Start docker service
service:
name: docker
state: started
enabled: "{{ docker_service_enabled }}"
I am obviously missing/misunderstanding a step. Greatly appreciate tips please. Thank you!