CentOS 6 volume group attached hard disk tutorials

Source: Internet
Author: User
Tags hex code

The XEN architecture VPS generally provides a capacity of no less than 10 Gb, but most VPS Based on the Xensystem panel are mounted with 10 Gb hard disks by default (the first disk), and the remaining capacity (the second disk) you need to manually mount it to expand the default 10 Gb capacity.

We recommend that you operate on the new system. If the system already has data, we recommend that you back up the data first to prevent data loss caused by mounting errors.

This tutorial applies to CentOS 6 series. For CentOS 5 Series, see Xen Linux VPS hard disk volume group mounting tutorial.


1. view the current hard disk status
Fdisk-l

For example:

Here, "Disk/dev/xvdb: 21.5 GB" indicates that the second virtual hard Disk has 2 GB capacity, "/dev/mapper/vg_501153278-lv_root: "9135 MB" indicates that "/" is allocated 9135 MB (on the first virtual disk ).


Ii. format the second disk as an LVM Partition

Mount/dev/xvdb (second disk) and overwrite the capacity to the Linux system "/" directory. You need to format the second disk as an LVM partition first.


fdisk /dev/xvdb

Run the preceding command in SSH and then perform the following operations:


Command (m for help): n # create a partition Command action e extended p primary Partition (1-4) p # Set partition number (1-4) for the primary Partition ): 1 # primary Partition Number First cylinder (1-2610, default 1): 1 # Start sector (Press enter directly) Using default value 1 Last cylinder, + cylinders or + size {K, m, G} (1-2610, default 2610): 2610 Using default value 2610 # End sector (Press enter directly) Command (m for help ): t # specify the partition type Selected partition 1 # select partition 1 Hex code (type L to list codes): 8e # 8e is LVM Changed system type of partition 1 to 8e (Linux LVM) Command (m for help): w # Save The partition table has been altered! Calling ioctl () to re-read partition table. Syncing disks.

3. View volume groups
vgdisplay

Run the preceding command in SSH to view the current PV and record "VG Name": vg_501153278, as shown in.


4. Add a volume group
1. Create the just-created LVM as PV
pvcreate /dev/xvdb1

Run the preceding commands by Using SSH.


2. Add a volume group
vgextend vg_501153278 /dev/xvdb1

Run the preceding command by Using SSH, enter the group Name (Vg Name) and the corresponding sub-drive number (/dev/xvdb1), and press enter to run the command.


3. View idle volume groups
vgdisplay

Run the preceding command again to record the value in "Free PE/Size": 5118.


V. Extended Disk
1. Expand the LV size
lvresize -l +5118 /dev/mapper/vg_501153278-lv_root

Run the preceding command in SSH, replace "+ 5118" with the value in "Free PE/Size", and replace "vg_501153278" with the Name of "VG Name.


2. Reset the size (to make it take effect)
resize2fs /dev/mapper/vg_501153278-lv_root

Run the preceding command in SSH to extend the format to make it take effect. For example.

Conclusion:

The principle of mounting a volume group is to virtualize the two disks into one hard disk through the volume group. When the first hard disk is insufficient, data is directly written to the second hard disk.

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.