快速业务通道

RH135-7-LVM

作者 佚名技术 来源 Linux系统 浏览 发布时间 2012-03-29

###Logical Volume Management (LVM)###

Features:
1. Ability to create Volume sets and stripe sets
2. LVM masks the underlying physical technology (ATA, ATAPI, IDE, SCSI, SATA, PATA, etc.)
3. LVM represents storage using a hierarchy:
a. Volume Groups (VG)
a1. Physical Volumes (PV) (/dev/sda2, /dev/sdb2, etc.)
b. Logical Volumes (LV)
b1. File system
4. LVM physical volumes can be of various sizes
5. Ability to resize volumes on the fly

Note: Volume groups join: Physical Volumes (PVs) and Logical Volumes (LVs)

Steps to setup LVM:
1. Create LVM partitions via fdisk or parted
a. ''fdisk /dev/sda, /dev/sdb, /dev/sdc
b. n
c. p
d. 10G
e. t - change to type ''8e'' (LVM)
f. w
g. partprobe /dev/sda

2. Create Physical Volumes using ''pvcreate''
a. pvcreate /dev/sda3 /dev/sdb3 /dev/sdc3

3. Create Volume Groups using ''vgcreate''
a. vgcreate volgroup001 /dev/sda3 /dev/sdb3 /dev/sdc3
Note: Volume Groups can be segmented into multiple Logical Volumes

4. Create one or more Logical Volumes
a. lvcreate -L 10GB -n logvolvar1 volgroup001
b. lvcreate -L 10GB -n logvolusr1 volgroup001
5. Create File system on Logical Volume(s)
a. ''mke2fs -j /dev/volgroup001/logvolvar1''
b. ''mke2fs -j /dev/volgroup001/logvolusr1''
6. Mount Logical Volume
a. mkdir /var1
b. ''mount /dev/volgroup001/logvolvar1 /var1
c. mkdir /usr1
d. ''mount /dev/volgroup001/logvolusr1 /usr1

Note: Be certain to update: /etc/fstab so that volumes are mounted when the system reboots

Empire CMS,phome.net

3-tiers of LVM display commands include:
a. pvdisplay - physical volumes - represent raw LVM partitions
b. vgdisplay - volume groups - aggregate physical volumes
c. lvdisplay - logical volumes - file systems - mount here


Rename of Logical Volumes
1. lvrename - used to rename volumes
a. lvrename volume_group_name old new

Task: Rename ''logvolvar1'' to ''logvolopt1''
a. lvrename volgroup001 logvolvar1 logvolopt1
Note: LVM is updated immediately, even while volume is mounted
Note: However, you must remount the logical volume to see the changes
b. umount /var1 && mount /dev/mapper/volgroup001-logvolopt1 /opt1
c. Update /etc/fstab

Note: /dev/volgroup001/* is symlinks to /dev/mapper/

Remove Logical Volumes

Task: remove ''logvolusr1'' from the logical volume pool
a. umount /usr1
b. lvremove /dev/mapper/volgroup001-logvolusr1
c. use ''lvdisplay'' to confirm removal


Resize Logical Volume:

Task: Grow (resize) ''logvolopt1'' to 20GB
a. lvresize -L 20GB /dev/volgroup001/logvolopt1
b. lvdisplay - to confirm new size of logical volume
c. df -h - will still reveal the current size
d. Resize the file system to update the INODE table on the logical volume to account for the new storage in ''logvolopt1''
d1. ''resize2fs -f -p /dev/volgroup001/logvolopt1''

Note: You may resize file systems online if the following are met:
1. 2.6x kernel series
2. MUST be formatted with ext3

Task: Shrink (resize) ''logvolopt1'' to 15GB
a. lvresize -L 15GB /dev/volgroup001/logvolopt1
b. lvdisplay
c. df -h
d. resize2fs -f -p /dev/volgroup001/logvolopt1
Note: online shrinking is not supported
e. df -h
Empire CMS,phome.net


Note: Check disk utilization prior to shrinking to reduce the risk of losing data


LVM GUI Utility
system-config-lvm

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号