云服务器挂载/dev/vdb1磁盘
1.首先检查是否有一块硬盘还未被挂载
2.如图所示,vdb还未被使用,开始分配它吧
[root@localhost ~]# fdisk /dev/vdb Command (m for help): n ##(m可以查看可以用哪些参数,n是划分一块新的盘符) Command action e extended p primary partition (1-4) ##(选择e是扩展分区,p是主分区,一块硬盘最多可以有3个主分区,我们这是第一次划分分区,所以选p) p Partition number (1-4): 1 ##(第一个分区) First cylinder (1-624152, default 1): ##(默认从1,按回车即可) Last cylinder, +cylinders or +size{K,M,G} (1-624152, default 624152): ##(因为我们是全部划分,默认是全部划分,按回车即可,如果只划分5G的话,那么输入+5G) Command (m for help): w ##(写入磁盘)
3.格式化刚划分的磁盘,我这里是格式成ext4格式
4.写入fstable
echo "/dev/vdb1 /data ext4 defaults 0 0" >> /etc/fstab
5.重新加载fstable,并查看磁盘是否加载成功
###如上,大功告成啦
最后,赠送上述步骤脚本一枚
#!/bin/bash ##author:tom.zhang ##date:2019-03-18 ##work:云服务器挂载/dev/vdb1磁盘 Check_vdb=`fdisk -l |grep /dev/vdb` Check_vdb1=`fdisk -l |grep /dev/vdb1` if [[ -z ${Check_vdb} ]];then echo "Disk /dev/vdb not exist!!!!" exit 1 fi if [[ ! -z ${Check_vdb1} ]];then echo "Disk /dev/vdb1 exist,please check!!!!" exit 1 fi echo "n p 1 w" | fdisk /dev/vdb sleep 3 Check_vdb1=`fdisk -l |grep /dev/vdb1` if [[ -z ${Check_vdb1} ]];then echo "Disk /dev/vdb1 create fail!!!!" exit 1 fi mkfs.ext4 /dev/vdb1 echo "/dev/vdb1 /data ext4 defaults 0 0" >> /etc/fstab mount -a df -h rm -f $0
exit 0