逻辑卷管理(LVM)
1、命令一般,对于物理机新插入的磁盘,或者虚拟机新建的磁盘,先用fdisk /dev/sdb命令创建分区。创建好一个分区/dev/sdb1之后,继续物理卷。1、创建物理卷pvcreate /dev/sdb1pvdisplay显示已建的物理卷2、创建卷组vgcreate vgtest(卷组名) /dev/sdb1vgdisplay3、创建逻辑卷lvcrea
1、命令
一般,对于物理机新插入的磁盘,或者虚拟机新建的磁盘,先用fdisk /dev/sdb命令创建分区。创建好一个分区/dev/sdb1之后,继续物理卷。
1、创建物理卷
pvcreate /dev/sdb1
pvdisplay显示已建的物理卷
2、创建卷组
vgcreate vgtest(卷组名) /dev/sdb1
vgdisplay
3、创建逻辑卷
lvcreate -L 600M(卷的大小) -n lvtest(卷名) vgtest
lvdisplay
4、建立挂载
mkdir /u01
vi /etc/fstab
/dev/vgtest/lvtest /u01 ext3 defaulte
5、文件格式化
mkfs.ext3 /dev/vgtest/lvtest
扩展逻辑卷大小
lvextend -L 1G(扩展到1G)/dev/vgtest/lvtest
resize2fs /dev/vgtest/lvtest 文件系统同步
缩减逻辑卷大小
umount
e2fscheck -f /dev/vgtest/lvtest
resize2fs /dev/vgtest/lvtest 800M(缩减到800M)
lvreduce -L 800M /dev/vgtest/lvtest
mount
将新硬盘加入逻辑卷
1、建立物理卷
2、扩展至卷组
vgextend vgtest /dev/sda10
撤出硬盘
pvmove vgtest /dev/sda10
vgreduce vgtest /dev/sda10
以上是关于LVM的一些操作
2、实例
- pvcreate /dev/sdb1
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/sda3
VG Name VolGroup
PV Size 18.80 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4813
Free PE 0
Allocated PE 4813
PV UUID r3DcdH-tavS-z0dy-bTcg-F5fz-F8MF-dpAjW3
"/dev/sdb1" is a new physical volume of "30.00 GiB"
--- NEW Physical volume ---
PV Name /dev/sdb1
VG Name
PV Size 30.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID 1Ynxmw-JblF-XAeE-ZKGD-0BSV-s7BL-SU1mql
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 18.80 GiB
PE Size 4.00 MiB
Total PE 4813
Alloc PE / Size 4813 / 18.80 GiB
Free PE / Size 0 / 0
VG UUID Xdh5kq-vKjk-nroE-Dssd-mi1h-SQGK-R07tOn
- vgextend VolGroup /dev/sdb1
[root@localhost ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 48.80 GiB
PE Size 4.00 MiB
Total PE 12492
Alloc PE / Size 4813 / 18.80 GiB
Free PE / Size 7679 / 30.00 GiB
VG UUID Xdh5kq-vKjk-nroE-Dssd-mi1h-SQGK-R07tOn
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup/LogVol01
VG Name VolGroup
LV UUID IUVeUw-2bmN-mm3H-Gh16-fKaR-choS-IfSosr
LV Write Access read/write
LV Status available
# open 1
LV Size 16.80 GiB
Current LE 4301
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup/LogVol00
VG Name VolGroup
LV UUID U9WYdb-xAdg-tCe1-FPxo-UyVe-v5Gp-a8UlZR
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@localhost ~]# lvextend /dev/VolGroup/LogVol01 /dev/sdb1
Extending logical volume LogVol01 to 46.80 GiB
Logical volume LogVol01 successfully resized
[root@localhost ~]# lvdisplay
--- Logical volume ---
LV Name /dev/VolGroup/LogVol01
VG Name VolGroup
LV UUID IUVeUw-2bmN-mm3H-Gh16-fKaR-choS-IfSosr
LV Write Access read/write
LV Status available
# open 1
LV Size 46.80 GiB
Current LE 11980
Segments 2
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Name /dev/VolGroup/LogVol00
VG Name VolGroup
LV UUID U9WYdb-xAdg-tCe1-FPxo-UyVe-v5Gp-a8UlZR
LV Write Access read/write
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-LogVol01
17G 8.3G 7.5G 53% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 194M 25M 159M 14% /boot
[root@localhost ~]# resize2fs /dev/mapper/VolGroup-LogVol01
resize2fs 1.41.12 (17-May-2010)
Filesystem at /dev/mapper/VolGroup-LogVol01 is mounted on /; on-line resizing required
old desc_blocks = 2, new_desc_blocks = 3
Performing an on-line resize of /dev/mapper/VolGroup-LogVol01 to 12267520 (4k) blocks.
The filesystem on /dev/mapper/VolGroup-LogVol01 is now 12267520 blocks long.
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用%% 挂载点
/dev/mapper/VolGroup-LogVol01
47G 8.3G 36G 19% /
tmpfs 499M 0 499M 0% /dev/shm
/dev/sda1 194M 25M 159M 14% /boot
更多推荐
所有评论(0)