【导读:数据是二十一世纪的石油,蕴含巨大价值,这是·情报通·大数据技术系列第[101]篇文章,欢迎阅读收藏】
1 基本概念
Linux 磁盘分区管理工具 fdisk 。 fdiskl 是 linux 操作系统自带的磁盘管理命令,可以查看、创建、删除磁盘分区。
2 术语解释
分区:对硬盘的一种 格式化 ,然后才能使用硬盘保存各种信息
磁柱( cylinder ):硬盘柱面,等于磁道数
3 详细说明
Linux 分区分为:主分区、扩展分区和逻辑分区,分区管理工具为 fdisk 。
查看磁盘当前分区状态:
[root@www ~]# fdisk [-l] 磁盘名称
参数: -l :输出后面的磁盘分区内容。若仅有 fdisk -l 时, 则系统将会把整个系统内能够搜索到的磁盘的分区均列出来。
示例:
<code>linux-q290:~ # fdisk -l /dev/sdpy
Disk /dev/sdpy: 598.0 GB, 597998698496 bytes
255 heads, 63 sectors/track, 72702 cylinders, total 1167966208 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk identifier: 0x00094c81
Device Boot Start End Blocks Id System
/dev/sdpy1 2048 33544191 16771072 82 Linux swap / Solaris
/dev/sdpy2 * 33544192 1167966207 567211008 83 Linux/<code>
分区管理:
<code>[root@www ~]# fdisk /dev/sdbb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x904dc04e.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
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
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)
d :删除分区
n :新建分区
q :不保存修改退出
w :保存修改并退出/<code>
删除分区:
[root@www ~]# fdisk /dev/hdc Command (m for help): d Partition number (1-5): 4
创建分区:
[root@www ~]# fdisk /dev/hdc
Command (m for help): n
Command action <== 因为是全新磁盘,因此会问 extended/primary 选项
e extended
p primary partition (1-4)
p <== 选择 Primary 分区
Partition number (1-4): 4 <== 设定为 4 号!
First cylinder (1-5005, default 1): <== 直接按下 [enter] 键决定
Using default value 1 <== 初始磁柱就选用默认值
Last cylinder or +size or +sizeM or +sizeK (1-5005, default 5005): +512M
Command (m for help): p
设置分区大小有 2 种方式( Last cylinder ):
1) 直接输入磁柱的编号,协议、需要自己计算磁柱 / 分割区的大小;
2) 用 +XXM 来输入分区的大小,让系统自己计算磁柱的号码。 # +XXM 是必项要有的, XX 为数字。
閱讀更多 情報通 的文章