码迷,mamicode.com
首页 > 系统相关 > 详细

linux下创建LVM

时间:2014-12-06 22:41:27      阅读:289      评论:0      收藏:0      [点我收藏+]

标签:des   http   io   ar   os   使用   sp   for   on   


参考文档链接:
http://www.chinaunix.net/jh/4/72921.html

名词解释:
1.物理卷 Physical Volume (PV):一个物理卷,包含了许多物理分区
2.物理分区 Physical Extents (PE)
3.卷组 Volume Group (VG):一个VG是由许多物理分区组成的(可能来自多个物理卷或硬盘)。
4.逻辑卷 Logical Volume (LV)
5.文件系统 Filesystem

创建逻辑卷LV,操作步骤如下:

1.对各个磁盘进行分区
[root@localhost ~]# fdisk /dev/sdb

2.创建物理卷(PV),例如:
[root@localhost ~]# pvcreate /dev/sdb1
Physical volume "/dev/sdb1" successfully created
[root@localhost ~]# pvcreate /dev/sdc1
Physical volume "/dev/sdc1" successfully created
[root@localhost ~]# pvcreate /dev/sdc2
Physical volume "/dev/sdc2" successfully created

3.将创建的物理卷(PV),添加到卷组(VG)中,比如VG命名为vgtest 
[root@localhost ~]# vgcreate vgtest /dev/sdb1 /dev/sdc1 /dev/sdc2
Volume group "vgtest" successfully created

3.1 查看新建的卷组
[root@localhost ~]# vgdisplay vgtest
--- Volume group ---
VG Name vgtest
System ID
Format lvm2
Metadata Areas 3
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 3
Act PV 3
VG Size 4.45 TB
PE Size 4.00 MB
Total PE 1167649
Alloc PE / Size 0 / 0
Free PE / Size 1167649 / 4.45 TB
VG UUID mxlmwo-DFHf-0Q32-W5Kj-KhaA-In07-DBReET

4.创建逻辑卷(命名为vgtest_LV01),在新建的卷组vgtest中
[root@localhost ~]# lvcreate -L 100G -n vgtest_LV01 vgtest    #创建100G容量大小的逻辑卷
Logical volume "vgtest_LV01" created

[root@localhost ~]# lvcreate -l +100%PVS -n vgtest_LV01 vgtest   #新逻辑卷使用全部的物理卷空间
Logical volume "vgtest_LV01" created

5.在逻辑卷上面创建文件系统,也就是格式化新创建的逻辑卷vgtest_LV01
[root@localhost ~]# mkfs.ext3 /dev/vgtest/vgtest_LV01
mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
13107200 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=0
800 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000, 7962624, 11239424, 20480000, 23887872

Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information:
done

This filesystem will be automatically checked every 35 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.

6.扩展逻辑卷LV的容量
[root@localhost ~]# lvextend -L +100G /dev/vgtest/vgtest_LV01
Extending logical volume vgtest_LV01 to 200.00 GB
Logical volume vgtest_LV01 successfully resized

7.扩展文件系统容量,逻辑卷LV容量扩展之后,需要随之扩展文件系统的容量
7.1检查文件系统
[root@localhost ~]# e2fsck -f /dev/vgtest/vgtest_LV01
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/vgtest/vgtest_LV01: 11/13107200 files (9.1% non-contiguous), 459383/26214400 blocks
7.2扩展文件系统
[root@localhost ~]# resize2fs -p /dev/vgtest/vgtest_LV01
resize2fs 1.39 (29-May-2006)
Resizing the filesystem on /dev/vgtest/vgtest_LV01 to 52428800 (4k) blocks.
Begin pass 1 (max = 800)
Extending the inode table XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
The filesystem on /dev/vgtest/vgtest_LV01 is now 52428800 blocks long.


部分命令:
help      Display help for commands
lvcreate    Create a logical volume
lvdisplay   Display information about a logical volume
lvs      Display information about logical volumes
pvcreate   Initialize physical volume(s) for use by LVM
pvdisplay  Display various attributes of physical volume(s)
pvs     Display information about physical volumes
vgcreate   Create a volume group
vgdisplay  Display volume group information
vgextend  Add physical volumes to a volume group
vgremove   Remove volume group(s)
vgs     Display information about volume groups


使用 parted 创建大于2T的gpt分区
[root@localhost ~]# parted /dev/sdb # 使用parted来对GPT磁盘操作,进入交互式模式
GNU Parted 1.8.1 Using /dev/sdb Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) mklabel gpt # 将MBR磁盘格式化为GPT
(parted) print #打印当前分区
(parted) mkpart primary 0 4.5TB # 分一个4.5T的主分区
(parted) mkpart primary 4.5TB 12TB # 分一个7.5T的主分区
(parted) print #打印当前分区
(parted) quit 退出
Information: Don’t forget to update /etc/fstab, if necessary.

 

linux下创建LVM

标签:des   http   io   ar   os   使用   sp   for   on   

原文地址:http://www.cnblogs.com/zhrq/p/4148829.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!