LVM Operation case

Source: Internet
Author: User

This article source: http://blog.csdn.net/bluishglc/article/details/48177367 prohibited any form of reprint, or will entrust CSDN official maintenance rights!

Scene

One machine is equipped with 3 hard drives with a capacity of 20g,45g,45g, with 20G of hard drives hanging in the root directory

Demand

Because the hard disk capacity is small, the remaining two fast 45G hard drives need to be stitched together for use

LVM Basics

Operation 0. Pre-preparation

We assume that we have partitioned and formatted each hard drive, which means that the hard drives and partitions are already working properly before we do the LVM transformation, so let's take a look at the hard disk and partition of this machine:

Simply put, three hard drives, one partition per hard disk, each partition occupies the full space of the disk, we pay particular attention to the partition's system ID (System type), which is the corresponding value of the systems column, Linux, which is the type of normal Linux physical partition, Our next first job is to modify it.

In fact, a physical volume can be built directly on a hard disk, that is, if you want the entire hard disk to be a physical volume, you don't need to partition and format it in advance! This way you don't need to change the type of a partition to Linux LVM.

1. Modify the system ID of the partition (type)

This is the first step in our creation of LVM, such as the previous one, usually the Linux partition's system ID is Linux (Code 83), and we want to modify them to Linux LVM (code 8e) to be managed and used by LVM.

This is done by using FDISK to complete the modification. In the following operation example:

    1. Enter T, command to modify the system ID of the partition
    2. Then you need to enter the new system Id,linux LVM type code is 8e
    3. Enter W, save the partition table and exit

Then use Fdisk-l to see if the change was successful, and in the output of the/DEV/XVDB1 partition we can clearly see that the System ID has changed to 8e Linux LVM

The next step is to perform the same operation on the third hard drive and change the partition system type to 8e Linux LVM.

2. Create a physical volume (PV)

Use the command:

pvcreate /dev/xvdb1 /dev/xvdc1

Note: As previously mentioned, you can directly put a hard disk into a physical volume instead of a partition, you can do this

pvcreate /dev/xvdb /dev/xvdc

Create two physical volumes

Use the command:

pvdisply

View the physical volumes created

3. Create a logical Volume group (VG)
vgcreate vg1 /dev/xvdb1 /dev/xvdc1

Create a logical Volume group VG1

Note: Similarly, if you are a physical volume created on a hard disk, as in the previous article, you should do this:

vgcreate vg1 /dev/xvdb /dev/xvdc

Use the command:

vgdisplay

To view the created Logical volume group

It is worth noting that the capacity of the VG1 is already the sum of two partitions.

4. Creating a logical Volume

Use the command:

-l100%-n lv1 vg1

Create a logical Volume LV1, assign the full capacity of the logical volume group VG1 to it

Use the command:

lvdisplay

View the logical volume you just created

5. Formatting logical Volumes

Use the command:

mkfs.ext4 /dev/vg1/lv1

Now that a logical volume has been created, we can see that it has no difference in the system and a physically 75GB hard drive, and then we can attach it to a folder and use it. We can use parted to look at all the partitioning conditions:

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

LVM Operation case

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.