
文章插圖
centos7.8配置lvm并掛載1 lvm是什么LVM(Logic Volume Manager)即邏輯卷管理器,是linux系統(tǒng)用戶對硬盤分區(qū)管理的一種機(jī)制 。創(chuàng)建初衷是為了解決硬盤設(shè)備在創(chuàng)建完分區(qū)后不易修改分區(qū)的問題,LVM技術(shù)是在硬盤分區(qū)和文件系統(tǒng)之間加了一個邏輯層,他提供了一個抽象的卷組,可以把多個硬盤進(jìn)行卷組合并,這樣一來,用戶就不用擔(dān)心物理硬盤設(shè)備的底層架構(gòu)布局,可以輕松實現(xiàn)對硬盤分區(qū)的動態(tài)調(diào)整 。簡而言之就是動態(tài)添加、縮減空間,而不會影響原有數(shù)據(jù) 。
2 lvm原理及常用命令PV(Physical Volume):物理卷
VG(Volume Group):卷組
LV(Logical Volume):邏輯卷
PE(Physical Extent):基本單元
物理卷處于LVM中的最底層,可以將其理解為物理硬盤、硬盤分區(qū)或者磁盤陣列,物理卷可以理解為一個磁盤分區(qū),創(chuàng)建物理卷時指定磁盤分區(qū) 。卷組是建立在物理卷之上的,一個卷組可以包含多個物理卷,卷組創(chuàng)建之后也可以繼續(xù)向其中添加物理卷 。邏輯卷是用卷組中空閑的資源建立的,而且邏輯卷在建立后可以動態(tài)地擴(kuò)建或者縮小空間 ?;驹砣鐖D:(圖片源自網(wǎng)絡(luò))
常用命令:
功能PV管理命令VG管理命令LV管理命令scan 掃描pvscanvgscanlvscancreate 創(chuàng)建pvcreatevgcreatelvcreatedisplay 顯示pvdisplayvgdisplaylvdisplayremove 移除pvremovevgremovelvremoveextend 擴(kuò)展vgextendlvextend(lvresize)reduce 減少vgreducelvreduce(lvresize)resize改變?nèi)萘縧vresizeattribute 改變屬性 pvchangevgchangelvchange3 實操步驟本次實操是在云平臺上的磁盤上進(jìn)行l(wèi)vm的創(chuàng)建及空間分配,磁盤為/dev/vdb
1 格式化分區(qū)依次輸入:fdisk /dev/vdb
n:新建分區(qū)
p:主分區(qū)
默認(rèn)回車
默認(rèn)回車
t:調(diào)整分區(qū)類型
8e:調(diào)整為lvm類型分區(qū)
w:保存
[root@localhost ~]# fdisk /dev/vdbWelcome 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 0xd3ff2d0b.Command (m for help): nPartition type:pprimary (0 primary, 0 extended, 4 free)eextendedSelect (default p): pPartition number (1-4, default 1):First sector (2048-419430399, default 2048):Using default value 2048Last sector, +sectors or +size{K,M,G} (2048-419430399, default 419430399):Using default value 419430399Partition 1 of type Linux and of size 200 GiB is setCommand (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): wThe partition table has been altered!Calling ioctl() to re-read partition table.Syncing disks.2 創(chuàng)建pv[root@localhost ~]# pvcreate /dev/vdb1Physical volume "/dev/vdb1" successfully created.#查看pv信息[root@localhost ~]# pvsPVVGFmtAttr PSizePFree/dev/vda2centos lvm2 a--<19.00g0/dev/vdb1lvm2 ---<200.00g <200.00g3 創(chuàng)建vg[root@localhost ~]# vgcreate vg_test /dev/vdb1#第一個參數(shù)為vg名稱,第二個參數(shù)為加入vg的pvVolume group "vg_test" successfully created#查看vg信息[root@localhost ~]# vgsVG#PV #LV #SN AttrVSizeVFreecentos120 wz--n-<19.00g0vg_test100 wz--n- <200.00g <200.00g4 創(chuàng)建lv,并加入100%vg的剩余空間[root@localhost ~]# lvcreate -n lv_test -l 100%FREE vg_test#創(chuàng)建名為lv_test的邏輯卷,并分配名為vg_test的卷組內(nèi)所有分區(qū)空間的全部空閑空間Logical volume "lv_test" created.4 格式化[root@localhost ~]# mkfs -t ext4 /dev/mapper/vg_test-lv_testmke2fs 1.42.9 (28-Dec-2013)Filesystem label=OS type: LinuxBlock size=4096 (log=2)Fragment size=4096 (log=2)Stride=0 blocks, Stripe width=0 blocks13107200 inodes, 52427776 blocks2621388 blocks (5.00%) reserved for the super userFirst data block=0Maximum filesystem blocks=21999124481600 block groups32768 blocks per group, 32768 fragments per group8192 inodes per groupSuperblock backups stored on blocks:32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,4096000, 7962624, 11239424, 20480000, 23887872Allocating group tables: doneWriting inode tables: doneCreating journal (32768 blocks): doneWriting superblocks and filesystem accounting information: done#再次查看磁盤信息,就能看到這一個邏輯卷了[root@localhost ~]# fdisk -l#省略了部分輸出Disk /dev/mapper/vg_test-lv_test: 214.7 GB, 214744170496 bytes, 419422208 sectorsUnits = sectors of 1 * 512 = 512 bytesSector size (logical/physical): 512 bytes / 512 bytesI/O size (minimum/optimal): 512 bytes / 512 bytes5 掛載磁盤掛載磁盤不用磁盤名的方式,使用UUID掛載,更加可靠 。
以上關(guān)于本文的內(nèi)容,僅作參考!溫馨提示:如遇健康、疾病相關(guān)的問題,請您及時就醫(yī)或請專業(yè)人士給予相關(guān)指導(dǎo)!
「愛刨根生活網(wǎng)」www.malaban59.cn小編還為您精選了以下內(nèi)容,希望對您有所幫助:- 查看linux版本的三種常用方法 查詢linux操作系統(tǒng)版本
- linux下壓縮文件夾命令 linux zip命令詳解
- linux結(jié)束進(jìn)程快捷鍵 linux停止命令輸出
- linux搭建python環(huán)境 linux下安裝python模塊
- linux系統(tǒng)安裝步驟 yum安裝命令
- 講解linux清空某目錄內(nèi)文件 linux清空文件內(nèi)容
- linux普通用戶修改root密碼 linux修改root密碼命令
- 解壓rar包命令詳細(xì)解釋 linux如何解壓rar文件壓縮包
- linux服務(wù)器清理緩存方法 linux清緩存怎么清理
- linux聯(lián)網(wǎng)設(shè)置方法 linux怎么上網(wǎng)搜索
