环境:ubuntu 18.04

查看新插入的磁盘

使用指令 sudo fdisk -l 查看磁盘是否被操作系统正确识别

Disk /dev/sdc: 4.6 TiB, 5000981078016 bytes, 9767541168 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

格式化磁盘

这里将磁盘格式化为ext4格式

sudo mkfs.ext4 /dev/sdc

挂载

将磁盘挂载到指定目录以使用

sudo mount /dev/sdc ~/disk/disk2

开机自动挂载

root权限打开/etc/fstab文件,添加:

UUID=7c07bcbe-b2c5-47e6-be0e-f7ad8a70609b /home/gpu-server/disk/disk2           ext4    defaults        0       2

UUID代表磁盘的唯一id,可以通过以下指令获取

ls -l /dev/disk/by-uuid/ 

total 0
lrwxrwxrwx 1 root root 10 6月  24 15:24 2424f4a3-86cb-40b1-85a1-73b2cec2103c -> ../../sdb1
lrwxrwxrwx 1 root root 10 6月  24 15:24 346e43e7-eb71-42b2-b65a-88d1dae16e51 -> ../../sdb5
lrwxrwxrwx 1 root root  9 6月  24 15:24 38d77a16-67d6-4c73-8096-4349be42c49f -> ../../sdf
lrwxrwxrwx 1 root root  9 6月  24 15:24 3ba647a5-0df9-47a4-b7cf-5e6cd385e708 -> ../../sda
lrwxrwxrwx 1 root root  9 6月  24 15:24 616f6cb1-52ca-4e55-a81c-d8b13475dad3 -> ../../sdd
lrwxrwxrwx 1 root root  9 6月  24 15:24 7c07bcbe-b2c5-47e6-be0e-f7ad8a70609b -> ../../sdc
lrwxrwxrwx 1 root root  9 6月  24 15:24 8c8db948-ce45-4707-aa6e-737fec350600 -> ../../sdg
lrwxrwxrwx 1 root root  9 6月  24 15:24 e14eac32-1bfc-4296-ba01-e1aa3d5238ba -> ../../sde
lrwxrwxrwx 1 root root 10 6月  24 15:24 fa564b4a-cacf-4a51-9f7a-23ad0ba43a08 -> ../../sdb6

参考

Linux查看与挂载新磁盘