建立LVM磁區
LVM(Logic Volume Manager)邏輯磁區管理器
是Linux核心提供的功能,用於在硬碟分割區建立邏輯磁區,方便系統管理
優點
- File System可以跨多個磁碟,因此大小不受物理磁碟限制
- 可以在系統運行時,動態擴展File System大小
- 可以新增磁碟至LVM儲存庫
缺點
其中一個磁碟損壞,整個volume都受到影響
基本名詞
- PP (Physical Partition)
物理分區
實體分區,如硬碟、硬碟分割槽或邏輯上與磁碟分割槽具有同樣功能的裝置(如:RAID分區)
- PE (Physical Extends)
物理擴展單元
PV的基本單元,是LVM中可以被定址的最小儲存單元
- PV (Physical Volume)
物理卷
PP的LVM抽象,一般一個PP對應一個PV,組成VG的基本單元
- VG (Volume Group)
卷組
數個PV組成的儲存池
- LV (Logic Volume)
邏輯卷
由VG分割出來的空間,可自由增加/減少
檔案系統建立於LV之上
架構圖
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
建立LVM
#disk partition
#檢視資訊
#PV操作指令
#VG操作指令
#LV操作指令
#掛載lv
修改/etc/fstab 可以讓系統在開機時自動掛載
例:/dev/mapper/testvg / xfs default 0 0 (各項參數意義)
- 要掛載的磁區,也可以用UUID
- 要掛載的位置
- 檔案系統格式
- 掛載參數
- dump決定是否要備份,0不用、1每日備份、2隔日
- fsck決定不正常開機後檢查檔案系統的順序,0不檢查、1根目錄、2其他磁區
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
ext檔案系統
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
線上增加LV空間大小
增加空間可以線上作業,減少需要先umount
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
縮小LV空間
結束掛載。先設定檔案系統縮小至多少,再設定LV大小
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
這裡resize2fs跟lvresize會設一樣的大小是因為LV內僅有一個file system。若有一個LV中有多個檔案系統,則lvresize要依據檔案系統減少的大小去設定LV的大小
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
xfs檔案系統
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
線上增加LV空間大小
步驟與ext檔案系統相同
Image Not Showing
Possible Reasons
- The image file may be corrupted
- The server hosting the image is unavailable
- The image path is incorrect
- The image format is not supported
Learn More →
補充:從增加磁區開始至LV擴大
- 改變磁區大小
- 將partition加入pv
- 將LV擴大
參考連結
LVM基礎建立步驟(英文)
LVM基礎建立步驟(中文)
LVM基礎知識
LVM簡易操作
LVM簡易操作2
parted基礎操作
線上LV擴增/縮小
shrinking ext file system
resize2fs、xfs_growfs差別