Linux磁盤管理.一Day.18

一.什么是磁盤(df -h 查看當(dāng)前目錄使用情況)

磁盤和硬盤相比較,磁盤是帶有正負(fù)極磁性的硬盤。

二.磁盤的基本結(jié)構(gòu)

1.盤片

2.磁道:負(fù)責(zé)儲(chǔ)存數(shù)據(jù)

3.扇區(qū):扇區(qū)的計(jì)算單位是512字節(jié)/扇區(qū),數(shù)據(jù)是存儲(chǔ)在哪個(gè)磁道,哪個(gè)扇區(qū)。

4.柱面

5.磁頭:讀取磁盤磁道上面金屬塊,主要負(fù)責(zé)讀或?qū)懭霐?shù)據(jù)。

三.磁盤的預(yù)備知識(shí)

1.磁盤接口:

? ? ? ? ? ? ? ? ? IDE和Scsi已經(jīng)被淘汰了

? ? ? ? ? ? ? ? ? SATA lll 6Gbps/s? 750MB/s?

? ? ? ? ? ? ? ? ? SAS? 8Gbps/s 1000MB/s

SSD 純電子(抗摔):

? ? ? ? ? ? ? ? ? ? ? ? ? msata? 淘汰

? ? ? ? ? ? ? ? ? ? ? ? ? m.2:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 接口類型:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? SATA 幾乎所有主板都兼容,性能差

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? PCL-E 需要看主板是否兼容,性能高

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 傳輸通道:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? AHCI

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? NVMe

2. 磁盤名詞

? ? ? ? ? 容量:MB? GB? TB? PB? EB

? ? ? ? ? 轉(zhuǎn)速 :ATA3==7200轉(zhuǎn)? SAS==15000轉(zhuǎn)(需要磁盤陣列RAID)

? ? ? ? ? 尺寸:3.5英寸? 2.5英寸 1.8英寸

? ? ? ? ? IOPS input / Output? 輸入輸出? ? ?

? ? ? ? ? 順序讀寫

? ? ? ? ? 隨機(jī)讀寫?

3. 磁盤命名規(guī)則 【a-z】【aa-zz】

PS:系統(tǒng)中分區(qū)由數(shù)字編號(hào)表示,1~4留給主分區(qū)使用和擴(kuò)展分區(qū),邏輯分區(qū)從5開始,為什么分區(qū)還有限制?因?yàn)镸BR分區(qū)只能分配4個(gè)主分區(qū)。還有一種新型的分區(qū)表GPT,GPT支持分配128個(gè)主分區(qū)。(MBR與GPT之間不能相互轉(zhuǎn)換,轉(zhuǎn)換的話會(huì)導(dǎo)致數(shù)據(jù)丟失)http://www.udaxia.com/wtjd/6117.htm


1.添加磁盤

[root@neimengJay ~]# lsblk (查看磁盤信息)

2.給磁盤分區(qū)(fdisk)

第一個(gè)分區(qū)

Command (m for help): n

Partition type:

? p? primary (0 primary, 0 extended, 4 free)? :(主分區(qū))

? e? extended? ? (擴(kuò)展分區(qū))

Select (default p): p? ? (選擇創(chuàng)建主分區(qū))

Partition number (1-4, default 1): 回車? (默認(rèn)創(chuàng)建第一個(gè)主分區(qū))

First sector (2048-2147483647, default 2048): 回車(默認(rèn)扇區(qū))

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-2147483647, default 2147483647): +500M? (給第一個(gè)分區(qū)分配500MB)

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

Command (m for help): w? (w保存)

The partition table has been altered!

第二個(gè)分區(qū)

Command (m for help): n

Partition type:

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

? e? extended

Select (default p): e? (創(chuàng)建擴(kuò)展分區(qū))

Partition number (2-4, default 2):

First sector (1026048-2147483647, default 1026048):

Using default value 1026048

Last sector, +sectors or +size{K,M,G} (1026048-2147483647, default 2147483647):? 回車 (默認(rèn)將剩余空間都給擴(kuò)展分區(qū))

Using default value 2147483647

Partition 2 of type Extended and of size 1023.5 GiB is set

Command (m for help): w? (保存)

The partition table has been altered!

第三個(gè)分區(qū)

Command (m for help): n

Partition type:

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

? l? logical (numbered from 5)

Select (default p): l? ? (創(chuàng)建邏輯分區(qū))

Adding logical partition 5

First sector (1028096-2147483647, default 1028096):

Using default value 1028096

Last sector, +sectors or +size{K,M,G} (1028096-2147483647, default 2147483647): +100M (分配100MB空間)

Partition 5 of type Linux and of size 97.8 GiB is set

Command (m for help): w? (保存)

The partition table has been altered!

檢查磁盤是否是MBR分區(qū)

[root@neimengJay ~]# fdisk /dev/sdb -l | grep type

Disk label type: dos

[root@yum-test ~]# lsblk

(查看磁盤分區(qū)情況)

安裝parted,刷新內(nèi)核立即生效,無需重啟

[root@neimengJay ~]# yum install? parted -y

[root@neimengJay ~]# partprobe /dev/sdb

2.格式化磁盤

[root@neimengJay ~]# mkfs.ext4 /dev/sdb

(格式化整個(gè)磁盤)

[root@neimengJay ~]# mkfs.xfs /dev/sdb1

(格式化/dev/sdb1磁盤)

3.使用mount掛載并使用

如果需要使用該磁盤空間,需要準(zhǔn)備一個(gè)空的目錄作為掛載點(diǎn)與該設(shè)備進(jìn)行關(guān)聯(lián)。

[root@neimengJay ~]# mkdir /data

[root@neimengJay ~]# mount /dev/sdb1 /data/

(掛載sdb1到 /data)

主分區(qū)? 擴(kuò)展分區(qū)? 邏輯分區(qū)

MBR:最多可以分配4個(gè)主分區(qū),足夠使用就可以。

MBR:如果分配7個(gè)分區(qū)怎么分:

(三個(gè)主分區(qū),一個(gè)擴(kuò)展分區(qū)==四個(gè)邏輯分區(qū))

(兩個(gè)主分區(qū),一個(gè)擴(kuò)展分區(qū)==五個(gè)邏輯分區(qū))

(一個(gè)主分區(qū),一個(gè)擴(kuò)展分區(qū)==六個(gè)邏輯分區(qū))

實(shí)際使用500G

格式化==掛載到 / data:

系統(tǒng)盤:/? ———/dev/sda

數(shù)據(jù)盤:/data———/dev/sdb

如果不夠用再加一個(gè)數(shù)據(jù)盤

數(shù)據(jù)盤:/soft———/dev/sdc

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容