Docker is consuming my boot volume quickly, I wanted to dedicated a hard drive just for docker images.
Provision ext4 volume
- Start gdisk program (new hard disk: /dev/sdb)
sudo gdisk /dev/sdb
- Remove all partition from the hard disk
d delete a partition
- Create a new partition
n add a new partition
Command (? for help): n
Partition number (1-128, default 1):
First sector (34-209715166, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-209715166, default = 209715166) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300):
Changed type of partition to 'Linux filesystem'
- Save the partition on disk
w write table to disk and exit
Command (? for help): w
Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!
Do you want to proceed? (Y/N): y
OK; writing new GUID partition table (GPT) to /dev/sdb.
The operation has completed successfully.
admiral@LorientK2:~$ sudo mkfs -t ext4 /dev/sdb1
mke2fs 1.42.9 (4-Feb-2014)
Discarding device blocks: done
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214139 blocks
1310706 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=4294967296
800 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, 7962624, 11239424, 20480000, 23887872
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
- Create a new ext4 fs on the partition
sudo mkfs -t ext4 /dev/sdb1
Mounting the new partition on boot
- Create a mounting point (e.g. /media/data)
sudo mkdir /media/data
- Edit /etc/fstab
sudo vi /etc/fstab
- Add line to the end of file
/dev/sdb1 /media/data ext4 defaults 0 2
- Reload mount
sudo mount -a
Bind /var/lib/docker to the new partition
- Create docker directory in the new partition
sudo mkdir /media/data/docker
- Stop docker service
sudo service docker stop
- Copy existing docker content to new directory
sudo rsync -aXS /var/lib/docker/. /media/data/docker/
- Compare directories
sudo diff -r /var/lib/docker /media/data/docker
- Edit /etc/fstab
sudo vi /etc/fstab
- Add line to the end of file
/media/data/docker /var/lib/docker none bind 0 0
- Reload mount
sudo mount -a
- Restart Docker
sudo service docker start
Reference
No comments:
Post a Comment