Files
Obsidian-Main/05. 資料收集/Linux/lvm.md

100 lines
3.2 KiB
Markdown
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# PV(Physical Volume)
PV(Physical Volume) 就是LVM的磁碟分區。
## 建立PV
建立PV的命令如下
```bash
pvcreate /dev/sdb /dev/sdc /dev/sdd
```
```result
`Physical volume "/dev/sdb" successfully created`
`Physical volume "/dev/sdc" successfully created`
`Physical volume "/dev/sdd" successfully created`
```
這樣我們就建立了3個PV。
## 查看 PV
使用 `pvdisplay` 和 `pvs` 來檢視你建立的 PV。
`pvs` 輸出會比較簡短,例:
```
sudo pvs
```
```result
PV VG Fmt Attr PSize PFree
/dev/sda3 ubuntu-vg lvm2 a-- 57.62g 28.81g
/dev/sdb1 vg1 lvm2 a-- <2.73t 0
/dev/sdc1 vg1 lvm2 a-- <2.73t 0
```
 `pvdisplay` 就比較詳細:
```
sudo pvdisplay 
```
```result
--- Physical volume ---
PV Name /dev/sdb1
VG Name vg1
PV Size <2.73 TiB / not usable 3.44 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 715396
Free PE 0
Allocated PE 715396
PV UUID cWvfBE-Vbyp-l09E-QH0O-ZZoC-AdSG-t1J7TT
--- Physical volume ---
PV Name /dev/sdc1
VG Name vg1
PV Size <2.73 TiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 715396
Free PE 0
Allocated PE 715396
PV UUID eDdYr4-HSZC-wRBa-feGx-SHp1-Wfye-m0e1PY
--- Physical volume ---
PV Name /dev/sda3
VG Name ubuntu-vg
PV Size 57.62 GiB / not usable 2.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 14751
Free PE 7376
Allocated PE 7375
PV UUID zUlIaB-1Uof-3eF6-z5I7-OnqJ-UYDk-gThxJQ
```
# VG(Volume Group)
VG(Volume Group) 由 PV 組成你可以自由的排列組合。我們拿剛剛建立的3個PV把它組成一個VG。
## 建立 VG
```
vgcreate vg1 /dev/sdb /dev/sdc /dev/sdd
```
`vg1` 是你的VG 名字,可以自由更改。
後面的`/dev/sdb``/dev/sdc``/dev/sdd` 就是你剛剛建立的 PV。
## 查看 VG
使用 `vgdisplay` 和 `vgs` 來檢視你建立的 PV。
# LV(Logical Volume)
LV(Logical Volume) 可以對應到實際的硬碟,它才是可以被 mount 到 directory 的東西。LV 可以只使用 VG 某一部份的也就是說一個VG可以切出很多LV。
## 建立 LV
- [What is LVM2 in Linux ?. LVM | by The_CodeConductor | Medium](https://medium.com/@The_CodeConductor/what-is-lvm2-in-linux-3d28b479e250)
- [建立LVM磁區 - HackMD](https://hackmd.io/@yzai/BJUIhnAb9)
- [LVM — pv, vg, lv. 动态的分配档案系统的空间,方便管理者随时调整空间,达到妥善使用硬件ㄒㄧㄠ | by Kiwi lee | Medium --- LVM — pv, vg, lv. 動態的分配檔案系統的空間,方便管理者隨時調整空間,達到妥善使用硬體ㄒㄧㄠ | by Kiwi lee | Medium](https://sean22492249.medium.com/lvm-pv-vg-lv-1777a84a3ce8)
- [天黑的時候,星星就會出現!: Linux LVM (建立、擴充、移除LVM磁區) 操作筆記](https://sc8log.blogspot.com/2017/03/linux-lvm-lvm.html)
- [Maxsolar's Linux Blog: LVM2學習筆記](https://maxubuntu.blogspot.com/2010/05/lvm2.html)