CentOS7 LVM add HDD and expansion

Source: Internet
Author: User

I. Introduction of LVM

LVM is shorthand for Logical Volume Manager (Logical Volume management), which is a mechanism for managing disk partitions in a Linux environment. LVM converts one or more disk partitions (PV) into a volume group (VG), which is equivalent to a large hard disk, where we can divide some logical volumes (LVS). You can add a new disk partition when there is not enough space for the volume group to use. We can also divide some space from the remaining space on the volume group to use for logical volumes that are not enough space.


LVM models such as:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/3F/wKiom1UCozqRFqxeAAG7GUxEGiI294.jpg "title=" 15.png "alt=" Wkiom1ucozqrfqxeaag7guxegii294.jpg "/>

Second, LVM add HDD and expansion

Test environment: CentOS7 64-bit (KVM virtual machine)

LVM version: lvm2-2.02.105-14.el7.x86_64

1. Add a hard drive (8GB) to the system

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/39/wKioL1UCppmhSdIjAAKV8ioaU_8847.jpg "title=" 14.png "alt=" Wkiol1ucppmhsdijaakv8ioau_8847.jpg "/>

Use fdisk-l to see this new plate for/DEV/VDB:

shell# fdisk-l

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/3F/wKiom1UCpifTBblUAAQ82M1Bf5g201.jpg "title=" 2.png " alt= "Wkiom1ucpiftbbluaaq82m1bf5g201.jpg"/>

2, the new disk partition

Use the fdisk command to partition the new disk, where a primary partition/DEV/VDB1 is established, size 8GB, and finally the partition table is re-read using the partprobe command:

shell# fdisk/dev/vdbshell# Partprobe

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/39/wKioL1UCp5GxyGZaAA4mZCbd6zI957.jpg "title=" 3-1_ copy. png "alt=" wkiol1ucp5gxygzaaa4mzcbd6zi957.jpg "/>

In the partitioning process, note that the format is 8e, which is the LVM partition format.

3. Create physical volume (PV)

To create a physical volume using the pvcreate command,pvdisplay View the physical volume information:

shell# pvcreate/dev/vdb1shell# Pvdisplay

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/39/wKioL1UCqNqxGdtnAALlubh9ZfU693.jpg "title=" 4.png " alt= "Wkiol1ucqnqxgdtnaallubh9zfu693.jpg"/>

4. Adding PV to the Volume Group (VG)

Use Vgdisplay to view volume group information and display the volume group named CentOS with an idle size of 0:

shell# Vgdisplay

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/39/wKioL1UCqauTF4K3AAHZNsqkEPU128.jpg "title=" 1.png " alt= "Wkiol1ucqautf4k3aahznsqkepu128.jpg"/>

Add/DEV/VDB1 to CentOS using the vgextend command:

shell# Vgextend CENTOS/DEV/VDB1

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/39/wKioL1UCqieTRfuIAAB8vhFL7c4900.jpg "title=" 5.png " alt= "Wkiol1ucqietrfuiaab8vhfl7c4900.jpg"/>

We re-check the volume group information and found that the free space is 8GB, indicating that/DEV/VDB1 has successfully joined in:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/3A/wKioL1UCqqjCkyMAAAHAR-pYI4Q174.jpg "title=" 6.png " alt= "Wkiol1ucqqjckymaaahar-pyi4q174.jpg"/>

5. Create a logical volume (LV)

Use the lvcreate command to divide a new logical volume from the volume group, creating a logical volume partition called NEWLV, 4GB in size, and using Lvdisplay to view logical Volume information:

shell# lvcreate-l 4g-n newlv centosshell# lvdisplay

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/3F/wKiom1UCqguxHgiGAAW2XNw9-gQ507.jpg "title=" 7-1_ copy. png "alt=" wkiom1ucqguxhgigaaw2xnw9-gq507.jpg "/>

Let's look at the volume group information again, the volume group has the remaining 4GB space:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/40/wKiom1UCqszySmcfAAHjPD9topM757.jpg "title=" 8.png " alt= "Wkiom1ucqszysmcfaahjpd9topm757.jpg"/>

6. Format the logical volume and mount it

The new logical volume is formatted to be mounted to the system to store data. Use mkfs.xfs format to CentOS7 XFS file system:

shell# MKFS.XFS/DEV/CENTOS/NEWLV

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/3A/wKioL1UCreviNJTmAAHP5wDGs_I570.jpg "title=" 9.png " alt= "Wkiol1ucrevinjtmaahp5wdgs_i570.jpg"/>

Mount to the/mnt directory (you can mount it to the directory you need), and then mount it to see a capacity of 4GB:

shell# mount-t xfs/dev/centos/newlv/mnt/shell# df-th

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/5B/40/wKiom1UCrPijc-QwAAISB0kRF4Q420.jpg "title=" 10.png "alt=" Wkiom1ucrpijc-qwaaisb0krf4q420.jpg "/>

Set the boot auto mount, edit the /etc/fstab file, add the last line:

/dev/centos/newlv/mnt XFS Defaults 1 2

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/40/wKiom1UCru2h4j7zAAD5xdCy684180.jpg "title=" 16.png "alt=" Wkiom1ucru2h4j7zaad5xdcy684180.jpg "/>

7, Logical Volume expansion

Use the lvextend command for logical volume expansion. I allocated all the remaining space to the NEWLV and increased it to 8GB, such as:

shell# lvextend-l +100%FREE/DEV/CENTOS/NEWLV

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/3A/wKioL1UCsGmCLO6tAADG8q0WDxs285.jpg "title=" 11.png "alt=" Wkiol1ucsgmclo6taadg8q0wdxs285.jpg "/>

Use the xfs_growfs command to adjust the XFS format file system size online (CentOS6 using RESIZE2FS):

shell# XFS_GROWFS/DEV/CENTOS/NEWLV

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/5B/40/wKiom1UCr1OCExEnAAQhpLMXn8g840.jpg "title=" 12.png "alt=" Wkiom1ucr1ocexenaaqhplmxn8g840.jpg "/>

Finally we see that the logical volume partition has been dynamically expanded to 8GB:

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/5B/3A/wKioL1UCsIbTUjAUAAHFG4bUKDE852.jpg "title=" 13.png "alt=" Wkiol1ucsibtujauaahfg4bukde852.jpg "/>

This article is from the "Start Linux blog" blog, make sure to keep this source http://qicheng0211.blog.51cto.com/3958621/1620171

CentOS7 LVM add HDD and expansion

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.