LVM common Command Parameters

Source: Internet
Author: User

LVM common Command Parameters

Physical Volume Management
Pvchange

The pvchange command allows the Administrator to change the permission for allocating physical volumes. If the physical volume fails, you can use the pvchange command to disable the allocation of PES on the physical volume.
Syntax pvchange (option) (parameter)

Option

-U: generate a new UUID;
-X: whether to allow PE allocation.

Parameters

Physical volume: Specify the device file corresponding to the physical volume of the property to be modified.

Instance
Use the pvchange command to disable the allocation of PES on a specified physical volume.

Enter the following command in the command line: pvchange-x n/dev/sdb1 # prohibit the allocation of PE on "/dev/sdb1"
The output information is as follows:
Physical volume "/dev/sdb1" changed
1 physical volume changed/0 physical volumes not changed

Pvcreate
The pvcreate command is used to initialize a physical hard disk partition as a physical volume for LVM to use.

Syntax pvcreate (option) (parameter)

Option

-F: Creates a physical volume forcibly without user confirmation;
-U: Specifies the UUID of the device;
-Y: Answers "yes" to all questions ";
-Z: whether to use the first four sectors.
Parameter physical volume: Specify the device file name corresponding to the physical volume to be created.

Convert 6-9 partitions to pv. Note the usage of braces:
[Root @ localhost ~] # Pvcreate/dev/hda {6, 7, 8, 9}
Physical volume "/dev/hda6" successfully
Created Physical volume "/dev/hda7" successfully created
Physical volume "/dev/hda8" successfully created
Physical volume "/dev/hda9" successfully created

Pvremove

The pvremove command is used to delete an existing physical volume. When you use the pvremove command to delete a physical volume,
It deletes the physical volume information on the LVM partition so that it is no longer considered as a physical volume.

Syntax:
Pvremove (option) (parameter)

Option

-D: debugging mode;
-F: Force Delete;
-Y: "yes" for the question ".

Parameters

Physical volume: Specify the device file name corresponding to the physical volume to be deleted.

Instance

Use the pvremove command to delete the physical volume/dev/sdb2.

Enter the following command in the command line: pvremove/dev/sdb2 # delete a physical volume

Labels on physical volume "/dev/sdb2" successfully wiped

From: http://man.linuxde.net/pvremove

Pvs

The pvs command is used to output formatted physical volume information reports. The pvs command can only obtain the summary of the physical volume,
To obtain more detailed information, use the pvdisplay command.

Syntax

Pvs (option) (parameter)

Option

-- Noheadings: No title header is output;

-- Nosuffix: the unit of no output space.

Parameters

Physical volume: displays the list of physical volumes for the report.

Instance

Use the pvs command to display information reports of all physical volumes in the system.
Enter the following command in the command line: pvs

# Output physical volume information the report output information is as follows:
Pv vg fmt Attr PSize PFree/dev/sdb1 vg1000 lvm2 -- 100.00 M 100.00 M/dev/sdb2 lvm2 -- 101.98 M 101.98 M

 

Pvresize

Pvdisplay

Pvscan

The pvscan command scans all hard disks connected to the system to list the physical volumes found.
Use the-n option of the pvscan command to display physical volumes in the hard disk that do not belong to any volume group. These physical volumes are not used.

Syntax

Pvscan Option

-D: debugging mode;

-E: Only displays physical volumes belonging to the output volume group;

-N: Only displays physical volumes that do not belong to any volume group;

-S: short format output;-u: displays UUID.

Instance

Use the pvscan command to scan the physical volumes of all hard disks in the current system,
Enter the following command in the command line:
[Root @ localhost ~] # Pvscan # scan physical volumes on all hard disks

The output information is as follows:
PV/dev/sdb1 lvm2 [101.94 MB] PV/dev/sdb2 lvm2[ 101.98 MB]
Total: 2 [203.92 MB]/in use: 0 [0]/in no VG: 2 [203.92 MB]

 

Volume Group Management
Vgcreate

The vgcreate command is used to create an LVM volume group. A Volume Group organizes multiple physical volumes into a whole,
Blocks the details of the underlying physical volume. When creating logical volumes on a volume group, you do not need to consider the specific physical volume information.

Syntax

Vgcreate (option) (parameter)

Option

-L: Maximum number of logical volumes allowed to be created in a volume group;

-P: Maximum number of physical volumes that can be added to a volume group;

-S: the PE size of the physical volume on the volume group.

Parameters

Volume group name: name of the volume group to be created; physical volume list: List of physical volumes to be added to the volume group.

Instance

Use the vgcreate command to create a volume group "vg1000" and add physical volumes/dev/sdb1 and/dev/sdb2 to the volume group.

