CentOS7中怎么动态扩容LVM
发表于:2024-09-22 作者:千家信息网编辑
千家信息网最后更新 2024年09月22日,这期内容当中小编将会给大家带来有关CentOS7中怎么动态扩容LVM,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。问题CentOS7上面的磁盘空间有点紧张,需要扩容
千家信息网最后更新 2024年09月22日CentOS7中怎么动态扩容LVM
这期内容当中小编将会给大家带来有关CentOS7中怎么动态扩容LVM,文章内容丰富且以专业的角度为大家分析和叙述,阅读完这篇文章希望大家可以有所收获。
问题
CentOS7上面的磁盘空间有点紧张,需要扩容。
解决
查询当前磁盘状态
[root@xxx ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTfd0 2:0 1 4K 0 disk sda 8:0 0 200G 0 disk ├─sda1 8:1 0 500M 0 part /boot└─sda2 8:2 0 15.5G 0 part ├─centos-swap 253:0 0 1.6G 0 lvm [SWAP] └─centos-root 253:1 0 13.9G 0 lvm /sr0 11:0 1 1024M 0 rom loop0 7:0 0 4.3G 0 loop /mnt/iso
查询当前文件系统状态
[root@xxx ~]# df -h文件系统 容量 已用 可用 已用% 挂载点/dev/mapper/centos-root 14G 14G 20K 100% /devtmpfs 3.8G 0 3.8G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 442M 3.4G 12% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 295M 202M 60% /boottmpfs 782M 12K 782M 1% /run/user/42/dev/loop0 4.3G 4.3G 0 100% /mnt/isotmpfs 782M 0 782M 0% /run/user/0
查看当前磁盘分区情况
[root@xxx ~]# gdisk /dev/sdaGPT fdisk (gdisk) version 0.8.10Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present***************************************************************Found invalid GPT and valid MBR; converting MBR to GPT formatin memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit bytyping 'q' if you don't want to convert your MBR partitionsto GPT format!***************************************************************Command (? for help): pDisk /dev/sda: 419430400 sectors, 200.0 GiBLogical sector size: 512 bytesDisk identifier (GUID): FE64D670-2841-445E-974F-12A258105C57Partition table holds up to 128 entriesFirst usable sector is 34, last usable sector is 419430366Partitions will be aligned on 2048-sector boundariesTotal free space is 385877949 sectors (184.0 GiB)Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB 8300 Linux filesystem 2 1026048 33554431 15.5 GiB 8E00 Linux LVM
lvm扩容
创建8e
[root@xxx ~]# gdisk /dev/sdaGPT fdisk (gdisk) version 0.8.10Partition table scan: MBR: MBR only BSD: not present APM: not present GPT: not present***************************************************************Found invalid GPT and valid MBR; converting MBR to GPT formatin memory. THIS OPERATION IS POTENTIALLY DESTRUCTIVE! Exit bytyping 'q' if you don't want to convert your MBR partitionsto GPT format!***************************************************************Command (? for help): nPartition number (3-128, default 3): First sector (34-419430366, default = 33554432) or {+-}size{KMGTP}: Last sector (33554432-419430366, default = 419430366) or {+-}size{KMGTP}: +84GCurrent type is 'Linux filesystem'Hex code or GUID (L to show codes, Enter = 8300): L0700 Microsoft basic data 0c01 Microsoft reserved 2700 Windows RE 3000 ONIE boot 3001 ONIE config 4100 PowerPC PReP boot 4200 Windows LDM data 4201 Windows LDM metadata 7501 IBM GPFS 7f00 ChromeOS kernel 7f01 ChromeOS root 7f02 ChromeOS reserved 8200 Linux swap 8300 Linux filesystem 8301 Linux reserved 8302 Linux /home 8400 Intel Rapid Start 8e00 Linux LVM a500 FreeBSD disklabel a501 FreeBSD boot a502 FreeBSD swap a503 FreeBSD UFS a504 FreeBSD ZFS a505 FreeBSD Vinum/RAID a580 Midnight BSD data a581 Midnight BSD boot a582 Midnight BSD swap a583 Midnight BSD UFS a584 Midnight BSD ZFS a585 Midnight BSD Vinum a800 Apple UFS a901 NetBSD swap a902 NetBSD FFS a903 NetBSD LFS a904 NetBSD concatenated a905 NetBSD encrypted a906 NetBSD RAID ab00 Apple boot af00 Apple HFS/HFS+ af01 Apple RAID af02 Apple RAID offline af03 Apple label af04 AppleTV recovery af05 Apple Core Storage be00 Solaris boot bf00 Solaris root bf01 Solaris /usr & Mac Z bf02 Solaris swap bf03 Solaris backup bf04 Solaris /var bf05 Solaris /home bf06 Solaris alternate se bf07 Solaris Reserved 1 bf08 Solaris Reserved 2 bf09 Solaris Reserved 3 bf0a Solaris Reserved 4 bf0b Solaris Reserved 5 c001 HP-UX data c002 HP-UX service ea00 Freedesktop $BOOT eb00 Haiku BFS ed00 Sony system partitio ed01 Lenovo system partitPress thekey to see more codes: 8e00ef00 EFI System ef01 MBR partition scheme ef02 BIOS boot partition fb00 VMWare VMFS fb01 VMWare reserved fc00 VMWare kcore crash pfd00 Linux RAID Hex code or GUID (L to show codes, Enter = 8300): 8e00Changed type of partition to 'Linux LVM'Command (? for help): pDisk /dev/sda: 419430400 sectors, 200.0 GiBLogical sector size: 512 bytesDisk identifier (GUID): F8A75D30-20AF-412A-A7CD-F66D4A57D232Partition table holds up to 128 entriesFirst usable sector is 34, last usable sector is 419430366Partitions will be aligned on 2048-sector boundariesTotal free space is 209717181 sectors (100.0 GiB)Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB 8300 Linux filesystem 2 1026048 33554431 15.5 GiB 8E00 Linux LVM 3 33554432 209715199 84.0 GiB 8E00 Linux LVMCommand (? for help): wFinal checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTINGPARTITIONS!!Do you want to proceed? (Y/N): yOK; writing new GUID partition table (GPT) to /dev/sda.Warning: The kernel is still using the old partition table.The new table will be used at the next reboot.The operation has completed successfully.
这里需要注意的地方就是,扩容了84G,并且使用8e00。
更新8e
[root@xxx ~]# partprobe -s/dev/sda: gpt partitions 1 2 3[root@xxx ~]# lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTfd0 2:0 1 4K 0 disk sda 8:0 0 200G 0 disk ├─sda1 8:1 0 500M 0 part /boot├─sda2 8:2 0 15.5G 0 part │ ├─centos-swap 253:0 0 1.6G 0 lvm [SWAP]│ └─centos-root 253:1 0 13.9G 0 lvm /└─sda3 8:3 0 84G 0 part sr0 11:0 1 1024M 0 rom loop0 7:0 0 4.3G 0 loop /mnt/iso
验证8e
[root@xxx ~]# gdisk -l /dev/sdaGPT fdisk (gdisk) version 0.8.10Partition table scan: MBR: protective BSD: not present APM: not present GPT: presentFound valid GPT with protective MBR; using GPT.Disk /dev/sda: 419430400 sectors, 200.0 GiBLogical sector size: 512 bytesDisk identifier (GUID): F8A75D30-20AF-412A-A7CD-F66D4A57D232Partition table holds up to 128 entriesFirst usable sector is 34, last usable sector is 419430366Partitions will be aligned on 2048-sector boundariesTotal free space is 209717181 sectors (100.0 GiB)Number Start (sector) End (sector) Size Code Name 1 2048 1026047 500.0 MiB 8300 Linux filesystem 2 1026048 33554431 15.5 GiB 8E00 Linux LVM 3 33554432 209715199 84.0 GiB 8E00 Linux LVM
PV阶段
现有PV
[root@xxx ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size 15.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 3970 Free PE 0 Allocated PE 3970 PV UUID S13vMN-W0wQ-HCae-fPKa-bClZ-RzW0-39xc9C
现在PV的大小是15G。
创建PV
[root@xxx ~]# pvcreate /dev/sda3 Physical volume "/dev/sda3" successfully created.
验证PV
[root@xxx ~]# pvdisplay --- Physical volume --- PV Name /dev/sda2 VG Name centos PV Size 15.51 GiB / not usable 3.00 MiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 3970 Free PE 0 Allocated PE 3970 PV UUID S13vMN-W0wQ-HCae-fPKa-bClZ-RzW0-39xc9C "/dev/sda3" is a new physical volume of "84.00 GiB" --- NEW Physical volume --- PV Name /dev/sda3 VG Name PV Size 84.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID Ssb5Y6-gD5q-heAE-sil9-oIU3-kdX8-B0pqLS
VG阶段
现有VG
[root@xxx ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 3 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 1 Act PV 1 VG Size <15.51 GiB PE Size 4.00 MiB Total PE 3970 Alloc PE / Size 3970 / <15.51 GiB Free PE / Size 0 / 0 VG UUID F3IvIs-uz92-m9d6-XYYL-0QvN-xqs8-qxD9fC
VG也是15G。
扩容VG
[root@xxx ~]# vgextend centos /dev/sda3 Volume group "centos" successfully extended
在这个阶段遇到Couldn't create temporary archive name.
问题,只需要清理一部分无用文件腾出一点点磁盘空间即可。
验证VG
[root@xxx ~]# vgdisplay --- Volume group --- VG Name centos System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 2 Open LV 2 Max PV 0 Cur PV 2 Act PV 2 VG Size 99.50 GiB PE Size 4.00 MiB Total PE 25473 Alloc PE / Size 3970 / <15.51 GiB Free PE / Size 21503 / <84.00 GiB VG UUID F3IvIs-uz92-m9d6-XYYL-0QvN-xqs8-qxD9fC
Free部分已经不是0了。
LV阶段
现有LV
[root@xxx ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID c2sXrl-GC3c-nXbi-lED4-MqXx-5FPx-872laM LV Write Access read/write LV Creation host, time tamtest.hngytobacco.com, 2017-06-26 12:02:56 +0800 LV Status available # open 2 LV Size 1.60 GiB Current LE 410 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID r2qZe6-X3zx-D7te-U0t0-iJDF-VyWf-xl5by8 LV Write Access read/write LV Creation host, time tamtest.hngytobacco.com, 2017-06-26 12:02:57 +0800 LV Status available # open 1 LV Size <13.91 GiB Current LE 3560 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
这里主要扩容这个LV:/dev/centos/root。
扩容LV
[root@xxx ~]# lvresize -L +83.99GB /dev/centos/root Rounding size to boundary between physical extents: 83.99 GiB. Size of logical volume centos/root changed from <13.91 GiB (3560 extents) to <97.90 GiB (25062 extents). Logical volume centos/root successfully resized
验证LV
[root@xxx ~]# lvdisplay --- Logical volume --- LV Path /dev/centos/swap LV Name swap VG Name centos LV UUID c2sXrl-GC3c-nXbi-lED4-MqXx-5FPx-872laM LV Write Access read/write LV Creation host, time tamtest.hngytobacco.com, 2017-06-26 12:02:56 +0800 LV Status available # open 2 LV Size 1.60 GiB Current LE 410 Segments 1 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:0 --- Logical volume --- LV Path /dev/centos/root LV Name root VG Name centos LV UUID r2qZe6-X3zx-D7te-U0t0-iJDF-VyWf-xl5by8 LV Write Access read/write LV Creation host, time tamtest.hngytobacco.com, 2017-06-26 12:02:57 +0800 LV Status available # open 1 LV Size <97.90 GiB Current LE 25062 Segments 2 Allocation inherit Read ahead sectors auto - currently set to 8192 Block device 253:1
更新扩容
[root@xxx ~]# xfs_growfs /meta-data=/dev/mapper/centos-root isize=256 agcount=4, agsize=911360 blks = sectsz=512 attr=2, projid32bit=1 = crc=0 finobt=0 spinodes=0data = bsize=4096 blocks=3645440, imaxpct=25 = sunit=0 swidth=0 blksnaming =version 2 bsize=4096 ascii-ci=0 ftype=0log =internal bsize=4096 blocks=2560, version=2 = sectsz=512 sunit=0 blks, lazy-count=1realtime =none extsz=4096 blocks=0, rtextents=0data blocks changed from 3645440 to 25663488
验证扩容
[root@xxx ~]# df -lh文件系统 容量 已用 可用 已用% 挂载点/dev/mapper/centos-root 98G 14G 84G 15% /devtmpfs 3.8G 0 3.8G 0% /devtmpfs 3.9G 0 3.9G 0% /dev/shmtmpfs 3.9G 442M 3.4G 12% /runtmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup/dev/sda1 497M 295M 202M 60% /boottmpfs 782M 12K 782M 1% /run/user/42/dev/loop0 4.3G 4.3G 0 100% /mnt/isotmpfs 782M 0 782M 0% /run/user/0
总结
主要就是创建8e分区,然后用pvcreate命令创建PV,再使用vgextend命令来扩容VG,再使用lvresize命令扩容LV,最后使用xfs_growfs命令更新扩容。
上述就是小编为大家分享的CentOS7中怎么动态扩容LVM了,如果刚好有类似的疑惑,不妨参照上述分析进行理解。如果想知道更多相关知识,欢迎关注行业资讯频道。
验证
命令
文件
磁盘
阶段
就是
系统
更新
动态
内容
容量
状态
空间
问题
分析
查询
专业
中小
内容丰富
地方
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
访问服务器端文件
网络安全公司资质审批
东莞物联网软件开发费用
青羊区网络安全社区
csgo国服从服务器
设置dhcp服务器
研究所网络安全工程师
国产软件网络安全基金
杭州戴尔服务器总代理
戴尔媒体服务器
数据库表导出命令
如何准备软件开发工作内容
java 数据库公共类
维护边缘网络安全吗
化学领域有几个数据库的特点
计算机网络安全的研究和探讨
淄博ios软件开发哪家做的好
软件开发有事物是指什么
计算机网络技术容易找工作吗
数据库对信息管理的重要性
上海5g服务器机柜厂家
石林正规软件开发市场价
学校网络安全培训计刘
博山在线考试软件开发报价
互联网科技公司画册
支持微软服务器操作系统的服务器
注重互联网金融网络安全保障
怀化口碑好的软件开发公司
社区网络安全小视频怎么拍
十一网络技术有限公司