查看磁盘信息:
[root@PROD1 ~]# fdisk -l
Disk /dev/sda: 68.7 GB, 68719476736 bytes
255 heads, 63 sectors/track, 8354 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: 0x0003ad13
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 548 8355 62708736 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
使用sdb创建基于磁盘的物理卷
[root@PROD1 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created
查看物理卷创建是否成功
[root@PROD1 ~]# pvdisplay
"/dev/sdb" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID LDexlC-p56Q-knle-Gtxx-juj9-DmAD-nbaWgh
创建VG存储池
[root@PROD1 ~]# vgcreate VolGroup01 /dev/sdb
Volume group "VolGroup01" successfully created
分配LV逻辑卷
[root@PROD1 ~]# lvcreate -L 10G -n LogVol01 VolGroup01
Logical volume "LogVol01" created.
格式化分区
[root@PROD1 ~]# mkfs.ext4 /dev/VolGroup01/LogVol01
mke2fs 1.43-WIP (20-Jun-2013)
文件系统标签=
OS type: Linux
块大小=4096 (log=2)
分块大小=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
655360 inodes, 2621440 blocks
131072 blocks (5.00%) reserved for the super user
第一个数据块=0
Maximum filesystem blocks=2684354560
80 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Allocating group tables: 完成
正在写入inode表: 完成
Creating journal (32768 blocks): 完成
Writing superblocks and filesystem accounting information: 完成
添加/u02挂载点
[root@PROD1 ~]# mkdir /u02
挂载逻辑卷
[root@PROD1 ~]# mount /dev/VolGroup01/LogVol01 /u02
[root@PROD1 ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
/dev/mapper/VolGroup01-LogVol01 on /u02 type ext4 (rw)
卸载逻辑卷
[root@PROD1 ~]# umount /u02/
[root@PROD1 ~]# mount
/dev/sda3 on / type ext4 (rw)
proc on /proc type proc (rw)
sysfs on /sys type sysfs (rw)
devpts on /dev/pts type devpts (rw,gid=5,mode=620)
tmpfs on /dev/shm type tmpfs (rw)
/dev/sda1 on /boot type ext4 (rw)
none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
现在给系统新增加一块盘
[root@PROD1 ~]# fdisk -l
Disk /dev/sda: 68.7 GB, 68719476736 bytes
255 heads, 63 sectors/track, 8354 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: 0x0003ad13
Device Boot Start End Blocks Id System
/dev/sda1 * 1 26 204800 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 26 548 4194304 82 Linux swap / Solaris
Partition 2 does not end on cylinder boundary.
/dev/sda3 548 8355 62708736 83 Linux
Disk /dev/sdb: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
Disk /dev/sdc: 21.5 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 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: 0x00000000
Disk /dev/mapper/VolGroup01-LogVol01: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 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: 0x00000000
使用sdc创建基于磁盘的物理卷
[root@PROD1 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created
查看物理卷创建是否成功
[root@PROD1 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sdb
VG Name VolGroup01
PV Size 20.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 5119
Free PE 2559
Allocated PE 2560
PV UUID LDexlC-p56Q-knle-Gtxx-juj9-DmAD-nbaWgh
"/dev/sdc" is a new physical volume of "20.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdc
VG Name
PV Size 20.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID IqjvIC-HoGD-p9OL-9CP2-pkkZ-wghY-9emOzR
将sdc添加到卷组
[root@PROD1 ~]# vgextend VolGroup01 /dev/sdc
Volume group "VolGroup01" successfully extended
将sdc容量全部扩容到LogVol01
[root@PROD1 ~]# lvextend /dev/VolGroup01/LogVol01 /dev/sdc
Size of logical volume VolGroup01/LogVol01 changed from 10.00 GiB (2560 extents) to 30.00 GiB (7679 extents).
Logical volume LogVol01 successfully resized
通过resize2fs命令令新增的空间在线(on-line)生效
[root@PROD1 ~]# resize2fs /dev/VolGroup01/LogVol01
resize2fs 1.43-WIP (20-Jun-2013)
Resizing the filesystem on /dev/VolGroup01/LogVol01 to 7863296 (4k) blocks.
The filesystem on /dev/VolGroup01/LogVol01 is now 7863296 blocks long.
扩容后效果
[root@PROD1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda3 59G 12G 44G 22% /
tmpfs 1002M 280K 1001M 1% /dev/shm
/dev/sda1 190M 77M 100M 44% /boot
/dev/mapper/VolGroup01-LogVol01
30G 28M 28G 1% /u02
https://oracle-base.com/articles/linux/linux-logical-volume-management
http://blog.csdn.net/wuweilong/article/details/7565530
http://blog.itpub.net/29435844/viewspace-1071797/
http://blog.chinaunix.net/uid-1829236-id-161153.html