Enter the following command in the command line:

[Root @ localhost ~] # Vgcreate vg1000/dev/sdb1/dev/sdb2 # create a volume group "vg1000"

The output information is as follows:

Volume group "vg1000" successfully created

Vgremove

The vgremove command is used to delete an LVM volume group. When a logical volume has been created on the volume group to be deleted, the vgremove Command needs to confirm the deletion,
Prevents accidental deletion of data.

Syntax

Vgremove (option) (parameter)

Option

-F: Force Delete.

Parameters

Volume group: the name of the volume group to be deleted.

Instance

Use the vgremove command to delete the LVM volume group "vg1000 ".

Enter the following command in the command line:

[Root @ localhost ~] # Vgremove vg1000 # delete a volume group

"Vg1000" Volume group "vg1000" successfully removed

Vgextend

The vgextend command is used to dynamically expand an LVM volume group by adding physical volumes to the volume group to increase the volume group capacity.
Physical volumes in the LVM volume group can be added when you create a volume group using the vgcreate command, or you can dynamically Add a volume group using the vgextend command.
 
Syntax
 
Vgextend (option) (parameter)

Option
 
-D: debugging mode;
 
-T: test only.
 
Parameters
 
Volume group: Specifies the name of the volume group to operate. Physical Volume list: Specifies the list of physical volumes to be added to the volume group.
 
Instance
 
Use the vgextend command to add a physical volume to the volume group "vg2000.
 
Enter the following command in the command line:
 
[Root @ localhost ~] # Vgextend vg2000/dev/sdb2 # Add the physical volume "/dev/sdb2" to the volume group "vg2000"

The output information is as follows:
 
Volume group "vg2000" successfully extended

Vgreduce

The vgreduce command removes physical volumes from an LVM volume group to reduce the volume group capacity. The remaining physical volume in the LVM volume group cannot be deleted.

Syntax

Vgreduce (option) (parameter)

Option

-A: If no physical volume is specified in the command line, all empty physical volumes are deleted;

-- Removemissing: deletes the lost physical volume in the volume group to restore the volume group to normal.

Parameters

Volume group: Specifies the name of the volume group to be operated. Physical Volume list: Specifies the list of physical volumes to be deleted.

Instance

Use the vgreduce command to remove the physical volume/dev/sdb2 from the volume group "vg2000.

Enter the following command in the command line:

[Root @ localhost ~] # Vgreduce vg2000/dev/sdb2 # Delete the physical volume "/dev/sdb2" from the volume group "vg2000"

The output information is as follows: Removed "/dev/sdb2" from volume group "vg2000"


Vgchange

The vgchange command is used to modify the attributes of a volume group. It is often used to set whether the volume group is active or inactive. An active volume group cannot be deleted,
You must use the vgchange command to set the volume group to non-active before deleting it.

Syntax

Vgchange (option) (parameter)

Option

-A: Set the activity status of the volume group.

Parameters

Volume group: Specify the volume group for which you want to set properties.

Instance

Use the vgchange command to change the status of the volume group to active.

Enter the following command in the command line:

[Root @ localhost ~] # Vgchange-ay vg1000 # Set the volume group "vg1000" to active

The output information is as follows:

1 logical volume (s) in volume group "vg1000" now active

Vgscan vgdisplay

Logical volume Management

Lvcreate

The lvcreate command is used to create the logical volume of the LVM. Logical volumes are created on the volume group. The device files corresponding to the logical volume are stored in the volume group directory,
For example, if you create a logical volume "lvol0" on the volume group "vg1000", the device file corresponding to the logical volume is "/dev/vg1000/lvol0 ".

Syntax

Lvcreate (option) (parameter)

Option

-L: Specifies the size of the logical volume, in the unit of "kKmMgGtT" bytes;

-L: Specify the logical volume size (number of LE ).

Parameters

Logical volume: name of the logical volume to be created.

Instance

Use the lvcreate command to create a MB logical volume on the volume group "vg1000.

Enter the following command in the command line:

[Root @ localhost ~] # Lvcreate-L 200 M vg1000 # create a logical volume of M

The output information is as follows:

Logical volume "lvol0" created

Lvremove

The lvremove command is used to delete the specified LVM logical volume. If the logical volume has been loaded using the mount command, you cannot use the lvremove command to delete it.
The logical volume can be deleted only after the umount command is unmounted.

Syntax

Lvremove (option) (parameter)

Option

-F: Force Delete.

Parameters

Logical volume: Specifies the logical volume to be deleted.

Instance

Use the lvremove command to delete the specified logical volume.

Enter the following command in the command line:

