Usually, the second disk is named /dev/sdb.
You will be prompted to enter parameters:
command (m for help):n
Partition number(1-4):1
First cylinder (1-22800,default 1):Enter
command (m for help):w
- Mount the disk to the target directory
1
2
| mkdir /data
mount -t ext4 /dev/sdb /data
|
- Mount the directory automatically at boot
First find the device UUID.
1
2
3
| blkid |grep /dev/sdb
/dev/sdb: UUID="328a9d32-abb6-492a-aabe-b6a63583674d" TYPE="ext4"
|
Edit /etc/fstab to add the mount entry.
1
2
3
| vim /etc/fstab
UUID=328a9d32-abb6-492a-aabe-b6a63583674d /dev/sdb ext4 defaults 0 0
|
1.1 Adding a Data Disk to a Cloud Server
After scaling up a cloud instance, the new disk may be named /dev/vdc and so on. The steps are as follows.
- Find the device name of the new disk
- Partition
Select in order:
- n add a new partition
- p primary partition (1-4), choose as needed
- Format
- Mount
1
2
| mkdir /local_dir
mount /dev/vdc /local_dir
|
2. Migrating Docker Storage
- Move the Docker storage data
1
| mv /var/lib/docker /data/
|
1
| ln -s /data/docker /var/lib/docker
|