Linux磁盤管理

Linux磁盤管理

什么是磁盤

磁盤是一種計(jì)算機(jī)的外部存儲器設(shè)備,由一個或多個覆蓋有磁性材料的鋁制或玻璃制的碟片組成,用來存儲用戶的信息,這種信息可以反復(fù)地被讀取和改寫。絕大多數(shù)磁盤被永久封存在一個密封的盒子里

1、磁道:磁盤的每個盤面被劃分為許多同心圓,這些同心圓的軌道叫做磁道。 2、扇區(qū):一個盤面劃分為若干個內(nèi)角相同的扇形,這樣盤面上的每個磁道就被分為若干段圓弧,每段圓弧叫做一個扇區(qū)。每個扇區(qū)中的數(shù)據(jù)作為一個單元同時被讀入或?qū)懭搿C恳粋€扇區(qū)是512字節(jié),其中有64個字節(jié)存儲的是分區(qū)表,一條分區(qū)信息占16個字節(jié)。 3、柱面:每一個盤片同一大小的同心圓可以看成連在一起的柱面,磁盤在分區(qū)的時候最小單位是柱面,每一個盤片的上下面都可以讀取數(shù)據(jù),每一個磁頭,不可以跨盤面讀取數(shù)據(jù)。

RAID

磁盤陣列(Redundant Arrays of Independent Disks,RAID)。磁盤陣列是由很多塊獨(dú)立的磁盤,組合成一個容量巨大的磁盤組,利用個別磁盤提供數(shù)據(jù)所產(chǎn)生加成效果提升整個磁盤系統(tǒng)效能。利用這項(xiàng)技術(shù),將數(shù)據(jù)切割成許多區(qū)段,分別存放在各個硬盤上。

以下是幾種RAID模式:

  • RAID0

    RAID0將數(shù)據(jù)分散在n個磁盤中,以獨(dú)立的方式并行讀取n個磁盤的數(shù)據(jù),理論上,一個由n塊磁盤組成的RAID0是單個磁盤性能的n倍。

  • RAID1

    將數(shù)據(jù)分別寫到兩組磁盤中,分別為工作磁盤和鏡像磁盤,相當(dāng)于做了一次冗余,安全性高,但是成本也高。

  • RAID10

    RAID10兼?zhèn)淞薘AID1和RAID0的有優(yōu)點(diǎn)。首先基于RAID1模式將磁盤分為2份,當(dāng)要寫入數(shù)據(jù)的時候,將所有的數(shù)據(jù)在兩份磁盤上同時寫入,相當(dāng)于寫了雙份數(shù)據(jù),起到了數(shù)據(jù)保障的作用。且在每一份磁盤上又會基于RAID0技術(shù)講數(shù)據(jù)分為N份并發(fā)的讀寫,這樣也保障了數(shù)據(jù)的效率。

LVM

Linux LVM是由Heinz Mauelshagen開發(fā)的,于1998年發(fā)布到了Linux社區(qū)。它允許你在Linux 上用簡單的命令行命令管理一個完整的邏輯卷管理環(huán)境。

Linux LVM有兩個可用的版本。

  • LVM1:最初的LVM包于1998年發(fā)布,只能用于Linux內(nèi)核2.4版本 。它僅提供了基本的邏

輯卷管理功能。

  • LVM2:LVM的更新版本,可用于Linux內(nèi)核2.6版本。它在標(biāo)準(zhǔn)的LVM1功能外提供了額

外的功能。 大部分采用2.6或更高內(nèi)核版本的現(xiàn)代Linux發(fā)行版都提供對LVM2的支持。除了標(biāo)準(zhǔn)的邏輯卷管理功能外,LVM2還提供了另外一些好用的功能。

磁盤分區(qū)

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="linux" cid="n30" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-color: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; caret-color: rgb(184, 191, 198); color: rgb(184, 191, 198); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: initial initial; background-repeat: initial initial;">查看當(dāng)前磁盤的一個分區(qū)狀況
fdisk -l
fdisk [選項(xiàng)] <磁盤> #更改分區(qū)表
fdisk [選項(xiàng)] -l [<磁盤>] #列出分區(qū)表

讓硬盤進(jìn)入分區(qū)模式
fdisk /dev/sda

將分區(qū)信息讀到內(nèi)核中
partprobe

將 /dev下的 sda5 磁盤格式化為 ext2 的格式類型
mkfs.ext2 /dev/sda5

將 /dev/sda5 掛載到 test 中
mount /dev/sda5/test

卸載已經(jīng)掛載的 /dev/sda5 磁盤也就是作為掛載接口的test目錄
umount /dev/sda5或者umount /test

查看磁盤的信息(推薦)
df -h

查看對應(yīng)分區(qū)的UUID(編號)
blkid</pre>

格式化常用命令

用法:

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n33" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-color: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; caret-color: rgb(184, 191, 198); color: rgb(184, 191, 198); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: initial initial; background-repeat: initial initial;"> mkfs [選項(xiàng)] [-t <類型>] [文件系統(tǒng)選項(xiàng)] <設(shè)備> [<大小>]</pre>

創(chuàng)建一個Linux 文件系統(tǒng)。

選項(xiàng) 功能
-t 文件系統(tǒng)類型;若不指定,將使用 ext2
-V 解釋正在進(jìn)行的操作;
-h 幫助文檔
-v 展示版本信息

掛載

查看當(dāng)前磁盤的詳細(xì)掛載信息 mount命令

用法:

<pre class="md-fences md-end-block ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n54" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: Monaco, Consolas, "Andale Mono", "DejaVu Sans Mono", monospace; margin-top: 0px; margin-bottom: 20px; font-size: 0.9rem; display: block; break-inside: avoid; text-align: left; white-space: normal; background-color: rgb(51, 51, 51); position: relative !important; padding: 10px 10px 10px 30px; width: inherit; caret-color: rgb(184, 191, 198); color: rgb(184, 191, 198); font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; background-position: initial initial; background-repeat: initial initial;"> mount [-lhV]
mount -a [選項(xiàng)]
mount [選項(xiàng)] [--source] <源> | [--target] <目錄>
mount [選項(xiàng)] <源> <目錄>
mount <操作> <掛載點(diǎn)> [<目標(biāo)>]</pre>

因選項(xiàng)過多,這里不做詳解,可以在命令行輸入 mouunt -h 獲

參考:[Slash Young CSDN]

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

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