產品型號:Thinkpad E15
系統版本:centos8
案例:在sdb盤上建一個分區,大小為1G
在虛擬機上添加一塊硬盤
例:對sdb這塊盤劃分一個100M的分區出來
[root@xuegod63 ~]# fdisk /dev/sdb
...
Command (m for help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibility flag
d delete a partition 刪除分區
g create a new empty GPT partition table
G create an IRIX (SGI) partition table
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)
Command (m for help): p -----打印分區表
Command (m for help): n ----新建一個分區
Partition type:
p primary (2 primary, 0 extended, 2 free) p:主分區
e extended e:擴展分區
Select (default p): --#直接默認
Using default response p
Partition number (1,4, default 1): ---#直接默認
First sector (1230848-41943039, default 1230848): ---#直接默認
Using default value 1230848
Last sector, +sectors or +size{K,M,G} (1230848-41943039, default 41943039): +1G
#輸入分區大小
Partition 3 of type Linux and of size 1 GiB is set
Command (m for help): w #保存退出
格式化并創建文件系統
[root@xuegod63 ~]# mkfs.xfs /dev/sdb1
注:-f 參數可以對已經存在文件系統的分區,強制格式化
[root@xuegod63 ~]# mkdir /sdb1 #創建掛載點
[root@xuegod63 ~]# mount /dev/sdb1 /sdb1/ #掛載
[root@xuegod63 ~]# df -h #查看
總結:
1. 添加硬盤
2. fdisk /dev/sdb創建分區
3. mkfs.xfs /dev/sdb1格式化并創建文件系統
4. 創建掛載目錄/sdb1
5. 掛載/dev/sdb1到/sdb1