1
2
3
4
5
6
7
8
|
[root@xpleaf ~]# fdisk -l /dev/sdb
Disk /dev/sdb:
1073
MB, 1073741824bytes
255
heads,
63
sectors/track, 130cylinders
Units = cylinders of
16065
*
512
=
8225280
bytes
Sector size (logical/physical): 512bytes /
512
bytes
I/O size (minimum/optimal):
512
bytes/
512
bytes
Disk identifier:
0x00000000
|
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
|
[root@xpleaf ~]# fdisk /dev/sdb ===>直接接磁盘名就可以分区
Device contains neither a valid DOSpartition table, nor Sun, SGI or OSF disklabel
Building a
new
DOS disklabel
with
diskidentifier
0x7f3aa9cb
.
Changes will remain
in
memory only,until you decide to write them.
After that, of course, the previouscontent won't be recoverable.
Warning: invalid flag
0x0000
ofpartition table
4
will be corrected by w(rite)
WARNING: DOS-compatible mode isdeprecated. It's strongly recommended to
switch
off the mode (command
'c'
) andchange display units to
sectors (command
'u'
).
Command (m
for
help): m
Command action
a toggle a bootable flag
b edit bsd disklabel
c toggle the dos compatibilityflag
d
delete
a partition ===>删除一个分区
l list known partition types ===>查看分区类型对应编号列表
m print
this
menu ===>打印此帮助菜单
n add a
new
partition ===>新建一个分区
o create a
new
empty DOSpartition table
p print the partition table ===>打印分区表
q quit without saving changes ===>退出但不保存更改
s create a
new
empty Sundisklabel
t change a partition's system id ===>更改分区类型(做LVM时需要)
u change display/entry units
v verify the partition table
w write table to disk and exit ===>将操作写入分区表并退出程序
x extra functionality (expertsonly)
Command (m
for
help): n
Command action
e extended
p primary partition (
1
-
4
)
p ===>新建一个主分区
Partition number (
1
-
4
):
1
===>指定主分区的分区号码
First cylinder (
1
-
130
,
default
1
): ===>指定分区开始的柱面号
Usingdefault value
1
Last cylinder, +cylinders or+size{K,M,G} (
1
-
130
,
default
130
): +100M
===>指定分区结束的柱面号,或者指定分区大小,让fdisk自动判断结束柱面号
Command (m
for
help): p
Disk /dev/sdb:
1073
MB, 1073741824bytes
255
heads,
63
sectors/track, 130cylinders
Units = cylinders of
16065
*
512
=
8225280
bytes
Sector size (logical/physical): 512bytes /
512
bytes
I/O size (minimum/optimal):
512
bytes/
512
bytes
Disk identifier:
0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1
1
14
112423
+
83
Linux
Command (m
for
help): n
Command action
e extended
p primary partition (
1
-
4
)
e ===>新建一个扩展分区
Partition number (
1
-
4
):
1
Partition
1
is
already defined. Delete it before re-adding it.
===>由于前面已经使用了分区号码
1
,所以这里会提示错误
Command (m
for
help): n
Command action
e extended
p primary partition (
1
-
4
)
e
Partition number (
1
-
4
):
2
First cylinder (
15
-
130
,
default
15
):
Usingdefault value
15
Last cylinder, +cylinders or+size{K,M,G} (
15
-
130
,
default
130
):
Usingdefault value
130
===>分区的开始柱面号和结束柱面号都使用默认值,即把剩余磁盘空间分配给该分区
Command (m
for
help): p
Disk /dev/sdb:
1073
MB, 1073741824bytes
255
heads,
63
sectors/track, 130cylinders
Units = cylinders of
16065
*
512
=
8225280
bytes
Sector size (logical/physical): 512bytes /
512
bytes
I/O size (minimum/optimal):
512
bytes/
512
bytes
Disk identifier:
0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1
1
14
112423
+
83
Linux
/dev/sdb2
15
130
931770
5
Extended
Command (m
for
help): n
Command action
l logical (
5
or over) ===>由于扩展分区只能有一个,上面新建扩展分区后
p primary partition (
1
-
4
) 这里就显示逻辑分区了,也可以看到fdisk命令,
p 要想新建逻辑分区,需要先新建扩展分区
Partition number (
1
-
4
):
3
No free sectors available
===>这里还想再新建一个主分区,但是提示已经没有磁盘空间剩余
Command (m
for
help): n
Command action
l logical (
5
or over)
p primary partition (
1
-
4
)
l ===>新建一个逻辑分区
First cylinder (
15
-
130
,
default
15
):
Usingdefault value
15
Last cylinder, +cylinders or+size{K,M,G} (
15
-
130
,
default
130
): +400M
Command (m
for
help): p
Disk /dev/sdb:
1073
MB, 1073741824bytes
255
heads,
63
sectors/track, 130cylinders
Units = cylinders of
16065
*
512
=
8225280
bytes
Sector size (logical/physical): 512bytes /
512
bytes
I/O size (minimum/optimal):
512
bytes/
512
bytes
Disk identifier:
0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1
1
14
112423
+
83
Linux
/dev/sdb2
15
130
931770
5
Extended
/dev/sdb5
15
66
417658
+
83
Linux
Command (m
for
help): n
Command action
l logical (
5
or over)
p primary partition (
1
-
4
)
l
First cylinder (
67
-
130
,
default
67
):
Usingdefault value
67
Last cylinder, +cylinders or+size{K,M,G} (
67
-
130
,
default
130
):
Usingdefault value
130
Command (m
for
help): p
Disk /dev/sdb:
1073
MB, 1073741824bytes
255
heads,
63
sectors/track, 130cylinders
Units = cylinders of
16065
*
512
=
8225280
bytes
Sector size (logical/physical): 512bytes /
512
bytes
I/O size (minimum/optimal):
512
bytes/
512
bytes
Disk identifier:
0x7f3aa9cb
Device Boot Start End Blocks Id System
/dev/sdb1
1
14
112423
+
83
Linux
/dev/sdb2
15
130
931770
5
Extended
/dev/sdb5
15
66
417658
+
83
Linux
/dev/sdb6
67
130
514048
+
83
Linux
Command (m
for
help): w ===>保存更改
The partition table has been altered!
Calling ioctl() to re-read partitiontable.
Syncing disks.
|
1
|
[root@xpleaf ~]# partprobe /dev/sdb
|
1
2
3
4
5
6
|
[root@xpleaf ~]# mkfs.ext4 /dev/sdb
sdb sdb1 sdb2 sdb5 sdb6
[root@xpleaf ~]# mkfs.ext4 /dev/sdb1
……
This filesystem will be automaticallychecked every
31
mounts or
180
days, whichever comes first. Use tune2fs -c or -i to
override
.
|
1
2
3
|
[root@xpleaf ~]# tune2fs -c -
1
/dev/sdb1
tune2fs
1.41
.
12
(
17
-May-
2010
)
Setting maximal mount count to -
1
|
1
2
3
4
5
6
7
|
[root@xpleaf ~]# mount /dev/sdb1 /mnt
[root@xpleaf ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3
9
.2G
1
.8G
7
.0G
21
% /
tmpfs 937M
0
937M
0
% /dev/shm
/dev/sda1 194M 34M 151M
19
% /boot
/dev/sdb1 107M
5
.6M 96M
6
% /mnt
|
1
2
3
4
5
6
|
n
p
1
0
100M
w
|
1
|
fdisk /dev/hda < fdiskcmd.txt
|