Migrate Docker Data - tulliolo/mobybolt GitHub Wiki
You can take advantage of this guide in the following situations:
- you have already installed MobyBolt on a single disk and want to migrate to the configuration with a separate storage for Docker data;
- you want to replace the disk for Docker data that is already on your system.
💡 If you are in case 2 and want to replace an internal drive, you can temporarily connect the new drive via USB3, complete the steps in this guide, and then replace the disk in the internal slot.
Run the following command (with example output):
$ lsblk -o NAME,MOUNTPOINT,UUID,FSTYPE,SIZE,LABEL,MODEL
> NAME MOUNTPOINT UUID FSTYPE SIZE LABEL MODEL
> sda 20G CYX-SSD-S1000
> ├─sda1 /boot/efi ED3D-37B3 vfat 512M
> ├─sda2 / b6649e30-d00b-4fd8-8ce0-b85be4c3075b ext4 18.5G
> └─sda3 [SWAP] b39d91f1-065d-41fd-be35-cbd96ac1ff3a swap 976M
> sdb 1.9T SPCC Solid State Disk
Here we will see if the new disk has been detected by the system and what unit name has been assigned to it. Normally sda is the name assigned for the primary disk, sdb for the secondary disk, and so on, but your case could be different, pay attention to the SIZE and MODEL columns to identify each one, e.g: 1.9T, SPCC Solid State Disk.
For each disk present, also pay attention to the MOUNT POINT column (any partitions of the disk you are looking for will not have any MOUNT POINT associated with them)
A performant SATA/USB3 unit storage is essential for your node.
Install hdparm:
$ sudo apt install -y hdparm
Let's check if your drive works well as-is:
$ sudo hdparm -t --direct /dev/<YOUR_DEVICE>
> Timing O_DIRECT disk reads: 932 MB in 3.00 seconds = 310.23 MB/sec
<YOUR_DEVICE> with your device, detected during the previous step.
ℹ️ If the measured speed is more than 150MB/sec, you're good.
Type this command to use the fdisk utility and manage the secondary disk:
$ sudo fdisk /dev/<YOUR_DEVICE>
<YOUR_DEVICE> with your device, detected during the previous step.
You will be in the fdisk prompt, where you'll need to follow the next steps:
-
Type
gandenter/returnkey in order to create a new GPT Partition Table. -
Type
nin order to create a new primary partition, and then pressenter/returnkey until the prompt shows you:Created a new partition X of type 'Linux filesystem'. -
Type
wandenter/returnkey in order to save the configuration and exit.
Partition X contains a Y signature. Do you want to remove the signature? [Y]es/[N]o. In this case, type y and press enter/return key until the prompt shows you: The signature will be removed by a write command.
ℹ️ This will create a new partition called probably sdb1.

Finally, format the new partition to Ext4 and obtain the UUID:
$ sudo mkfs.ext4 /dev/<YOUR_PARTITION>
<YOUR_PARTITION> with your partition, created during the previous step.
The output will look similar to the following as an example (take note of the Filesystem UUID):
> mke2fs 1.47.0 (5-Feb-2023)
> Discarding device blocks: done
> Creating filesystem with 503315968 4k blocks and 125829120 inodes
> Filesystem UUID: 774987cd-7827-47b2-813e-6fdb2692a182
> ...
If you have Docker data to migrate, you can follow the next steps:
-
Temporary mount the new partition:
$ sudo mount -m /dev/<YOUR_PARTITION> /mnt/temp⚠️ Remember to replace<YOUR_PARTITION>with your partition, created during the previous step. -
Shutdown docker:
$ sudo systemctl stop docker docker.socket -
Install rsync:
$ sudo apt install -y rsync -
Copy Docker data:
$ sudo rsync -av /var/lib/docker/ /mnt/temp/
Edit the fstab file and add the following line at the end, replacing <YOUR_UUID> with your own UUID:
$ sudo nano /etc/fstab
UUID=<yourUUID> /var/lib/docker ext4 defaults,noatime 0 2
/var/lib/docker mount point)
Reboot:
$ sudo reboot