1. hard disk formatting

  • View new disk

    1
    
    fdisk -l
    

Usually, the name of the second hard disk will be /dev/sdb.

  • Disk partition

    1
    
    fdisk /dev/sdb
    

There will be a prompt to enter the following parameters.

1
2
3
4
command (m for help):n
Partition number(1-4):1
First cylinder (1-22800,default 1):Enter
command (m for help):w
  • Format the disk as ext4

    1
    
    mkfs.ext4 /dev/sdb
    
  • Mount the disk to the specified directory

    1
    2
    
    mkdir /data
    mount -t ext4 /dev/sdb /data
    
  • Auto-mount directory on boot

    First find the UUID of the device.

    1
    2
    3
    
    blkid |grep /dev/sdb
    
    /dev/sdb: UUID="328a9d32-abb6-492a-aabe-b6a63583674d" TYPE="ext4"
    

    Edit /etc/fstab to add a new mount entry.

    1
    2
    3
    
    vim /etc/fstab 
    
    UUID=328a9d32-abb6-492a-aabe-b6a63583674d /dev/sdb ext4 defaults 0 0
    

2. Migrating Docker Storage

  • Suspend Docker

    1
    
    systemctl stop docker
    
  • Mobile Docker Storage Data

    1
    
    mv /var/lib/docker /data/
    
  • Create a new link

    1
    
    ln -s /data/docker /var/lib/docker
    
  • Restart Docker

    1
    
    systemctl start docker