Linux command: LVM manages disk files PV VG LV

Source: Internet
Author: User

Introduction to Commands:

Physical volume (PV) physical volume Management commands:

Pvcreate Create, Pvremove Remove data from PV, Pvscan scan

Pvdisplay Detailed View (PVS view simple information), Pvmove move the data on a PV to other PV

Command format:


pvcreat/dev/sda{10,11}

PVS View PV Information


Volume Group (VG) volume Group Management commands:

Vgcreate Create, Vgremove delete vg,pvscan scan, vgextend add extension

Vgreduce reduction, Vgdiplay detailed display (VGs simple display), Vgscan scan

Command format:


Vgcreate VG_NAME/PATH/TO/PV

Command parameters:

-S #: Specifies the PE size, which defaults to 4MB #为数字

Vgcreate myvg/dev/sda{10,11}

Vgremove MYVG

Vgcreate-s 8M myvg/dev/sda{10,11}

VGS Viewing VG Information

Vgreduce Myvg/dev/sda11 reduced SDA11 from MYVG

Pvremove/dev/sda11 removing SDA11 from PV


Logical Volume (LV) Logical Volume management commands:

Lvcreate Create, Lvremove delete lv,lvextend add extension,

Lvreduce reduction, Lvdisplay display (LVS)

Command format:

Lvcreate-n lv_name-l #G Vg_name

Command parameters:

-N: Specifies the name of the LV

-L #: Specifies the size of the LV, #表示数字

Lvcreate-l 50m-n TESTLV MYVG

Lvdisplay/dev/myvg/testlv

Mkfs-t EXT4/DEV/MYVG/TESTLV

Mount/dev/myvg/testlv/mnt

Lvremove/dev/mapper/myvg-testlv



Command instance:

1, create a PV,VG,LV process, and mount the use of the LV, as well as remove the LV (here is the use of 2 physical hard disk to do the test)

[[email protected] ~]# pvcreate/dev/sd{b,c} Create 2 hard drives as a physical volume (PV) Physical volume

Physical volume "/dev/sdb" successfully created

Physical volume "/DEV/SDC" successfully created

[[email protected] ~]# PVS View new PV information

PV VG Fmt Attr PSize pfree

/dev/sdb lvm2 a--2.00g 2.00g

/DEV/SDC lvm2 a--2.00g 2.00g

[[email protected] ~]# vgcreate myvg/dev/sd{b,c} Create Volume Group (VG) Volume Group

Volume Group "MYVG" successfully created

[[email protected] ~]# VGS View Volume group information

VG #PV #LV #SN Attr vsize vfree

MYVG 2 0 0 wz--n-3.99g 3.99g

[[email protected] ~]# lvcreate-l 50m-n testlv MYVG Create a 50MB-size Logicalvolume (LV) logical volume, and named TESTLV

Rounding up size to full physical extent 52.00 MiB

Logical volume "TESTLV" created

[[email protected] ~]# LVS Display Logical Volume Information

LV VG Attr lsize Pool Origin data% Move Log cpy%sync Convert

TESTLV myvg-wi-a-----52.00m

[[email protected] ~]# VGS Display volume group information

VG #PV #LV #SN Attr vsize vfree

MYVG 2 1 0 wz--n-3.99g 3.94g

[[email protected] ~]# vgdisplay Display volume group details, PE size 4MB

---Volume Group---

VG Name MYVG

System ID

Format lvm2

Metadata Areas 2

Metadata Sequence No 2

VG Access Read/write

VG Status resizable

MAX LV 0

Cur LV 1

Open LV 0

Max PV 0

Cur PV 2

ACT PV 2

VG Size 3.99 GiB

PE Size 4.00 MiB

Total PE 1022

Alloc pe/size 13/52.00 MiB

Free Pe/size 1009/3.94 GiB

VG UUID t2xygz-spon-dedp-z862-wx9v-7dai-ugwz03

[[email protected] ~]# lvdisplay Display the details of the logical volume

---Logical volume---

LV PATH/DEV/MYVG/TESTLV

LV Name TESTLV

VG Name MYVG

LV UUID XL2L2D-KKH9-SDVS-PMZG-OK39-LCIU-39GGPD

LV Write Access Read/write

