分类: LINUX
2010-09-18 22:18:36
[root@bogon ~]# rpm -qa | grep lvm
lvm2-2.02.40-6.el5
[root@bogon ~]# fdisk /dev/sdb1 对新硬盘分区
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-124, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-124, default 124): +200m
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
[root@bogon ~]# fdisk /dev/sdc1
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. 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)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-124, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-124, default 124): +200m
Command (m for help): t
Selected partition 1
Hex code (type L to list codes): 8e
Changed system type of partition 1 to 8e (Linux LVM)
Command (m for help): w
[root@bogon ~]# pvcreate /dev/sdb1 创建物理卷
Physical volume "/dev/sdb1" successfully created
[root@bogon ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@bogon ~]# pvdisplay 查看PV信息
[root@bogon ~]# vgcreate volcm /dev/sdb1 /dev/sdc1 创建卷组
Volume group "volcm" successfully created
[root@bogon ~]# vgchange -a y volcm 激活卷组
0 logical volume(s) in volume group "volcm" now active
[root@bogon ~]# pvscan 查看物理卷
PV /dev/sdb1 VG volcm lvm2 [980.00 MB / 980.00 MB free]
PV /dev/sdc1 VG volcm lvm2 [980.00 MB / 980.00 MB free]
PV /dev/sda2 VG VolGroup00 lvm2 [7.88 GB / 0 free]
Total: 3 [9.79 GB] / in use: 3 [9.79 GB] / in no VG: 0 [0 ]
[root@bogon ~]# vgscan 查看卷组
Reading all physical volumes. This may take a while...
Found volume group "volcm" using metadata type lvm2
Found volume group "VolGroup00" using metadata type lvm2
[root@bogon ~]# vgreduce volcm /dev/sdb1 删除物理卷
Removed "/dev/sdb1" from volume group "volcm"
[root@bogon ~]# vgextend volcm /dev/sdb1 增加物理卷
Volume group "volcm" successfully extended
[root@bogon ~]# lvcreate -L 200M -n lv1 volcm 创建逻辑卷
Logical volume "lv1" created
[root@bogon ~]# mkfs.ext3 /dev/volcm/lv1 格式化
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=1024 (log=0)
Fragment size=1024 (log=0)
51200 inodes, 204800 blocks
10240 blocks (5.00%) reserved for the super user
First data block=1
Maximum filesystem blocks=67371008
25 block groups
8192 blocks per group, 8192 fragments per group
2048 inodes per group
Superblock backups stored on blocks:
8193, 24577, 40961, 57345, 73729
Writing inode tables: done
Creating journal (4096 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 23 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@bogon ~]# mkdir /lvm1 挂载
[root@bogon ~]# mount /dev/volcm/lv1 /lvm1
[root@bogon ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
6.7G 1.1G 5.3G 18% /
/dev/sda1 99M 12M 82M 13% /boot
tmpfs 252M 0 252M 0% /dev/shm
/dev/mapper/volcm-lv1
194M 5.6M 179M 4% /lvm1
[root@bogon ~]# lvreduce -L -50m /dev/volcm/lv1 缩减逻辑卷
Rounding up size to full physical extent 48.00 MB
WARNING: Reducing active and open logical volume to 152.00 MB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lv1? [y/n]: y
Reducing logical volume lv1 to 152.00 MB
Logical volume lv1 successfully resized
[root@bogon ~]# lvextend -L +50m /dev/volcm/lv1 扩展逻辑卷
Rounding up size to full physical extent 52.00 MB
Extending logical volume lv1 to 204.00 MB
Logical volume lv1 successfully resized
[root@bogon ~]# umount /dev/volcm/lv1 删除逻辑卷
[root@bogon ~]# lvremove /dev/volcm/lv1
Do you really want to remove active logical volume "lv1"? [y/n]: y
Logical volume "lv1" successfully removed
大概就这些了......