1.查看当前Linux服务器磁盘分区
1 # df -Th
2.查看当前服务器硬盘
1 # fdisk -l
图中磁盘 /dev/sdb为未挂载的磁盘(磁盘符号依次为sda、sdb、sdc……)
后面以sdb为例
3.磁盘分区
# fdisk /dev/sdb (依次键入) n 回车 p 回车 1 回车 (此处为数字1,不是l) 回车 w
4.格式化
1 # mkfs -t ext4 -c /dev/sdb1
5.挂载磁盘
1 # mkdir /data (/下创建目录data用于挂载) 2 # mount /dev/sdb1 /data
6.设置开机自动挂载
1 vi /etc/fstab
在最后一行添加
/dev/sdb1 /data ext4 defaults 0 0
:wq(保存)
7.检查
再次输入命令:
1 # df -Th
最后一行可发现/data目录已挂载硬盘sdb,有50G容量