Establish and expand LVM Logical Volumes in Linux

Source: Internet
Author: User
Description of LVM Logical Volume Creation and Expansion: PV: physical volume VG: volume group (a VG on the physical layer is composed of one or more PVs) LV: logical volume (a VG on the logical level is composed of one or more LV) the order of creating logical volume is the hard disk of the PV-VG-LVIDE interface shown as: hdaSCSI interface hard disk display is: sda logical volume creation: example

 

LVM Logical Volume Creation and Expansion

 

Note:

PV: physical volume

VG: volume group (a VG on the physical layer is composed of one or more PVs)

LV: logical volume (a VG on the logical level is composed of one or more LV)

 

The logical volume creation sequence is PV-> VG-> LV

 

The hard disk of the IDE interface is displayed as hda.

The hard disk of the SCSI interface is displayed as sda.

 

Create logical volume:

For example, if we select hda5 as the logic, we must first confirm that hda5 is in umount state.

# Df? H Check the mount status of hda5 in the mount status

# Umount/Dev/hda5 Remove hda5

 

# Pvcreate/Dev/hda5Create hda5 as a physical volume

# PvscanView all the current physical volumes and check whether hda5 exists.

 

# Vgcreate VolGroup0/dev/hda5Create volume group VolGroup0 and add hda5 to volume Group

# VgscanView all the current volume groups and check that VolGroup0 exists.

 

# Lvcreate? L 5G? N Vol01 VolGroup0Create a 5G logical volume Vol01 and specify the volume group as VolGroup0

#LvsCan View all current logical volumes and confirm there is Vol01

 

# Mkfs. ext3/Dev/VolGroup0/Vol01 format the new logical volume Vol01

# Mkdir/TestCreate a directory

# Mount/dev/VolGroup0/Vol01/test Mount logical volume Vol01 to the test Directory

 

As a result, a logical volume is complete.

 

Extended logical volume:

1.   The VG space is large enough to only expand the LV

# Lvextend? L + 2G/Dev/VolGroup0/Vol01 add 2 GB space to the logical volume Vol01

# Resize2fs/Dev/VolGroup0/Vol01 Reset the Vol01 size

# Lvscan  The current lv size is changed to 7 GB.

# Reboot Restart the machine

# Df? H  After restarting, you can seeThe size of/dev/VolGroup0/Vol01 is 7 GB.

 

 

2.   VG is not enough space.

The premise of extending the VG is that there is still unallocated space on your hard disk.

# Fdisk/dev/hda n-> e-> 6-> + 5G-> w   Create a 5G extended partition with a partition number of 6

# Mkfs. ext3/dev/hda6 Format the new hda6

# Fdisk? L You can view all the current partitions to see hda6.

 

Next we will merge the new hda6 into VG.

 

# Pvcreate/Dev/hda6Create hda6 as a physical volume

# PvscanView all the current physical volumes and check whether hda6 exists.

# Vgextend VolGroup0/dev/hda6 Add hda6 to the VolGroup0 volume Group

# Vgs  Check the brief information of the vgs and find that the VolGroup0 space is increased.

If the problem persists, leave a message...

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.