[Root @ localhost ~] # Lvremove/dev/vg1000/lvol0 # delete a logical volume "lvol0"

The output information is as follows:

Do you really want to remove active logical volume "lvol0 "? [Y/n]: y # confirm to delete Logical volume "lvol0" successfully removed

Lvextend

The lvextend command disk management lvextend command is used to expand the size of the logical volume online without interrupting the application's access to the logical volume.
The lvextend command is used to dynamically expand disk space online. The whole space expansion process is completely transparent to applications.
 
Syntax
 
Lvextend (option) (parameter)

Option
 
-L: Specifies the size of the logical volume, in the unit of "kKmMgGtT" bytes;
 
-L: Specify the logical volume size (number of LE ).
 
Parameters
 
Logical volume: Specifies the logical volume to be extended.
 
Instance
 
Use the lvextend command to increase the logical volume/dev/vg1000/lvol0 by MB.
 
Enter the following command in the command line:
 
[Root @ localhost ~] # Lvextend-L + 100 M/dev/vg1000/lvol0 # increase the space by M
 
The output information is as follows:
 
Extending logical volume lvol0 to 300.00 MB Logical volume lvol0 successfully resized

Lvresize

The lvresize command is used to adjust the space of the LVM logical volume to increase or reduce the space. Exercise caution when using the lvresize command to adjust the logical volume space and reduce the space,
It may cause data loss.

Syntax lvresize (option) (parameter)

Option

-L: Specifies the size of the logical volume, in the unit of "kKmMgGtT" bytes;

-L: Specify the logical volume size (number of LE ).

Parameters

Logical volume: Specifies the logical volume to be deleted.

Instance

Use the lvresize command to adjust the maximum logical volume size.

Enter the following command in the command line:

[Root @ localhost ~] # Lvresize-L + 200 M/dev/vg1000/lvol0 # increase the logical volume space by 200 M

The output information is as follows:

Extending logical volume lvol0 to 280.00 MB Logical volume lvol0 successfully resized

Lvreduce

The lvreduce command disk management lvreduce command is used to reduce the space occupied by LVM logical volumes. Using the lvreduce command to shrink the space of a logical volume may delete the existing data on the logical volume,
Therefore, you must confirm before the operation.

Syntax

Lvreduce (option) (parameter)

Option

-L: Specifies the size of the logical volume, in the unit of "kKmMgGtT" bytes;

-L: Specify the logical volume size (number of LE ).

Parameters

Logical volume: The device file corresponding to the logical volume to be operated.

Instance

Use the lvreduce command to reduce the size of the specified logical volume.

Enter the following command in the command line:

[Root @ localhost ~] # Lvreduce-L-50 M/dev/vg1000/lvol0 # reduce the size of the logical volume by 50 M

The output information is as follows:
... Omitted some output content... Do you really want to reduce lvol0? [Y/n]: y # confirm the operation
Elastic cing logical volume lvol0 to 252.00 MB Logical volume lvol0 successfully resized


Lvchange lvrename
Lvdisplay

The lvdisplay command is used to display attributes such as the logical volume size, read/write status, and snapshot information of LVM. If the "logical volume" parameter is omitted,
The lvdisplay command displays all logical volume attributes. Otherwise, only the specified logical volume attribute is displayed.

Syntax

Lvdisplay (parameter)

Parameters

Logical volume: The device file corresponding to the logical volume for which the attribute is to be displayed.

Instance

Use the lvdisplay command to display the attributes of the specified logical volume.

Enter the following command in the command line:
[Root @ localhost ~] # Lvdisplay/dev/vg1000/lvol0 # display logical volume attributes

The output information is as follows: --- Logical volume --- LV Name/dev/vg1000/lvol0 ...... some output content is omitted ...... Block device 253: 0

Lvscan

The lvscan command is used to scan all LVM logical volumes in the current system. You can use the lvscan command to find all logical volumes in the system,
And the corresponding device file.
 
Syntax
Lvscan (option)

Option

-B: displays the master and secondary device numbers of the logical volume.

Instance

Use the lvscan command to scan all logical volumes in the system.

Enter the following command in the command line:

[Root @ localhost ~] # Lvscan # scan all logical volumes

The output information is as follows: ACTIVE '/dev/vg1000/lvol0' [200.00 MB] inherit

  • Use LVM to create elastic disk storage-Part 1
  • Expanding/downgrading LVM in Linux (Part 2)
  • Recording and restoring logical volume snapshots in LVM (part 3)
  • Set a streamlined resource allocation volume in LVM (part 4)
  • Use fragmented I/O to manage multiple LVM disks (Part 5)

This article permanently updates the link address:

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.