实验环境
虚拟机软件:VMware Workstation
操作系统:Read Hat Enteprise 6.3
1.查看/dev/sdb硬盘信息
[ root@template ~]# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xcb3a6101.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4):
Value out of range.
Partition number (1-4): 1
First cylinder (1-13054, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-13054, default 13054):
Using default value 13054Command (m for help): t
Selected partition 1
Hex code (type L to list codes): p
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)Command (m for help): p
Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xcb3a6101Device Boot Start End Blocks Id System
/dev/sdb1 1 13054 104856223+ 8e Linux LVMCommand (m for help): w
The partition table has been altered!Calling ioctl() to re-read partition table.
Syncing disks.
2.创建PV
[ root@template ~]# pvcreate /dev/sdb1
Writing physical volume data to disk "/dev/sdb1"
Physical volume "/dev/sdb1" successfully created
3.查看pv大小
[ root@template ~]# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg_template lvm2 a-- 199.51g 141.57g
/dev/sdb1 lvm2 a-- 100.00g 100.00g
4.查看vg大小
[ root@template ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_template 1 3 0 wz--n- 199.51g 141.57g
5.vg扩展
[ root@template ~]# vgextend vg_template /dev/sdb1
Volume group "vg_template" successfully extended
6.查看vg
[ root@template ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_template 2 3 0 wz--n- 299.50g 241.57g
[ root@template ~]# vgdisplay
--- Volume group ---
VG Name vg_template
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 9
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 2
Act PV 2
VG Size 299.50 GiB
PE Size 4.00 MiB
Total PE 76673
Alloc PE / Size 14832 / 57.94 GiB
Free PE / Size 61841 / 241.57 GiB
VG UUID Iaj2et-jkB2-aQbc-pvNo-nKcK-EUnZ-4ituwL/dev/mapper/vg_template-lv_root
50G 1.4G 46G 3% /
tmpfs 242M 0 242M 0% /dev/shm
/dev/sda1 485M 32M 429M 7% /boot
/dev/sr0 3.5G 3.5G 0 100% /media
/dev/mapper/vg_template-lv_home
5.0G 160M 4.6G 4% /home
7.增加home目录的lv至6G
[ root@template ~]# lvextend -L 6G /dev/mapper/vg_template-lv_home
Extending logical volume lv_home to 6.00 GiB
Logical volume lv_home successfully resized
[ root@template ~]# resize2fs -f /dev/mapper/vg_template-lv_home
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/vg_template-lv_home is mounted on /home; on-line resizing required
old desc_blocks = 1, new_desc_blocks = 1
Performing an on-line resize of /dev/mapper/vg_template-lv_home to 1572864 (4k) blocks.
The filesystem on /dev/mapper/vg_template-lv_home is now 1572864 blocks long.
8.查看home的lv大小
[ root@template ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg_template-lv_root
50G 1.4G 46G 3% /
tmpfs 242M 0 242M 0% /dev/shm
/dev/sda1 485M 32M 429M 7% /boot
/dev/sr0 3.5G 3.5G 0 100% /media
/dev/mapper/vg_template-lv_home
6.0G 160M 5.5G 3% /home