老男孩Linux58期17組劉藝 第21天筆記

第21天筆記 磁盤管理 Fdsik 創(chuàng)建分區(qū)

Raid是廉價(jià)冗余磁盤陣列(Redundant Array of Inexpensive Disk)的簡(jiǎn)稱, 有時(shí)也簡(jiǎn)稱磁盤陣列(Disk Array)惫撰。

RAID分為兩類:

軟RAID,系統(tǒng)層面實(shí)現(xiàn)的歉糜,性能差。

硬RAID咒精,硬件層面實(shí)現(xiàn)的锌钮,性能好陨闹。

主板板載RAID:功能弱,0聘芜,1

獨(dú)立RAID卡:功能強(qiáng)兄渺,0,1,5,10 *****工作選擇。

LVM全稱(Logic Volume Management (Manager))邏輯卷管理,它的最大用途是可以【靈活的管理磁盤的容量】汰现,讓磁盤分區(qū)可以隨意放大或縮小挂谍,便于更好的應(yīng)用磁盤的剩余空間,如果過于強(qiáng)調(diào)性能與備份瞎饲,那么還是應(yīng)該使用RAID功能口叙,而不是LVM。

LVM是軟件層面實(shí)現(xiàn)的企软,性能太低庐扫。性能降低5-10%。

買服務(wù)器插滿磁盤仗哨,分區(qū)規(guī)劃好形庭,永遠(yuǎn)都不需要LVM。

RAID1又稱為Mirror或Mirroring(鏡像)厌漂,

它的宗旨是最大限度的保證用戶數(shù)據(jù)的可用性和可修復(fù)性萨醒。

RAID1的操作方式是把用戶寫入一個(gè)磁盤的數(shù)據(jù)百分之百地自動(dòng)復(fù)制到另外

一個(gè)磁盤上,從而實(shí)現(xiàn)存儲(chǔ)雙份的數(shù)據(jù)苇倡。

RAID5描述 中庸

RAID5是一種存儲(chǔ)性能富纸、數(shù)據(jù)安全和存儲(chǔ)成本兼顧的存儲(chǔ)解決方案。

RAID5需要三塊或以上的物理磁盤旨椒,可以提供熱備盤實(shí)現(xiàn)故障的恢復(fù)晓褪;

采用【奇偶校驗(yàn)】,可靠性強(qiáng)综慎,且只有同時(shí)損壞兩塊硬盤時(shí)數(shù)據(jù)才會(huì)完全損壞涣仿,

只損壞一塊硬盤時(shí),系統(tǒng)會(huì)根據(jù)存儲(chǔ)的奇偶校驗(yàn)位重建數(shù)據(jù),臨時(shí)提供服務(wù)好港;此時(shí)如果有熱備盤愉镰,系統(tǒng)還會(huì)自動(dòng)在熱備盤上重建故障磁盤上的數(shù)據(jù);

分區(qū)知識(shí):

回憶:

(1)什么是分區(qū)钧汹?

磁盤分區(qū)就相當(dāng)于給磁盤打隔斷丈探。

(2)磁盤和分區(qū)在Linux里的命名。

IDE /dev/hda hdb

SCSI sda sdb

分區(qū)數(shù)字表示:sda1 sda2 sda3

(3)磁盤分區(qū)類型和特點(diǎn):

1拔莱、主分區(qū)(primary)P

1)系統(tǒng)中必須要存在的分區(qū)碗降,系統(tǒng)盤選擇主分區(qū)安裝。

2)數(shù)字編號(hào)只能是1-4.sda1辨宠、sda2遗锣、sda3货裹、sda4嗤形。

3)主分區(qū)最多四個(gè),最少一個(gè)弧圆。

2赋兵、擴(kuò)展分區(qū)(extend)E

1)相當(dāng)于一個(gè)獨(dú)立的小磁盤。獨(dú)立的分區(qū)表搔预,不能獨(dú)立存在霹期。

2)有獨(dú)立的分區(qū)表。

3)不能獨(dú)立存在拯田,即不能直接存放數(shù)據(jù)历造。

4)必須在擴(kuò)展分區(qū)上建立邏輯分區(qū)才能存放數(shù)據(jù)。

5)占用主分區(qū)的編號(hào)(主分區(qū)+擴(kuò)展分區(qū))之和最多4個(gè)船庇。

6)擴(kuò)展分區(qū)可以沒有吭产,最多只能有一個(gè)。

3鸭轮、邏輯分區(qū)(logic)L

2)數(shù)字編號(hào)只能是從5開始臣淤。

3)存放于擴(kuò)展分區(qū)之上。

4)存放任意普通數(shù)據(jù)窃爷。

磁盤分區(qū)注意事項(xiàng)要點(diǎn)

一塊硬盤的分區(qū)方式只能為如下組合之一:

(1)任意多個(gè)主分區(qū)邑蒋,但要求1≤主分區(qū)數(shù)量≤4。

例如:一個(gè)硬盤可以分為4個(gè)主分區(qū)3個(gè)主分區(qū)2個(gè)主分區(qū)或1個(gè)主分區(qū)按厘。

