Day19-磁盤管理

磁盤的基本概念


每個(gè)硬盤中心都是一摞高速運(yùn)轉(zhuǎn)的圓盤,在圓盤上附著的一圈金屬顆粒,每個(gè)金屬顆粒都有自己的磁化程度,用于儲存0和1

當(dāng)記錄數(shù)據(jù)時(shí),硬盤的磁頭開始通電,形成強(qiáng)磁場,數(shù)據(jù)在磁場的作用下轉(zhuǎn)變成電流,使顆粒磁化,從而將信息記錄在圓盤上。

由海量顆粒組成的信息,就是我們存在硬盤里的數(shù)據(jù)。

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

  • 盤片:硬盤一般有一個(gè)或多個(gè)盤片,每個(gè)盤片可以有兩面,即第一個(gè)盤片的正面為0面,反面為1面然后依次類推
  • 磁道:每個(gè)盤片的盤面在出廠的時(shí)候被劃分出了多個(gè)同心圓環(huán),數(shù)據(jù)就存儲在這樣的同心圓環(huán)上面,我們將這樣的圓環(huán)稱為磁道(Track),每個(gè)盤面可以劃分多個(gè)磁道。但肉業(yè)不可見
  • 扇區(qū):在硬盤出廠時(shí)會對磁盤進(jìn)行一次低格,其實(shí)就是再每個(gè)磁道劃分為若干個(gè)弧段,每個(gè)弧段就是一個(gè)扇區(qū) (Sector)。扇區(qū)是硬盤上存儲的物理單位,現(xiàn)在每個(gè)扇區(qū)可存儲512字節(jié)數(shù)據(jù)已經(jīng)成了業(yè)界的約定。
  • 柱面:柱面實(shí)際上就是我們抽象出來的一個(gè)邏輯概念,簡單來說就是處于同一個(gè)垂直區(qū)域的磁道稱為 柱面 ,即各盤面上面相同位置磁道的集合。這樣數(shù)據(jù)如果存儲到相同半徑磁道上的同一扇區(qū),這樣可以實(shí)現(xiàn)并行讀取,主要是減少磁頭尋道時(shí)間。
  • 磁頭:讀取磁盤磁道上面金屬塊,主要負(fù)責(zé)讀或?qū)懭霐?shù)據(jù)。

磁盤的預(yù)備知識

  • 磁盤的接口
    (1)IDE out
    (2)Scsi out
    (3)SATA III 6Gbps/s 750MB/s 1T 400 100MB/s
    (4)SAS 8Gbps/s 1000MB/s 1T 4500
    (5)SSD 純電子 抗摔
    兩種接口:(1)msata out (2)m.2
    接口類型 :(1)SATA 幾乎所有主板都兼容, 便宜 性能差 ,(2)PCI-E 需要看主板是否兼容, 貴, 性能高
    傳輸通道 :(1)PCI-E AHCI ,(2)NVMe
磁盤接口 特性
IDE out
Scsi out
SATA III 6Gbps/s 750MB/s 1T 400 100MB/s
SAS 8Gbps/s 1000MB/s 1T 4500
SSD 純電子 抗摔

磁盤的名詞

  • 容量 MB GB TB PB EB .............
  • 轉(zhuǎn)速 SATA3 ==7200 SAS 15000 (非常之高) 磁盤陣列RAID
  • 尺寸 3.5 2.5 1.8
  • IOPS Input/Output 輸入輸出
    (1)順序讀寫
    (2)隨機(jī)讀寫
設(shè)備類型: 硬盤-內(nèi)置
容量: 73G/146G/300G
尺寸: 2.5英寸/3.5英寸
接口: SAS 6Gb/s
轉(zhuǎn)速: 7200轉(zhuǎn) /10000轉(zhuǎn)/15000轉(zhuǎn)每分

磁盤的命名規(guī)則[a-z][aa-zz]


http://www.udaxia.com/wtjd/6117.html

磁盤的基本分區(qū)

1,添加磁盤

[root@oldboy ~]  ll /dev/sd* 
brw-rw----. 1 root disk 8,  0 Aug 19 11:29 /dev/sda
brw-rw----. 1 root disk 8,  1 Aug 19 11:29 /dev/sda1 
brw-rw----. 1 root disk 8,  2 Aug 19 11:29 /dev/sda2 
brw-rw----. 1 root disk 8,  3 Aug 19 11:29 /dev/sda3 
brw-rw----. 1 root disk 8, 16 Aug 19 11:29 /dev/sdb 
brw-rw----. 1 root disk 8, 32 Aug 19 11:29 /dev/sdc

[root@oldboy ~]  lsblk 
NAME   MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT 
sda      8:0    0   40G  0 disk 
├─sda1   8:1    0    1G  0 part /boot 
├─sda2   8:2    0    1G  0 part [SWAP] 
└─sda3   8:3    0   38G  0 part / 
sdb      8:16   0    1T  0 disk 
sdc      8:32   0    4T  0 disk 
sr0     11:0    1  4.3G  0 rom  

2,給磁盤分區(qū)

[root@oldboyfang ~]$ fdisk /dev/sdc
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 0x71756a88.

Command (m for help): m                       #輸入m列出常用命令
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   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)

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-41943039, default 2048):                 #默認(rèn)扇區(qū)
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-41943039, default 41943039): +100M                                                                                    
Partition 1 of type Linux and of size 100 MiB is set

Command (m for help): n              #新建分區(qū)
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 (206848-41943039, default 206848): 
Using default value 206848
Last sector, +sectors or +size{K,M,G} (206848-41943039, default 41943039): 
Using default value 41943039
Partition 2 of type Extended and of size 19.9 GiB is set

Command (m for help): n                     #新建分區(qū)
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 (208896-41943039, default 208896): 
Using default value 208896
Partition 5 of type Linux and of size 19.9 GiB is set
Command (m for help): p             #查看分區(qū)創(chuàng)建
Disk /dev/sdc: 21.5 GB, 21474836480 bytes, 41943040 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: 0x71756a88

   Device Boot      Start         End      Blocks   Id  System
/dev/sdc1            2048      206847      102400   83  Linux
/dev/sdc2          206848    41943039    20868096    5  Extended
/dev/sdc5          208896    41943039    20867072   83  Linux

Command (m for help): w                     #保存分區(qū)
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
The kernel still uses the old table. The new table will be used at
the next reboot or after you run partprobe(8) or kpartx(8)
Syncing disks.
[root@oldboyfang ~]$ fdisk /dev/sdc -l |grep type      #檢查磁盤是否是MBRf分區(qū)方式
Disk label type: dos
[root@oldboyfang ~]$ partprobe /dev/sdc                     #刷新內(nèi)核,立即生效,無需重啟

3,使用mkfs對磁盤進(jìn)行格式化

[root@oldboyfang ~]$ mkfs -t xfs /dev/sdb6                    #使用mkfs對磁盤進(jìn)行格式化

4,掛載目錄

[root@oldboyfang ~]$ mount /dev/sdc data_6                 #掛載目錄

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

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

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