国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

Linux磁盤管理之LVM的使用

2024-08-28 00:04:35
字體:
來源:轉載
供稿:網友

一、LVM介紹

在我們管理Linux磁盤的時候,通常會遇到這么一種情況。在最初規劃Linux的磁盤的時候,我們給某個分區劃分了一定量的磁盤空間,使用一段時間后,發現我們規劃的磁盤空間不足了,這個時候怎么辦?我們肯定要想辦法給擴容呀,找一塊磁盤分區,格式化,然后掛載,然后把數據拷貝到新加的磁盤上,然后把原有的磁盤卸載掉,通常我們是這樣做的。這樣一來雖然達到了擴容的目的,但是費時費力;如果第二次擴容,空間還是不夠,我們又要重復上面的步驟;如果分配的磁盤空間過大,使用了很久才發現它根本用不到那么多空間,這個時候是不是又要調整呀,聽著就感覺很繁瑣。這時候你肯定要想有沒有那種可掛載上一塊盤,我們利用某種管理手段,可以在線的調整磁盤的空間,這樣有節約了時間,也可實現彈性管理磁盤。對,lvm就有這樣的功能。

LVM(logical volume manager)邏輯卷管理,它可以彈性的管理文件系統的容量,LVM的工作原理是將一個或多個底層塊設備組織成一個邏輯設備,這個邏輯設備可以在未來新增或移除其他的分區到這個邏輯設備中,從而實現了彈性管理磁盤。

PV:物理卷(physical volume);物理卷就是指硬盤分區或從邏輯上與磁盤分區具有同樣功能的設備(如raid),是LVM的基本儲存邏輯塊,但和基本的物理存儲介質(如分區,磁盤等)比較,卻包含有與LVM相關的管理參數

VG:卷組(volume group)LVM卷組類似于非LVM系統中的物理硬盤,尤其物理卷組成,可以在卷組上創建一個或多個LVM分區(邏輯卷),LVM卷組由一個或多個物理卷組成

LV:邏輯卷(logical volume)LVM的邏輯卷類似非LVM系統中的硬盤分區,在邏輯卷之上可以創建文件系統。

LVM就是將一些零碎的磁盤分區(PV)合并成一個較大的磁盤(VG),然后在根據需要對這個較大的磁盤(VG)進行劃分成不同的大小分區(LV),這些小的分區(LV)是可以動態的擴展和縮小的,這就是LVM的邏輯卷管理過程。所謂LVM的大磁盤就是將許多PV整合成的VG,那么這個大磁盤最大可達到多少容量呢?我們知道在文件系統里面數據存儲的最小單位是塊(block),不過在LVM當中數據儲存的最小單位是PE,PE的的作用同block的作用一樣,需要注意到是LVM默認使用的PE大小是4M,而LVM的VG最多能包含65534個PE,也就是說默認LVM的VG會有4×65534M/1024M=256G,所以PE的大小決定了VG的最大容量,當然我們在創建VG的時候可指定PE大小,從而來決定VG的大小。

二、LVM實現

1)前期準備幾塊硬盤或者分區來模擬PV

[root@test-centos7-node1 ~]# lsblkNAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda   8:0  0  50G 0 disk ├─sda1  8:1  0  2G 0 part /boot├─sda2  8:2  0  2G 0 part [SWAP]└─sda3  8:3  0  46G 0 part /sdb   8:16  0  50G 0 disk sr0   11:0  1 792M 0 rom [root@test-centos7-node1 ~]# fdisk /dev/sdbWelcome 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 tableBuilding a new DOS disklabel with disk identifier 0x6180123f.Command (m for help): pDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x6180123f  Device Boot   Start     End   Blocks  Id SystemCommand (m for help): nPartition type:  p  primary (0 primary, 0 extended, 4 free)  e  extendedSelect (default p): pPartition number (1-4, default 1): First sector (2048-104857599, default 2048): Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +10GPartition 1 of type Linux and of size 10 GiB is setCommand (m for help): pDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x6180123f  Device Boot   Start     End   Blocks  Id System/dev/sdb1      2048  20973567  10485760  83 LinuxCommand (m for help): tSelected partition 1Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): nPartition type:  p  primary (1 primary, 0 extended, 3 free)  e  extendedSelect (default p): pPartition number (2-4, default 2): First sector (20973568-104857599, default 20973568): Using default value 20973568Last sector, +sectors or +size{K,M,G} (20973568-104857599, default 104857599): +10GPartition 2 of type Linux and of size 10 GiB is setCommand (m for help): tPartition number (1,2, default 2): Hex code (type L to list all codes): 8eChanged type of partition 'Linux' to 'Linux LVM'Command (m for help): nPartition type:  p  primary (2 primary, 0 extended, 2 free)  e  extendedSelect (default p): pPartition number (3,4, default 3): First sector (41945088-104857599, default 41945088): Using default value 41945088Last sector, +sectors or +size{K,M,G} (41945088-104857599, default 104857599): +10GPartition 3 of type Linux and of size 10 GiB is setCommand (m for help): tPartition number (1-3, default 3): Hex code (type L to list all codes): 8e Changed type of partition 'Linux' to 'Linux LVM'Command (m for help): pDisk /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytesDisk label type: dosDisk identifier: 0x6180123f  Device Boot   Start     End   Blocks  Id System/dev/sdb1      2048  20973567  10485760  8e Linux LVM/dev/sdb2    20973568  41945087  10485760  8e Linux LVM/dev/sdb3    41945088  62916607  10485760  8e Linux LVMCommand (m for help): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.[root@test-centos7-node1 ~]# lsblkNAME  MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda   8:0  0  50G 0 disk ├─sda1  8:1  0  2G 0 part /boot├─sda2  8:2  0  2G 0 part [SWAP]└─sda3  8:3  0  46G 0 part /sdb   8:16  0  50G 0 disk ├─sdb1  8:17  0  10G 0 part ├─sdb2  8:18  0  10G 0 part └─sdb3  8:19  0  10G 0 part sr0   11:0  1 792M 0 rom [root@test-centos7-node1 ~]#
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 通海县| 肇东市| 衡阳市| 五莲县| 瑞安市| 田东县| 西林县| 乌兰察布市| 泽州县| 会东县| 宿松县| 南涧| 托克托县| 古丈县| 汉中市| 麻城市| 扶绥县| 定边县| 哈尔滨市| 乌拉特后旗| 如皋市| 苏尼特左旗| 花莲县| 宜州市| 临漳县| 三门峡市| 潼南县| 北川| 宣武区| 昂仁县| 肃宁县| 阳信县| 渑池县| 永和县| 广元市| 涡阳县| 奇台县| 南康市| 尉犁县| 瓮安县| 穆棱市|