「大數據」(一百零一)常用分區工具

【導讀:數據是二十一世紀的石油,蘊含巨大價值,這是·情報通·大數據技術系列第[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 為數字。


分享到:


相關文章: