Brief introduction

LVM It's logical volume management (Logical Volume Manager) For short , It is Linux It is a mechanism to manage disk partition in environment ,LVM It's a logical layer built on hard disks and partitions , To improve the flexibility of disk partition management . adopt LVM System administrators can easily manage disk partitions , Such as : Connect several partitions into a single volume group (volumegroup), Form a storage pool . Administrators can create logical volume groups on volume groups at will (logicalvolumes), And further create a file system on the logical volume group . Administrator through LVM You can easily adjust the size of the storage volume group , And you can name the disk storage as a group 、 Management and distribution .

Expansion plan

① Add a new hard disk , And put the new hard drive through mount Mount to the designated mount point ;( Let's say I create a new one /data Catalog , Mount the new hard disk to /data Available under )

② Add a new hard disk , adopt LVM Allocate the space of the new hard disk to the original system disk , Realize dynamic expansion of system disk ;( You can also enlarge the original disk in the virtual machine settings , And then expand )

Let's record it here centos7 Next plan ② Operation steps of .

Test target

Take one CentOS7.4 Virtual machine original system disk expansion 10G.( The original system disk 30G, Capacity to 40G)

Operation steps

1. Virtual machine edit settings add a new hard disk

2. Check it out.

[root@server- ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 990M 990M % /dev
tmpfs 1001M 1001M % /dev/shm
tmpfs 1001M 57M 944M % /run
tmpfs 1001M 1001M % /sys/fs/cgroup
/dev/mapper/centos-root 27G .8G 22G % / // After expansion , Let's look at the item , Contrast
/dev/sda1 1014M 154M 861M % /boot
tmpfs 201M 201M % /run/user/
[root@server- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda : 30G disk
├─sda1 : 1G part /boot
└─sda2 : 29G part
├─centos-root : 27G lvm /
└─centos-swap : 2G lvm [SWAP]
sdb : 10G disk // The new hard disk is named sdb, Already exist , But it's not partitioned yet and can't be used by the system
sr0 : 1024M rom

3. Create a partition for the new hard disk ( A partition is created by default here )

[root@server- ~]# fdisk /dev/sdb
Welcome to fdisk (util-linux 2.23.). Changes will remain in memory only, until you decide to write them.
Be careful before using the write command. Command (m for help): n // Add new section
Partition type:
p primary ( primary, extended, free)
e extended
Select (default p): // enter , Default p, Primary partition
Using default response p
Partition number (-, default ): // enter , Default 1
First sector (-, default ): // enter , Default start position
Using default value
Last sector, +sectors or +size{K,M,G} (-, default ): // enter , Default last position
Using default value
Partition of type Linux and of size GiB is set Command (m for help): t // Change the partition format
Selected partition
Hex code (type L to list all codes): L // Check out the options
Empty NEC DOS Minix / old Lin bf Solaris
FAT12 Hidden NTFS Win Linux swap / So c1 DRDOS/sec (FAT-
XENIX root Plan Linux c4 DRDOS/sec (FAT-
XENIX usr 3c PartitionMagic OS/ hidden C: c6 DRDOS/sec (FAT-
FAT16 <32M Venix Linux extended c7 Syrinx
Extended PPC PReP Boot NTFS volume set da Non-FS data
FAT16 SFS NTFS volume set db CP/M / CTOS / .
HPFS/NTFS/exFAT 4d QNX4.x Linux plaintext de Dell Utility
AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
AIX bootable 4f QNX4.x 3rd part Amoeba e1 DOS access
a OS/ Boot Manag OnTrack DM Amoeba BBT e3 DOS R/O
b W95 FAT32 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) CP/M a0 IBM Thinkpad hi eb BeOS fs
e W95 FAT16 (LBA) OnTrack DM6 Aux a5 FreeBSD ee GPT
f W95 Ext'd (LBA) 54 OnTrackDM6 a6 OpenBSD ef EFI (FAT-12/16/
OPUS EZ-Drive a7 NeXTSTEP f0 Linux/PA-RISC b
Hidden FAT12 Golden Bow a8 Darwin UFS f1 SpeedStor
Compaq diagnost 5c Priam Edisk a9 NetBSD f4 SpeedStor
Hidden FAT16 < SpeedStor ab Darwin boot f2 DOS secondary
Hidden FAT16 GNU HURD or Sys af HFS / HFS+ fb VMware VMFS
Hidden HPFS/NTF Novell Netware b7 BSDI fs fc VMware VMKCORE
AST SmartSleep Novell Netware b8 BSDI swap fd Linux raid auto
1b Hidden W95 FAT3 DiskSecure Mult bb Boot Wizard hid fe LANstep
1c Hidden W95 FAT3 PC/IX be Solaris boot ff BBT
1e Hidden W95 FAT1 Old Minix
Hex code (type L to list all codes): 8e // Change the partition format to LVM
Changed type of partition 'Linux' to 'Linux LVM' Command (m for help): p // Print , Check the modified partition (blocks Is the partition size Unit is kb) Disk /dev/sdb: 10.7 GB, bytes, sectors
Units = sectors of * = bytes
Sector size (logical/physical): bytes / bytes
I/O size (minimum/optimal): bytes / bytes
Disk label type: dos
Disk identifier: 0xa6e3dd82 Device Boot Start End Blocks Id System
/dev/sdb1 8e Linux LVM Command (m for help): w // preservation
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

4. Look at the partition again , It's just good zoning , No mount, no system root , Can't use

[root@server- ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda : 30G disk
├─sda1 : 1G part /boot
└─sda2 : 29G part
├─centos-root : 27G lvm /
└─centos-swap : 2G lvm [SWAP]
sdb : 10G disk
└─sdb1 : 10G part
sr0 : 1024M rom

5. Convert the new partition to a physical volume

[root@server- ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created.

6. View existing volume group names , Here for centos

[root@server- ~]# vgdisplay
--- Volume group ---
VG Name centos // This is a Centos The system default VG Name,RHEL The system shows rhel
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size <29.00 GiB // Note the change in this value
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 28.99 GiB
Free PE / Size / 4.00 MiB
VG UUID RNpAgN-PLQm-M4vp-E37i-fhhp-mr2z-faLm3A

7. Merge the physical volume of the conversion number to the vg( The volume group ) in

[root@server- ~]# vgextend centos /dev/sdb1
Volume group "centos" successfully extended
[root@server- ~]# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas
Metadata Sequence No
VG Access read/write
VG Status resizable
MAX LV
Cur LV
Open LV
Max PV
Cur PV
Act PV
VG Size 38.99 GiB // contrast , Bigger about 10G
PE Size 4.00 MiB
Total PE
Alloc PE / Size / 28.99 GiB
Free PE / Size / 10.00 GiB
VG UUID RNpAgN-PLQm-M4vp-E37i-fhhp-mr2z-faLm3A

8. View the logical volume , The default system is divided into 2 individual , Select the corresponding logical volume path

[root@server- ~]# lvdisplay
--- Logical volume ---
LV Path /dev/centos/swap // The system is divided by default 2G to swap, Never mind
LV Name swap
VG Name centos
LV UUID w8yxWk-Qrth-x16P-jVg3-1haX-lZUH-0r1SkV
LV Write Access read/write
LV Creation host, time localhost.localdomain, -- :: +
LV Status available
# open
LV Size 2.00 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device : --- Logical volume ---
LV Path /dev/centos/root // Expand the logical volume later , Remember the path
LV Name root
VG Name centos
LV UUID ECEWl4-0AEW-W1Tn-acE2-GLpe-NxeD-v16tGb
LV Write Access read/write
LV Creation host, time localhost.localdomain, -- :: +
LV Status available
# open
LV Size 26.99 GiB
Current LE
Segments
Allocation inherit
Read ahead sectors auto
- currently set to
Block device :

9. Expand space for logical volumes

[root@server- ~]# lvextend /dev/centos/root /dev/sdb1
Size of logical volume centos/root changed from 26.99 GiB ( extents) to <36.99 GiB ( extents).
Logical volume centos/root successfully resized.

10. Write to file system , Make the expansion effective .

[root@server- ~]# xfs_growfs /dev/mapper/centos-root
meta-data=/dev/mapper/centos-root isize= agcount=, agsize= blks
= sectsz= attr=, projid32bit=
= crc= finobt= spinodes=
data = bsize= blocks=, imaxpct=
= sunit= swidth= blks
naming =version bsize= ascii-ci= ftype=
log =internal bsize= blocks=, version=
= sectsz= sunit= blks, lazy-count=
realtime =none extsz= blocks=, rtextents=
data blocks changed from to

If it is ext System , have access to resize2fs Command substitution xfs_growfs command .

11. Check the expansion effect

[root@server- ~]# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 990M 990M % /dev
tmpfs 1001M 1001M % /dev/shm
tmpfs 1001M 57M 944M % /run
tmpfs 1001M 1001M % /sys/fs/cgroup
/dev/mapper/centos-root 37G .8G 32G % /
/dev/sda1 1014M 154M 861M % /boot
tmpfs 201M 201M % /run/user/

Compared with the initial display , Expansion successful .

end .

centos7 Next use LVM To expand the hard disk capacity of the system

  1. 【 Reprint 】CentOS7 Next use LVM Expand the hard disk of the system

    Original address :https://www.cnblogs.com/ding2016/p/9680690.html Brief introduction : LVM It's logical volume management (Logical Volume Manager) For short , It is L ...

  2. centos7 yum build lnmp Environment and configuration wordpress Detailed tutorial

    yum install lnmp The environment is the most convenient , The quickest way . It takes a lot of human time to compile and install the source code , Of course, source code compilation can be personalized to configure some other functions . For the moment ,yum The installation basically meets our requirements web Server requirements . This article is based on the recent ...

  3. Linux System hard disk expansion

    Reference tutorial :https://www.jb51.net/article/144291.htm 1. Check that the hard disk is used 99% $ df -h # Check that the hard disk is in use 99% file system Capacity Already used You can use Already used % hang ...

  4. Disk: Disk management LVM And system disk expansion

    brief introduction Hello, guys , Long time no see , Today, I would like to introduce the methods and experience of disk management : Disk management is an important part of operation and maintenance , It mainly includes the reasonable planning of disk and the expansion and reduction of capacity Common disk management methods are LVM(Logical Volume ...

  5. Oracle VM VirtualBox Inside the virtual machine Linux System hard disk expansion steps (CentOS6.5)

    1. First of all, get the information of the virtual machine to be expanded UUID VBoxManage The change order is C:\Program Files\Oracle\VirtualBox In the table of contents , You can add the directory to the environment variable first .C:\Users\yzkj- ...

  6. linux Next mount another system hard disk .

    Problem description : Error mounting /dev/sda5 at /media/wangzheng/ office : Command-line `mount -t "ntfs" -o &q ...

  7. LINUX for LVM Disk increases hard disk space

    summary : ~~~~~~~~~~~~~~~~~~~~ fdisk -lpvcreate /dev/sdbvgextend VolGroup /dev/sdblvextend -L +180G /dev/m ...

  8. CentOS7 Next use Firewall Firewall system blocking allows IP And port access Port forwarding IP Forwarding method

    CENTOS7 By default, the firewall system has started from iptable Changed to firewall, It's also used in different ways , Here is a detailed introduction One . Management port List dmz Level of allowed access port # firewall-cmd --zo ...

  9. Macbook install kali linux Dual system 2020.3 Hyperdetail

    Bloggers have been tossing about this thing for a week , There are still some problems to be solved ( I'll talk about it later ). But at least the system is equipped with , You can use the , It's amazing to see this table , And then click the top left corner to show that the world is worth . Actually, I'm pretending windos 10.macos and kali Three system ...

Random recommendation

  1. Spring Ioc--Bean assembly

    Follow up on the previous one IoC summary .Spring Container summary , Next, let's summarize Bean The assembly process of . To make a reference to Spring Container started successfully , You need to have the following skills at the same time 3 Conditions : 1.Spring The class package of the framework , Under the classpath of the application . ...

  2. SqlServer Split function

    Create FUNCTION [dbo].[SplitToTable] ( @SplitString nvarchar(max), @Separator nvarchar(10)=' ' ) RET ...

  3. cocos2d-x 3.2 Example file project location

    Update to 3.2 Then I suddenly want to see the official example , Suddenly found in test Medium cpp There is no project startup configuration under the project . strange , Is it just code ? After re searching, all the original project files are moved to build Under the folder , The specific path is  coc ...

  4. Tencent cloud YUM Installation failure

    After modifying the route ,YUM Installation failure , The prompt cannot be parsed YUM Source yum clear chche yum makecache

  5. Detailed explanation Paint Of setColorFilter(ColorFilter filter)

    One . brief introduction setColorFilter(ColorFilter filter) Set up color filtering , This method requires us to pass in a ColorFilter The parameter also returns a ColorFilter example . We are set ...

  6. [ turn ]cocos2d-js 3.0 Screen adaptation scheme The resolution adapts to

    First, introduce a api And the corresponding parameters : cc.view.setDesignResolutionSize(1024, 768, cc.ResolutionPolicy.FIXED_WIDTH); Here's the game ...

  7. Spring and SpringBoot Compare , The difference between solving puzzles

    1. summary : about Spring and SpringBoot What's the difference , I heard a lot of answers , Just started learning SpringBoot I was confused , With the accumulation of experience . I slowly understood the difference between the two frameworks , I Believe ...

  8. python3: File read and write +with open as sentence

    Please indicate the source of the reprint :https://www.cnblogs.com/shapeL/p/9141238.html Premise : In this paper, an example is introduced test.json Content : hello We 326342 1. File read ( ...

  9. 《Think Python》 The first 5 Chapter two study notes

    Catalog 5.1 Division and modulus (Floor division and modulus) 5.2 Boolean expression (Boolean expressions) 5.3 Logical operators (Logical operators) ...

  10. springboot2.1.3 Integrate webservice And errors No operation was found with the name {...} terms of settlement

    1. Project use springboot 2.1.3 edition , Integrate webservice The dependencies used are as follows <parent> <groupId>org.springframework.boot& ...