磁盘管理之LVM
磁盘管理之LVM
LVM是逻辑盘卷管理(Logical Volume Manager)的简称,它是Linux环境下对磁盘分区进行管理的一种机制,LVM是建立在硬盘和分区之上的一个逻辑层,从而提高磁盘分区管理的灵活性。接下来通过实验来详细了解LVM的使用。
Linux入门教程:使用LVM逻辑卷管理器管理灵活存储
CentOS 6.3下配置LVM(逻辑卷管理)
Linux LVM简明教程
Linux的LVM(Logical Volume Manager) 学习笔记
RHCE认证笔记:LVM实验
Linux系统管理之LVM案例
1.实验环境准备.添加一块未使用过的磁盘/dev/sdb,使用fdisk从其中分出两个5G的分区,并且将其分区类型该为8e
[root@localhost ~]# fdisk -l /dev/sdb
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: 0x0f199ec4
Device Boot Start End Blocks Id System
/dev/sdb1 1 654 5253223+ 8e Linux LVM
/dev/sdb2 655 1308 5253255 8e Linux LVM
2.创建物理卷:
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvcreate /dev/sdb2
dev_is_mpath: failed to get device for 8:18
Physical volume "/dev/sdb2" successfully created
[root@localhost ~]# pvscan
PV /dev/sda2 VG vg0 lvm2 [59.99 GiB / 7.99 GiB free]
PV /dev/sdb1 lvm2 [5.01 GiB]
PV /dev/sdb2 lvm2 [5.01 GiB]
Total: 3 [70.01 GiB] / in use: 1 [59.99 GiB] / in no VG: 2 [10.02 GiB]
3.在物理卷的基础上创建卷组,将/dev/sdb1加入卷组
[root@localhost ~]# vgcreate test /dev/sdb1
Volume group "test" successfully create
[root@localhost ~]# vgscan #可以看到卷组test已经创建成功
Reading all physical volumes. This may take a while...
Found volume group "test" using metadata type lvm2
Found volume group "vg0" using metadata type lvm2
4.在卷组test中创建一个大小为4G的逻辑卷test1
[root@localhost ~]# lvcreate -L 4G -n test1 test
Logical volume "test1" created
[root@localhost ~]# lvscan
ACTIVE '/dev/test/test1' [4.00 GiB] inherit #test1已经创建成功
ACTIVE '/dev/vg0/root' [20.00 GiB] inherit
ACTIVE '/dev/vg0/swap' [2.00 GiB] inherit
ACTIVE '/dev/vg0/usr' [10.00 GiB] inherit
ACTIVE '/dev/vg0/var' [20.00 GiB] inherit
5.接下来就可以按照普通分区,对test1进行格式化,并且挂载使用了
[root@localhost ~]# mkfs.ext4 /dev/test/test1
mke2fs 1.41.12 (17-May-2010)
......
This filesystem will be automatically checked every 34 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@localhost ~]# mkdir /test
[root@localhost ~]# mount /dev/test/test1 /test/
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/vg0-root 20G 428M 19G 3% /
tmpfs 246M 0 246M 0% /dev/shm
/dev/sda1 194M 30M 155M 16% /boot
/dev/mapper/vg0-usr 9.9G 2.3G 7.2G 24% /usr
/dev/mapper/vg0-var 20G 361M 19G 2% /var
/dev/mapper/test-test1 4.0G 136M 3.7G 4% /test #逻辑卷成功创建
6.在/test下放入一个文件,测试可否使用
[root@localhost test]# echo "lv test" >a.txt
[root@localhost test]# cat a.txt
lv test
更多详情见请继续阅读下一页的精彩内容:
|
评论暂时关闭