(2)擴(kuò)展分區(qū)可以和主分區(qū)組合医吊,但要求2≤(主分區(qū)+擴(kuò)展分區(qū))數(shù)量≤4)。

例如:3個(gè)主分區(qū)+1個(gè)擴(kuò)展分區(qū)或2個(gè)主分區(qū)+1個(gè)擴(kuò)展分區(qū)或1個(gè)主分區(qū)+1個(gè)擴(kuò)展分區(qū)逮京。

當(dāng)總分區(qū)的數(shù)量大于4個(gè)的時(shí)候卿堂,必須提前分一個(gè)擴(kuò)展分區(qū),擴(kuò)展分區(qū)最多只能有一個(gè)造虏。

(3)如果要分成四個(gè)磁盤分區(qū)的話御吞,那么最多就是可以:

P + P + P + P

P + P + P + E

問題:如果給一個(gè)磁盤分6個(gè)分區(qū)有哪些方案麦箍,同時(shí)寫出分區(qū)/dev/sda(數(shù)字)。

3P+1E(3L)? 1 2 3 5 6 7

2P+1E(4L)? 12 5678

1P+1E(5L)? 1 56789

分區(qū)分完了陶珠,空間還有剩余浪費(fèi)掉空間挟裂。

P + P + P + P

(4)磁盤分區(qū)工作原理:

磁盤是按柱面分區(qū)的。

磁盤分區(qū)登記的地點(diǎn)揍诽,磁盤分區(qū)表诀蓉。

磁盤分區(qū)表存放分區(qū)結(jié)果信息的。

磁盤分區(qū)表位置暑脆,0磁道0磁頭1扇區(qū)(512字節(jié))

占用1扇區(qū)的前446字節(jié)(系統(tǒng)引導(dǎo)信息的)后面的64字節(jié)(分區(qū)表)渠啤,

剩下2個(gè)字節(jié)分區(qū)結(jié)束標(biāo)志。

磁盤分區(qū)表的容量是有限的添吗,64字節(jié)沥曹,一個(gè)分區(qū)固定占16字節(jié)。

64/16=4分區(qū)(主分區(qū)+擴(kuò)展分區(qū))

(5)磁盤分區(qū)實(shí)戰(zhàn)

磁盤分區(qū)關(guān)鍵就是修改64字節(jié)的的分區(qū)表而已碟联。

磁盤分區(qū)常用命令fdisk妓美,修改MBR分區(qū)表,MBR格式鲤孵。

缺陷壶栋,被修改的磁盤大小不能大于2T。

磁盤分區(qū)其他命令parted,gpt分區(qū)格式普监,既能修改小于2T也能修改大于2T的磁盤贵试。

小于2T就用fdisk

大于2T就用parted

