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

# 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
*************** 當你發現自己的才華撐不起野心時,就請安靜下來學習吧!***************