## 查看當前linux服務器分區
```
df -h
```
:-: 
無掛載盤

有掛在盤
## 查看當前linux服務器硬盤:
```
fdisk -l
```
:-: 
無掛在盤

有掛在盤
/dev/vda 第一塊硬盤
/dev/vdb 第二塊硬盤
依此類推
以/dev/vdb為新增硬盤為例,需要進行以下操作方可正常使用(圖上有掛在盤的已經分區好了)
### 1、分區
```
fdisk /dev/vdb
```
按m回車查看help幫助,如下圖所示

幫助內容如下
```
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition
l list known partition types
m print this menu
n add a new partition
o create a new empty DOS partition table
p print the partition table
q quit without saving changes
s create a new empty Sun disklabel
t change a partition's system id
u change display/entry units
v verify the partition table
w write table to disk and exit
x extra functionality (experts only)
```
依次輸入
```
n,回車
p,回車
1,回車
回車
w
```
### 2、格式化
```
mkfs -t ext4 -c /dev/vdb1
```
### 3、掛載(掛載目錄可自行定義)
```
mount /dev/vdb1 /opt
```
其中/dev/vdb1為你剛才創建的分區,/opt是你自定義掛載的目錄
```
[root@host-192-168-0-7 ~]# mount /dev/vdb1 /home/wwwroot
mount: mount point /www_data does not exist
[root@host-192-168-0-7 ~]# mkdir /home/wwwroot
[root@host-192-168-0-7 ~]# mount /dev/vdb1 /home/wwwroot
```
如果失敗請查看需要手動創建home目錄
```
mkdir home
```

4、設置開機自動掛載(如果不設置開機自動掛載,重啟后不會自動
掛載分區)
```
vi /etc/fstab
```
在最后面添加一行
```
/dev/sdb1 /home/wwwroot ext4 defaults 0 0
```

配置完畢
再使用df -h查看是否正常掛載了。

重啟服務器系統,再次使用df -h命令驗證