实验目的:
理解LVM(逻辑卷管理器),添加、删除和调整LVM大小。
实验环境:
操作系统:RedHat Enterprise Linux 5 (RHEL5)
相关软件:lvm2-2.02.16-3.el5
实验步骤:
1. 新建分区,并将新分区的系统类型改为Linux LVM
使用“fdisk”交互模式新增分区
[root@linux tmp]# fdisk /dev/hda
Command (m for help): n //使用“n”新建分区
First cylinder (7797-9729, default 7797):
Using default value 7797
Last cylinder or +size or +sizeM or +sizeK (7797-9729, default 9729): +100M // 设定分区大小
Command (m for help): n
First cylinder (7810-9729, default 7810):
Using default value 7810
Last cylinder or +size or +sizeM or +sizeK (7810-9729, default 9729): +100M
Command (m for help): n
First cylinder (7823-9729, default 7823):
Using default value 7823
Last cylinder or +size or +sizeM or +sizeK (7823-9729, default 9729): +50M
Command (m for help): p //使用“p”查看分区信息
我们刚刚建立的分区如下
/dev/hda5 7797 7809 104391 83 Linux
/dev/hda6 7810 7822 104391 83 Linux
/dev/hda7 7823 7829 56196 83 Linux
Linux LVM分区类型代码为“8e”,(我们可以通过“l” 查看分区类型代码)
将刚刚建立的分区转换成Linux LVM类型
Command (m for help): t //使用“t”转换分区类型
Partition number (1-7): 7 // 输入分区号
Hex code (type L to list codes): 8e //输入分区类型代码
Changed system type of partition 7 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e (Linux LVM)
Command (m for help): t
Partition number (1-7): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
查看现在的分区信息
/dev/hda5 7797 7809 104391 8e Linux LVM
/dev/hda6 7810 7822 104391 8e Linux LVM
/dev/hda7 7823 7829 56196 8e Linux LVM
Command (m for help): w //输入“w” 保存退出
立即更新分区信息而不用重新启动系统
[root@linux tmp]# partprobe
2. 建立PV(物理卷)
将新建的分区“ /dev/hda5 /dev/hda6 /dev/hda7 ”转换为PV
[root@linux tmp]# pvcreate /dev/hda5 /dev/hda6 /dev/hda7
Physical volume “/dev/hda5” successfully created
Physical volume “/dev/hda6” successfully created
Physical volume “/dev/hda7” successfully created
查看PV信息
[root@linux tmp]# pvdisplay
— NEW Physical volume —
PV Name /dev/hda5
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID jSaI8a-D2B3-5HSA-LkPT-hQ1v-gut6-yY10t6
— NEW Physical volume —
PV Name /dev/hda6
VG Name
PV Size 101.94 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID ZHYeHa-lJtI-0UA8-DZhN-WBiU-0pfF-gqFlsy
— NEW Physical volume —
PV Name /dev/hda7
VG Name
PV Size 54.88 MB
Allocatable NO
PE Size (KByte) 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID KLBWkX-l694-Yagy-BdHf-RkJ2-2NIC-ltGty0
3. 建立VG(卷组)
将刚刚建立的PV中的2个分配到VG中,将VG命名为vg1
[root@linux tmp]# vgcreate vg1 /dev/hda5 /dev/hda6
Volume group “vg1” successfully created
查看建立好的VG
[root@linux tmp]# vgdisplay
— Volume group —
VG Name vg1
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 1
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 2
Act PV 2
VG Size 200.00 MB
PE Size 4.00 MB
Total PE 50
Alloc PE / Size 0 / 0
Free PE / Size 50 / 200.00 MB
VG UUID GOysUz-Fyeu-ttE0-R3UE-ra3Z-s1dM-l4QZ7n
4. 建立LV(逻辑卷)
建立新的LV,分配VG中全部的空间,并命名为LV1
[root@linux tmp]# lvcreate -L 200M -n lv1 vg1
Logical volume “lv1” created
查看LV信息
[root@linux tmp]# lvdisplay
— Logical volume —
LV Name /dev/vg1/lv1
VG Name vg1
LV UUID PkCxki-KweE-AcpE-r1KO-cguR-mxUm-xvPP0n
LV Write Access read/write
LV Status available
# open 0
LV Size 200.00 MB
Current LE 50
Segments 2
Allocation inherit
Read ahead sectors 0
Block device 253:3
使用ext3格式,建立LV的文件系统
[root@linux tmp]# mke2fs -j /dev/vg1/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 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
6. 挂载LV分区到目录
[root@linux tmp]# mount /dev/vg1/lv1 /tmp/lvm/
[root@linux tmp]# mount
/dev/mapper/vg1-lv1 on /tmp/lvm type ext3 (rw)
实验总结:
LVM将物理磁盘分区通过逻辑方式进行灵活的管理,可以充分保证在实际环境中对磁盘空间的合理利用。下期实验介绍如何调整LVM的大小和删除LVM。
RHCE_LAB(6)RHEL5的LVM应用实例(LVM创建)——结束
RHEL5的LVM应用实例(LVM创建)
转载请注明出处:服务器评测 » RHEL5的LVM应用实例(LVM创建)
相关推荐
- *FDC Servers 宣布在欧洲和北美进行大规模数据中心扩张
- *{eWebGuru.com} 廉价专用服务器| 免费 SSL 证书
- *229 美元/月 E-2276G + 128GB RAM + 2x1TB NVMe + 10TB 备份 + 1Gbps 20TB BW 限时优惠!
- *★★ 八核 HT Xeon 特价销售!| 中西部专用主机 | 美国印第安纳波利斯 ★★
- *Dedirock 为您提供首月 10% 闪购折扣,立即抢购!!!
- *FDC Servers 宣布在欧洲和北美进行大规模数据中心扩张
- ★ PSYCHZ NETWORKS ★ – 每月 22 美元起的超值优惠
- 腾讯云服务器CentOS环境下通过YUM安装软件