• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

The Geek Diary

CONCEPTS | BASICS | HOWTO

  • OS
    • Linux
    • CentOS/RHEL
    • Solaris
    • Oracle Linux
    • Linux Services
    • VCS
  • Database
    • oracle
    • oracle 12c
    • ASM
    • mysql
    • MariaDB
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Interview Questions
  • Big Data
    • Hadoop
    • Cloudera
    • Hortonworks HDP

How to find docker storage device and its size (device mapper storage driver)

By admin

Question: How to find the running docker storage device when docker is using the device-mapper storage driver and then check the size of it?

1. Please run the “docker info” command to display docker system-wide information which contains the docker storage info.

# docker info

Containers: 0
Running: 0
Paused: 0
Stopped: 0
Images: 0
Server Version: 18.03.1-ol
Storage Driver: devicemapper
Pool Name: docker-251:0-102683530-pool
Pool Blocksize: 65.54kB
Base Device Size: 26.84GB
Backing Filesystem: xfs
Udev Sync Supported: true
Data file: /dev/loop0   data file
Metadata file: /dev/loop1      metadata file
Data loop file: /var/lib/docker/devicemapper/devicemapper/data      data file
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata        metadata file
Data Space Used: 14.42MB        used space of data file
Data Space Total: 107.4GB       total space of data file
Data Space Available: 14.71GB 
Metadata Space Used: 581.6kB        used space of metadata file
Metadata Space Total: 2.147GB       total space of metadata file
Metadata Space Available: 2.147GB
Thin Pool Minimum Free Space: 10.74GB
Deferred Removal Enabled: true
Deferred Deletion Enabled: true
Deferred Deleted Device Count: 0
Library Version: 1.02.135-RHEL7 (2016-09-28)
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
Volume: local
Network: bridge host macvlan null overlay
Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: run
...

2. We can also use “lsblk” and “blkid” to check the layout and UUID of the docker storage.

# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 20G 0 disk
├─sda1 8:1 0 1G 0 part /boot
└─sda2 8:2 0 19G 0 part
├─ol-root 251:0 0 17G 0 lvm /
└─ol-swap 251:1 0 2G 0 lvm [SWAP]
sr0 11:0 1 1024M 0 rom
sr1 11:1 1 1024M 0 rom
loop0 7:0 0 100G 0 loop
└─docker-251:0-102683530-pool 251:2 0 100G 0 dm
loop1 7:1 0 2G 0 loop
└─docker-251:0-102683530-pool 251:2 0 100G 0 dm
# blkid
...
/dev/loop0: UUID="19e56ade-5aeb-476f-aa95-ce68ec99b17a" TYPE="xfs"
/dev/mapper/docker-251:0-102683530-pool: UUID="19e56ade-5aeb-476f-aa95-ce68ec99b17a" TYPE="xfs"

3. We can find the actual loopback-mounted sparse files on the file system.

# ll /var/lib/docker/devicemapper/devicemapper -l
total 13904
-rw-------. 1 root root 107374182400 Jan 7 09:47 data     100 GB displayed size
-rw-------. 1 root root 2147483648 Jan 7 10:48 metadata    2 GB displayed size
# du -skh *
13M data      13MB actual size
600K metadata        600 KB actual size

4. We can also use “losetup” to query the mapping of the loop devices for docker storage.

# losetup -a
/dev/loop0: [64256]:33600329 (/var/lib/docker/devicemapper/devicemapper/data)
/dev/loop1: [64256]:33600330 (/var/lib/docker/devicemapper/devicemapper/metadata)

Hence, from the above output, we can find that the docker storage is running in loop mode. This is indicated by the fact that the data loop file and a metadata loop file are on files under /var/lib/docker/devicemapper. These are loopback-mounted sparse files. Therefore the size of these displayed sparse files is much bigger than their actual size on the disk.

Filed Under: DevOps, Docker, Linux

Some more articles you might also be interested in …

  1. ‘ip’ Command cheat sheet (Command Line Reference)
  2. How to Count lines in a file in UNIX/Linux
  3. Server Application Getting “connection refused” From Remote Servers [due to firewalld or iptables] – CentOS/RHEL 7
  4. RedHat / CentOS : How to change currently active slave interface of bonding online
  5. LVM Configuration : Volume Group (VG) Operations/Utilities
  6. How to allow or deny telnet login to specific users only in CentOS/RHEL
  7. CentOS / RHEL : How to Install and Configure OpenSSH Server and Client
  8. Linux OS Service ‘sshd’
  9. How systemd-tmpfiles cleans up /tmp/ or /var/tmp (replacement of tmpwatch) in CentOS / RHEL 7
  10. New User Failed Run Kubectl with Error “The connection to the server xxx.xxx.xxx was refused – did you specify the right host or port?”

You May Also Like

Primary Sidebar

Recent Posts

  • How to set the default character set in MySQL and how to propagate it in a master-master replication scenario
  • “Connection reset by peer” – error while ssh into a CentOS/RHEL system with a specific user only
  • MySQL: how to figure out which session holds which table level or global read locks
  • Recommended Configuration of the MySQL Performance Schema
  • Archives
  • Contact Us
  • Copyright

© 2021 · The Geek Diary