This tutorial is suitable for the CentOS 6 series. For CentOS 5 series, please refer to “Xen Linux: VPS hard disk volume group mounting tutorial“.
First, view the current hard disk
fdisk -l

2, format the second disk to LVM partition
Mount the /dev/xvdb (the second disk) to Linux system “/” directory, the first step is format it to LVM partition
fdisk /dev/xvdb
Then do it as following
Command (m for help): n #create partition
Command action
e extended
p primary partition (1-4)
p #set the primary partition
Partition number (1-4): 1
First cylinder (1-2610, default 1):1 # Enter by default
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-2610, default 2610):2610
Using default value 2610 # (Enter by default) Command (m for help): t #partition type
Selected 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 group
vgdisplay
Execute it on SSH, view current PV and record ‘VG Name':vg_501153278
4, add volume group
1), create LVM to PV
pvcreate /dev/xvdb1
2), add add volume group
vgextend vg_501153278 /dev/xvdb1
Fill in Vg Name and partition number (/dev/xvdb1), Enter.
3), view free volume group
vgdisplay
Execute the command again, record ‘Free PE / Size’ value: 5118.
5, extend hard disk
1, extend LV size
lvresize -l +5118 /dev/mapper/vg_501153278-lv_root
Execute the command, and replace ‘+5118′ to ‘Free PE / Size’ value, replace ‘vg_501153278′ to ‘VG Name’ name.
2, set size
resize2fs /dev/mapper/vg_501153278-lv_root
The principle of Mount group volume is virtual two hard disks to one
through volume group, when the first hard disk capacity is not enough,
the data will be directly written to the second hard drive.
|