These instructions build on those provided here and here.
Before doing the following, create a new virtual disk and attach it to your VM. The size of the virtual disk just depends on what you intend to use/run and how many containers you intend to run. The default, 8 GB, is probably more than enough and is reasonable to use if in doubt since the default mode dynamically allocates the drive as needed.
Boot the VM and run just
fdisk -l
To see the disk device name(s) and their size. In this case it's the /dev/sda
shown here that has 8 GB capacity:
Disk /dev/sda: 8589 MB, 8589934592 bytes
Run the following to setup a partition on that disk:
sudo fdisk /dev/sda
Use the n
option to create a new partition, choose a p
(primary) partition and go with partition number 1. Accept the defaults for the cylinder choices to fill the entire disk.
Use w
to write the partition changes and exit.
If you get an error about ioctl not able to re-read, then reboot the VM:
sudo reboot
Format the filesystem on that partition being sure to assign the label boot2docker expects for the data volume:
sudo mkfs.ext4 -L boot2docker-data /dev/sda1
Reboot to allow the new disk and mount point to go into affect:
sudo reboot
To make sure it did what we expected, run
df
and confirm there is are /mnt/sda1
and /mnt/sda1/var/lib/docker
mounts (but with appropriate disk and partition identifiers for your setup). If you really want to connect all the dots, do
ls -ld /var/lib/docker
thanks, it is very useful for me