Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of lvm Volume extension in Linux system

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Linux system lvm volume expansion example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian with you to understand.

LVM is the abbreviation of logical disk Volume Management (Logical Volume Manager). It is a mechanism for managing disk partitions in Linux environment. LVM is a logical layer built on hard disks and partitions to improve the flexibility of disk partition management. LVM is a logical layer added between the disk partition and the file system to shield the underlying disk partition layout for the file system, to provide an abstract volume, and to establish the file system on the volume. Physical volumes (physical volume) physical volumes refer to hard disk partitions or devices that logically have the same function as disk partitions (such as RAID), which is the basic storage logic block of LVM, but compared with basic physical storage media (such as partitions, disks, etc.), it contains management parameters related to LVM.

Experimental environment:

System: Centos7 installed using lvm volume partition, the oracle database is deployed in / home/oracle partition, later found that the disk space is not enough, add a new hard disk to expand the partition / home/oracle capacity.

View system space using [root@localhost ~] # lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 20G 0 disk ├─ sda1 8:1 0200M 0 part / boot └─ sda2 8:2 019G 0 part boot centos-root 253 010G 0 lvm / ├─ centos-swap 253 lvm 1 04G 0 lvm [SWAP] └─ centos- Home 253:2 0 5G 0 lvm / homesr0 11:0 1 4.2G 0 rom

This shows that it is partitioned in lvm mode. If it is not a lvm partition, it cannot be expanded in this way. The directory where oracle resides is 5G in size. / dev/sdb is a newly added hard disk

Add a hard drive and change the partition to lvm format [root@localhost ~] # fdisk / dev/sdb Welcome to fdisk (util-linux 2.23.2). The changes remain in memory until you decide to write them to disk. Think twice before using the write command. Device does not contain a recognized partition table uses the disk identifier 0xd10b295e to create a new DOS disk label. Command (enter m for help): nPartition type: P primary (0 primary, 0 extended, 4 free) e extendedSelect (default p): P partition number (1-4, default 1): start sector (2048-20971519, default is 2048): the default value 2048Last sector will be used, + sector or + size {KMagne MMagg} (2048-20971519, default is 20971519): + 5G partition 1 has been set to Linux type Set the size to 5 GiB command (enter m for help): t selected partition 1Hex code (enter L to list all codes): 8e changed the type of partition "Linux" to "Linux LVM" command (enter m for help): P disk / dev/sdb:10.7 GB, 10737418240 bytes 20971520 sector Units = sector of 1 * 512 = 512 bytes sector size (logical / physical): 512byte / 512byte I size (min / best): 512byte / 512byte disk label type: dos disk identifier: 0xd10b295e device Boot Start End Blocks Id System/dev/sdb1 2048 10487807 5242880 8e Linux LVM command (enter m for help): WThe partition table has been altered calling ioctl () to re-read partition table. Synchronizing disks. The newly added hard disk is initialized to the physical volume [root@localhost ~] # pvcreate / dev/sdb1 Physical volume "/ dev/sdb1" successfully created. View volume group [root@localhost ~] # vgdisplay-Volume group-VG Name centos System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 3 Open LV 3 Max PV 0 Cur PV 1 Act PV 1 VG Size 19.00 GiB PE Size 4.00 MiB Total PE 4864 Alloc PE / Size 4864 / 19.00 GiB Free PE / Size 0 / 0 VG UUID sNqtMh-Yg2a-Y2gb-RZh7-yVJg-gVQH-6n2bxz

Therefore, the volume group name is centos and the size is 19G.

Add a new physical volume to the volume group [root@localhost ~] # vgextend centos / dev/sdb1Volume group "centos" successfully extended to view the volume group again [root@localhost ~] # 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 3 Open LV 3 Max PV 0 Cur PV 2 Act PV 2 VG Size

Volume group size changed to 24G

Increase the logical volume size 4G [root @ localhost ~] # lvresize-L + 4G / dev/centos/home Size of logical volume centos/home changed from 5.00 GiB (1280 extents) to 9.00 GiB (2304 extents). Logical volume centos/home successfully resized. View the disk size [root@localhost ~] # lsblkNAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTsda 8:0 0 20G 0 disk sda1 8:1 0200M 0 part / boot └─ sda2 8:2 0 19G 0 part boot centos-root 253 010G 0 lvm / ├─ centos-swap 253 lvm 1 0 4G 0 lvm [SWAP] └─ centos-home 253 : 2 0 9G 0 lvm / homesdb 8:16 0 10G 0 disk └─ sdb1 8:17 0 5G 0 part └─ centos-home 253:2 0 9G 0 lvm / homesr0 11:0 1 4.2G 0 rom

At this point, I saw that centos-home became 9G.

Df-h View disk size [root@localhost ~] # df-h File system capacity available available mount point / dev/mapper/centos-root 10G 927m 9.1G 10% / devtmpfs 478m 0478m 0% / devtmpfs 489m 0489m 0% / dev/shmtmpfs 489m 6 .8m 482m 2% / runtmpfs 489M 0 489m 0 / sys/fs/cgroup/dev/mapper/centos-home 5.0G 33M 5.0G 1% / home/dev/sda1 197M 103M 95M 53% / boottmpfs 98M 098M 0% / run/user/0

It is found that / dev/mapper/centos-home is still 5G at this time.

Resize the file system [root@localhost ~] # xfs_growfs / dev/centos/homemeta-data=/dev/mapper/centos-home isize=512 agcount=4, agsize=327680 blks = sectsz=512 attr=2, projid32bit=1 = crc=1 finobt=0 spinodes=0data = bsize=4096 blocks=1310720 Imaxpct=25 = sunit=0 swidth=0 blksnaming = version 2 bsize=4096 ascii-ci=0 ftype=1log = 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 1310720 to 2359296

If it's xfs, use xfs_growfs. If it's ext4, use resize2fs.

Check again [root@localhost ~] # df-h File system capacity available available mount point / dev/mapper/centos-root 10G 927M 9.1G 10% / devtmpfs 478M 0478m 0% / devtmpfs 489m 0489m 0% / dev/shmtmpfs 489m 6.8m 482m 2 % / runtmpfs 489M 0 489m 0% / sys/fs/cgroup/dev/mapper/centos-home 9.0G 33M 9.0G 1% / home/dev/sda1 197m 103M 95M 53% / boottmpfs 98M 0 98m 0% / run/user/0

In this way, the / home/home partition is really expanded.

Thank you for reading this article carefully. I hope the article "sample Analysis of lvm Volume extension of Linux system" shared by the editor will be helpful to you. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report