1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
# 使用 fdisk 磁盘管理命令
[root@FXQ-YWYY-57-81 ~]# fdisk /dev/vda
Welcome to fdisk (util-linux 2.35.2).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.
Command (m for help): p
Disk /dev/vda: 50 GiB, 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
Disklabel type: gpt
Disk identifier: 55A9D713-559A-436B-BA30-299A54040073
Device Start End Sectors Size Type
/dev/vda1 2048 1230847 1228800 600M EFI System
/dev/vda2 1230848 3327999 2097152 1G Linux filesystem
/dev/vda3 3328000 70436863 67108864 32G Linux filesystem
Command (m for help): m
Help:
GPT
M enter protective/hybrid MBR
Generic
d delete a partition # 删除
F list free unpartitioned space
l list known partition types
n add a new partition # 新增
p print the partition table
t change a partition type # 更改分区类型
v verify the partition table
i print information about a partition
Misc
m print this menu
x extra functionality (experts only)
Script
I load disk layout from sfdisk script file
O dump disk layout to sfdisk script file
Save & Exit
w write table to disk and exit
q quit without saving changes
Create a new label
g create a new empty GPT partition table
G create a new empty SGI (IRIX) partition table
o create a new empty DOS partition table
s create a new empty Sun partition table
# 新增 n ,内存取默认就行
Command (m for help): n
Partition number (4-128, default 4): 4
First sector (70436864-104857566, default 70436864):
Last sector, +/-sectors or +/-size{K,M,G,T,P} (70436864-104857566, default 104857566):
Created a new partition 4 of type 'Linux filesystem' and of size 16.4 GiB.
Partition #4 contains a swap signature.
# 默认 y
Do you want to remove the signature? [Y]es/[N]o: y
The signature will be removed by a write command.
# 保存
Command (m for help): w
The partition table has been altered.
Syncing disks.
# 让内核重新读取分区信息
[root@FXQ-YWYY-57-81 ~]# partprobe -s
/dev/vdb: msdos partitions 1
Warning: Unable to open /dev/sr0 read-write (Read-only file system). /dev/sr0 has been opened read-only.
/dev/sr0: msdos partitions
/dev/vda: gpt partitions 1 2 3 4
# 格式化分区,注意这是 filesystem 类型的分区格式化
[root@FXQ-YWYY-57-81 dev]# mkfs.xfs -f /dev/vda4
meta-data=/dev/vda4 isize=512 agcount=4, agsize=1075647 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=4302587, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
|