Linux LVM(Logical Volume Manager)

假设有3个disk 分区(/dev/sda1,/dev/sda2,/dev/sda3),先用2个做一个logical volume,在上面分一个区出来,然后假设这个区数据满了,把另外一个disk 分区弄上去,不丢数据

基本概念物理卷

物理分区(physical extent)

卷组

逻辑卷(logical volume)

建立2个disk分区的logical volume把/dev/sda1,/dev/sda2的分区类型修改为0x8e,”linux LVM” ( fdisk )

[root@SpecialProtocol root]# fdisk /dev/sda

The number of cylinders for this disk is set to 89410.There is nothing wrong with that, but this is larger than 1024,and could in certain setups cause problems with:1) software that runs at boot time (e.g., old versions of LILO)2) booting and partitioning software from other OSs (e.g., DOS FDISK, OS/2 FDISK)

Command (m for help): tPartition number (1-4): 1Hex code (type L to list codes): 8eChanged system type of partition 1 to 8e (Linux LVM)

Command (m for help):建立物理卷

[root@SpecialProtocol root]# pvcreate /dev/sda1 /dev/sda2 pvcreate — physical volume “/dev/sda1” successfully createdpvcreate — physical volume “/dev/sda2” successfully created把物理卷加到卷组

[root@SpecialProtocol root]# vgcreate test /dev/sda1 /dev/sda2vgcreate — INFO: using default physical extent size 32 MBvgcreate — INFO: maximum logical volume size is 2 Terabytevgcreate — doing automatic backup of volume group “test”vgcreate — volume group “test” successfully created and activated检查

[root@SpecialProtocol root]# vgdisplay -v test— Volume group —VG Name testVG Access read/writeVG Status available/resizableVG # 0MAX LV 256Cur LV 0Open LV 0MAX LV Size 2 TBMax PV 256Cur PV 2Act PV 2VG Size 306.31 GBPE Size 32 MBTotal PE 9802Alloc PE / Size 0 / 0Free PE / Size 9802 / 306.31 GBVG UUID 6v7zQA-H22c-AeQ3-1wN1-KBV9-ByZd-LJfllT

— No logical volumes defined in “test” —

— Physical volumes —PV Name (#) /dev/sda1 (1)PV Status available / allocatableTotal PE / Free PE 4901 / 4901

PV Name (#) /dev/sda2 (2)PV Status available / allocatableTotal PE / Free PE 4901 / 4901建立逻辑卷

[root@SpecialProtocol root]# lvcreate -L 306G -n lgdisk testlvcreate — doing automatic backup of “test”lvcreate — logical volume “/dev/test/lgdisk” successfully created建立文件系统

mkfs -t ext3 /dev/test/lgdiskmount 文件系统就可以用了

[root@SpecialProtocol root]# mount /dev/test/lgdisk /mnt增加一个disk分区过一段时间后,/dev/test/lgdisk满了,把/dev/sda3加上去用

如果卷组有多的空间,直接调用e2fsadm就可以了,下面我们做的事情是假设要加一个硬盘上去

umount 文件系统

增加卷组

[root@SpecialProtocol root]# pvcreate /dev/sda3pvcreate — physical volume “/dev/sda3” successfully created[root@SpecialProtocol root]# vgextend test /dev/sda3vgextend — INFO: maximum logical volume size is 2 Terabytevgextend — doing automatic backup of volume group “test”vgextend — volume group “test” successfully extended增长逻辑卷

[root@SpecialProtocol root]# lvextend -L+300G /dev/test/lgdisklvextend — extending logical volume “/dev/test/lgdisk” to 606 GBlvextend — doing automatic backup of volume group “test”lvextend — logical volume “/dev/test/lgdisk” successfully extended增长文件系统(对ext2,ext3文件有效)

[root@SpecialProtocol root]# e2fsck -f /dev/test/lgdiske2fsck 1.32 (09-Nov-2002)Pass 1: Checking inodes, blocks, and sizesPass 2: Checking directory structurePass 3: Checking directory connectivity/lost+found not found. Create<y>? yes

Pass 4: Checking reference countsPass 5: Checking group summary information

/dev/test/lgdisk: ***** FILE SYSTEM WAS MODIFIED *****/dev/test/lgdisk: 257/40108032 files (0.0% non-contiguous), 6761839/80216064 blocks[root@SpecialProtocol root]# resize2fs /dev/test/lgdiskresize2fs 1.32 (09-Nov-2002)The filesystem on /dev/test/lgdisk is now 158859264 blocks long.mount文件系统,就可以使用了

mount /dev/test/lgdisk /mnt配置文件/etc/lvmconf/ ./etc/lvmtab.d/ , /etc/lvmtab

本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/ufwt/archive/2006/11/27/1417179.aspx

不知道来年,会不会开出一地的记忆和忧愁。

Linux LVM(Logical Volume Manager)

相关文章:

你感兴趣的文章:

标签云: