Step1. 查看空闲磁盘
$ lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT vda 252:0 0 40G 0 disk └─vda1 252:1 0 40G 0 part / vdb 252:16 0 100G 0 disk 点击复制复制失败已复制
可以看出, vdb
是一个新的数据盘,总共大小为 100G
,我们将其挂载到 /var/lib/docker
文件夹中。
$ sudo fdisk -l Disk /dev/vda: 40 GiB, 42949672960 bytes, 83886080 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0x713d4ca9 Device Boot Start End Sectors Size Id Type /dev/vda1 * 2048 83884031 83881984 40G 83 Linux Disk /dev/vdb: 100 GiB, 107374182400 bytes, 209715200 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes点击复制复制失败已复制
Step2. 格式化分区
$ sudo mkfs.ext4 /dev/vdb mke2fs 1.44.1 (24-Mar-2018) Found a dos partition table in /dev/vdb1 Proceed anyway? (y,N) y # 写y mkfs.ext4: inode_size (128) * inodes_count (0) too big for a filesystem with 0 blocks, specify higher inode_ratio (-i) or lower inode count (-N).点击复制复制失败已复制
Step3. 临时挂载
$ sudo mount /dev/vdb /var/lib/docker点击复制复制失败已复制
Step4. 永久挂载
$ sudo vim /etc/fstab # /etc/fstab: static file system information. # # Use 'blkid' to print the universally unique identifier for a # device; this may be used with UUID= as a more robust way to name devices # that works even if disks are added and removed. See fstab(5). # # <file system> <mount point> <type> <options> <dump> <pass> # / was on /dev/vda1 during installation UUID=558c12b2-c059-4be7-936b-49bcbf3b52a7 / ext4 errors=remount-ro 0 1 /dev/fd0 /media/floppy0 auto rw,user,noauto,exec,utf8 0 0 /dev/vdb /var/lib/docker ext4 defaults 0 0 # 最后这句是后加的