LV Creation Host, Time Xuelinux, 2016-11-05 16:26:33 +0800

LV Status Available

# Open 0

LV Size 52.00 MiB

Current LE 13

Segments 1

Allocation inherit

Read ahead Sectors Auto

-Currently set to 256

Block Device 253:0

[[email protected] ~]# mkfs-t EXT4/DEV/MYVG/TESTLV The new LV format to EXT4 format

MKE2FS 1.41.12 (17-may-2010)

File System label =

Operating system: Linux

Block size =1024 (log=0)

Chunked size =1024 (log=0)

Stride=0 blocks, Stripe width=0 blocks

13328 inodes, 53248 blocks

2662 blocks (5.00%) reserved for the Super user

First block of data =1

Maximum filesystem blocks=54525952

7 Block groups

8192 blocks per group, 8192 fragments per group

1904 Inodes per group

Superblock backups stored on blocks:

8193, 24577, 40961


Writing Inode table: complete

Creating Journal (4096 blocks): complete

Writing Superblocks and FileSystem accounting information: Complete


This filesystem would be automatically checked every mounts or

Whichever comes first. Use Tune2fs-c or-i to override.


[[email protected] ~]# mount/dev/myvg/testlv/mnt mount the LV device

[Email protected] ~]# ls/mnt

Lost+found[[email protected] ~]# mount View devices that are already mounted

/dev/sda2 on/type ext4 (rw)

Proc On/proc type proc (rw)

Sysfs On/sys type SYSFS (rw)

Devpts on/dev/pts type devpts (rw,gid=5,mode=620)

Tmpfs on/dev/shm type Tmpfs (rw,rootcontext= "System_u:object_r:tmpfs_t:s0")

/DEV/SDA1 on/boot type EXT4 (rw)

/dev/sda3 on/home type EXT4 (rw)

/DEV/SDA7 on/tmp type EXT4 (rw)

/dev/sda5 on/usr type EXT4 (rw)

None On/proc/sys/fs/binfmt_misc type Binfmt_misc (rw)

/DEV/MAPPER/MYVG-TESTLV on/mnt type EXT4 (rw) LV has already been mounted successfully

The following action removes the LV device


[[email protected] ~]# umount/mnt First uninstall the already mounted LV device

[[email protected] ~]# LVREMOVE/DEV/MYVG/TESTLV directly remove the specified LV device

Do you really want to remove active logical volume TESTLV? [y/n]: y ok remove

Logical volume "TESTLV" successfully removed


[[email protected] ~]# lvdisplay See the LV device again, there is no LV device, so it is not shown.

[Email protected] ~]#

The following operation removes the VG device


[[email protected] ~]# vgreduce myvg/dev/sdb reduce the individual device SDB from the VG device

Removed "/dev/sdb" from volume Group "MYVG"

[[email protected] ~]# VGS view VG Information

VG #PV #LV #SN Attr vsize vfree

MYVG 1 0 0 wz--n-2.00g 2.00g

[[email protected] ~]# vgremove MYVG directly remove the entire VG

Volume Group "MYVG" successfully removed

[Email protected] ~]# VGS

No volume groups found removed successfully, VG device no

The following operation removes the PV device

[[email protected] ~]# PVs View PV information

PV VG Fmt Attr PSize pfree

/dev/sdb lvm2 a--2.00g 2.00g

/DEV/SDC lvm2 a--2.00g 2.00g

[[email protected] ~]# pvremove/dev/sdb remove SDB from PV

Labels on physical volume "/DEV/SDB" successfully wiped

[[email protected] ~]# PVREMOVE/DEV/SDC remove SDC from PV

Labels on physical volume "/DEV/SDC" successfully wiped

[[email protected] ~]# PVs removal succeeded, PV device no information

[Email protected] ~]#



2, create a PV,VG,LV process, and mount the use of the LV, as well as remove the LV (here is the use of 2 partitions to do the test)

The process of creating a LV with a partition is just the previous need to modify the partition type to 8e LVM type, and the other steps are consistent.



This article is from the "Learn Linux history" blog, please be sure to keep this source http://woyaoxuelinux.blog.51cto.com/5663865/1870134

Linux command: LVM manages disk files PV VG LV

Related Article

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.