[root@yurenkang ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.

Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x248d9b1d.

Command (m for help): n

Partition type:

p? primary (0 primary, 0 extended, 4 free)

e? extended

Select (default p):

Using default response p

Partition number (1-4, default 1):

First sector (2048-2097151, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-2097151, default 2097151): +150M

Partition 1 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

Command (m for help): n

Partition type:

p? primary (1 primary, 0 extended, 3 free)

e? extended

Select (default p):

Using default response p

Partition number (2-4, default 2):

First sector (309248-2097151, default 309248):

Using default value 309248

Last sector, +sectors or +size{K,M,G} (309248-2097151, default 2097151): +150M

Partition 2 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

Command (m for help): n

Partition type:

p? primary (2 primary, 0 extended, 2 free)

e? extended

Select (default p):

Using default response p

Partition number (3,4, default 3):

First sector (616448-2097151, default 616448):

Using default value 616448

Last sector, +sectors or +size{K,M,G} (616448-2097151, default 2097151): +150M

Partition 3 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

/dev/sdb3? ? ? ? ? 616448? ? ? 923647? ? ? 153600? 83? Linux

Command (m for help):

Command (m for help): n

Partition type:

p? primary (3 primary, 0 extended, 1 free)

e? extended

Select (default e):

Using default response e

Selected partition 4

First sector (923648-2097151, default 923648):

Using default value 923648

Last sector, +sectors or +size{K,M,G} (923648-2097151, default 2097151):

Using default value 2097151

Partition 4 of type Extended and of size 573 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

/dev/sdb3? ? ? ? ? 616448? ? ? 923647? ? ? 153600? 83? Linux

/dev/sdb4? ? ? ? ? 923648? ? 2097151? ? ? 586752? ? 5? Extended

Command (m for help): n

All primary partitions are in use

Adding logical partition 5

First sector (925696-2097151, default 925696):

Using default value 925696

Last sector, +sectors or +size{K,M,G} (925696-2097151, default 2097151): +150M

Partition 5 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

/dev/sdb3? ? ? ? ? 616448? ? ? 923647? ? ? 153600? 83? Linux

/dev/sdb4? ? ? ? ? 923648? ? 2097151? ? ? 586752? ? 5? Extended

/dev/sdb5? ? ? ? ? 925696? ? 1232895? ? ? 153600? 83? Linux

Command (m for help): n

All primary partitions are in use

Adding logical partition 6

First sector (1234944-2097151, default 1234944):

Using default value 1234944

Last sector, +sectors or +size{K,M,G} (1234944-2097151, default 2097151): +150M

Partition 6 of type Linux and of size 150 MiB is set

Command (m for help): p

Disk /dev/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

/dev/sdb3? ? ? ? ? 616448? ? ? 923647? ? ? 153600? 83? Linux

/dev/sdb4? ? ? ? ? 923648? ? 2097151? ? ? 586752? ? 5? Extended

/dev/sdb5? ? ? ? ? 925696? ? 1232895? ? ? 153600? 83? Linux

/dev/sdb6? ? ? ? 1234944? ? 1542143? ? ? 153600? 83? Linux

Command (m for help): n

All primary partitions are in use

Adding logical partition 7

First sector (1544192-2097151, default 1544192):

Using default value 1544192

Last sector, +sectors or +size{K,M,G} (1544192-2097151, default 2097151): +150M

Partition 7 of type Linux and of size 150 MiB is set

Command (m for help): w

The partition table has been altered!

Calling ioctl() to re-read partition table.

Syncing disks.

[root@yurenkang ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.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/sdb: 1073 MB, 1073741824 bytes, 2097152 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: 0x248d9b1d

Device Boot? ? ? Start? ? ? ? End? ? ? Blocks? Id? System

/dev/sdb1? ? ? ? ? ? 2048? ? ? 309247? ? ? 153600? 83? Linux

/dev/sdb2? ? ? ? ? 309248? ? ? 616447? ? ? 153600? 83? Linux

/dev/sdb3? ? ? ? ? 616448? ? ? 923647? ? ? 153600? 83? Linux

/dev/sdb4? ? ? ? ? 923648? ? 2097151? ? ? 586752? ? 5? Extended

/dev/sdb5? ? ? ? ? 925696? ? 1232895? ? ? 153600? 83? Linux

/dev/sdb6? ? ? ? 1234944? ? 1542143? ? ? 153600? 83? Linux

/dev/sdb7? ? ? ? 1544192? ? 1851391? ? ? 153600? 83? Linux

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市凯正,隨后出現(xiàn)的幾起案子毙玻,更是在濱河造成了極大的恐慌,老刑警劉巖漆际,帶你破解...
    沈念sama閱讀 221,820評(píng)論 6 515
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件淆珊,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡奸汇,警方通過查閱死者的電腦和手機(jī)施符,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 94,648評(píng)論 3 399
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來擂找,“玉大人戳吝,你說我怎么就攤上這事」嵯眩” “怎么了听哭?”我有些...
    開封第一講書人閱讀 168,324評(píng)論 0 360
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我陆盘,道長(zhǎng)普筹,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 59,714評(píng)論 1 297
  • 正文 為了忘掉前任隘马,我火速辦了婚禮太防,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘酸员。我一直安慰自己蜒车,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 68,724評(píng)論 6 397
  • 文/花漫 我一把揭開白布幔嗦。 她就那樣靜靜地躺著酿愧,像睡著了一般。 火紅的嫁衣襯著肌膚如雪邀泉。 梳的紋絲不亂的頭發(fā)上嬉挡,一...
    開封第一講書人閱讀 52,328評(píng)論 1 310
  • 那天,我揣著相機(jī)與錄音呼渣,去河邊找鬼棘伴。 笑死寞埠,一個(gè)胖子當(dāng)著我的面吹牛屁置,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播仁连,決...
    沈念sama閱讀 40,897評(píng)論 3 421
  • 文/蒼蘭香墨 我猛地睜開眼蓝角,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了饭冬?” 一聲冷哼從身側(cè)響起使鹅,我...
    開封第一講書人閱讀 39,804評(píng)論 0 276
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎昌抠,沒想到半個(gè)月后患朱,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 46,345評(píng)論 1 318
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡炊苫,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 38,431評(píng)論 3 340
  • 正文 我和宋清朗相戀三年裁厅,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片侨艾。...
    茶點(diǎn)故事閱讀 40,561評(píng)論 1 352
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡执虹,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出唠梨,到底是詐尸還是另有隱情袋励,我是刑警寧澤,帶...
    沈念sama閱讀 36,238評(píng)論 5 350
  • 正文 年R本政府宣布,位于F島的核電站茬故,受9級(jí)特大地震影響盖灸,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜磺芭,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,928評(píng)論 3 334
  • 文/蒙蒙 一糠雨、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧徘跪,春花似錦甘邀、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 32,417評(píng)論 0 24
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至哨查,卻和暖如春逗抑,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背寒亥。 一陣腳步聲響...
    開封第一講書人閱讀 33,528評(píng)論 1 272
  • 我被黑心中介騙來泰國打工邮府, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人溉奕。 一個(gè)月前我還...
    沈念sama閱讀 48,983評(píng)論 3 376
  • 正文 我出身青樓褂傀,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國和親加勤。 傳聞我的和親對(duì)象是個(gè)殘疾皇子仙辟,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,573評(píng)論 2 359

推薦閱讀更多精彩內(nèi)容