需求說明:
雲服務器上買了一塊8T的磁盤,准備掛載到服務器上的/data目錄下。







parted命令說明
# parted /dev/vdb 對/dev/sdb進行分區或管理操作 parted創建分區里的交互模式的操作說明 mklabel gpt 定義分區表格式(常用的有msdos和gpt分區表格式,msdos不支持2TB以上容量的磁盤,所以大於2TB的磁盤選gpt分區表格式) (parted) mkpart p1 創建第一個分區,名稱為p1(p1只是第一個分區的名稱,用別的名稱也可以,如part1)。如果只創建一個分區,可以不用寫分區名,默認即可。如上。 File system type? [ext2]? ext4 定義分區格式。(不支持ext4的,想分ext4格式的分區,可以通過mkfs.ext4格式化成ext4格式) Start? 1 定義分區的起始位置(單位支持K,M,G,T) End? 300G 定義分區的結束位置(單位支持K,M,G,T)。如果創建多個分區,下一個分區的Start就從上一個分區的End開始 (parted) print或在p 查看當前分區情況 quit 退出 刪除分區 (parted) rm rm刪除命令(刪除之前必須確保分區沒有被掛載) Partition number? 1 刪除第一個分區 (通過p可以查看到,查看結果中的第一列) (parted) print或在p 查看當前分區情況 quit 退出 格式化幾個TB的磁盤的說明 在格式化幾個TB的磁盤的時候,時間會非常的長,格式化6T的磁盤時間大概在一個半小時左右。(據硬盤實際情況而定)
Fdisk命令簡單小結
1. 查看可用的磁盤
[root@VM_16_9_centos ~]# fdisk -l /dev/vd[a-z]
Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005fc9a
Device Boot Start End Blocks Id System
/dev/vda1 * 2048 104857599 52427776 83 Linux
Disk /dev/vdb: 75.2 GB, 75161927680 bytes, 146800640 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0005fc9a
Device Boot Start End Blocks Id System
/dev/vdb1 * 2048 104857599 52427776 83 Linux
解釋說明:
sectors(或者顯示是cylinders)# 柱面總數
Device Boot Start End Blocks Id System
Device ## 設備文件路徑
Boot ## 是否為引導加載器、kernle所在的分區,用*表示
Start ## 起始柱面 分區划分:按柱面,由外向內,編號依次增大
End ## 結束柱面
Blocks ## 磁盤塊數
Id ## id標示
System ## 系統標示
注意:結束柱面不等於總柱面數即可分區,除了System: Extended的分區
2. 修改分區表
[root@localhost ~]# fdisk /dev/vdb
n 創建一個新分區
d 刪除
l 列出分區的id標示
t 調整id
q 退出
w 保存退出
m manual
p 顯示分區表信息
4. 創建分區,修改id。比如修改分區id為82
[root@localhost ~]# fdisk /dev/vdb
........
........
Command (m for help): n
First cylinder (14119-15665, default 14119):
Using default value 14119
Last cylinder, +cylinders or +size{K,M,G} (14119-15665, default 15665): +10G
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 82 ##則創建的改分區id為82
Changed system type of partition 5 to 82 (Linux *** / Solaris)
5. 讓內核識別添加的新分區
內核是否識別添加的新分區
[root@localhost ~]# ls /dev/vdb*
[root@localhost ~]# cat /proc/partitions
重讀分區表
[root@localhost ~]# partx -a /dev/vdb
[root@localhost ~]# partx -a /dev/vdb
更新分區表
[root@localhost ~]# partprobe /dev/vdb2 # vdb2是新創建出來的分區
6. 查看文件系統屬性信息
查看TYPE,LABEL,UUID
[root@localhost ~]# blkid /dev/vdb2
查看默認掛載屬性、超級塊信息
[root@localhost ~]# tune2fs -l /dev/vdb2
[root@localhost ~]# dumpe2fs -h /dev/vdb2
查看塊組信息
[root@localhost ~]# dumpe2fs /dev/vdb2
