假设有3个disk 分区(/dev/sda1,/dev/sda2,/dev/sda3),先用2个做一个logical volume,在上面分一个区出来,然后假设这个区数据满了,把另外一个disk 分区弄上去,不丢数据
-
把/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): t Partition number (1-4): 1 Hex code (type L to list codes): 8e Changed 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 created pvcreate -- physical volume "/dev/sda2" successfully created
-
把物理卷加到卷组
[root@SpecialProtocol root]# vgcreate test /dev/sda1 /dev/sda2 vgcreate -- INFO: using default physical extent size 32 MB vgcreate -- INFO: maximum logical volume size is 2 Terabyte vgcreate -- 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 test VG Access read/write VG Status available/resizable VG # 0 MAX LV 256 Cur LV 0 Open LV 0 MAX LV Size 2 TB Max PV 256 Cur PV 2 Act PV 2 VG Size 306.31 GB PE Size 32 MB Total PE 9802 Alloc PE / Size 0 / 0 Free PE / Size 9802 / 306.31 GB VG UUID 6v7zQA-H22c-AeQ3-1wN1-KBV9-ByZd-LJfllT --- No logical volumes defined in "test" --- --- Physical volumes --- PV Name (#) /dev/sda1 (1) PV Status available / allocatable Total PE / Free PE 4901 / 4901 PV Name (#) /dev/sda2 (2) PV Status available / allocatable Total PE / Free PE 4901 / 4901
-
建立逻辑卷
[root@SpecialProtocol root]# lvcreate -L 306G -n lgdisk test lvcreate -- doing automatic backup of "test" lvcreate -- logical volume "/dev/test/lgdisk" successfully created
-
建立文件系统
mkfs -t ext3 /dev/test/lgdisk
-
mount 文件系统就可以用了
[root@SpecialProtocol root]# mount /dev/test/lgdisk /mnt
过一段时间后,/dev/test/lgdisk满了,把/dev/sda3加上去用
如果卷组有多的空间,直接调用e2fsadm就可以了,下面我们做的事情是假设要加一个硬盘上去
-
umount 文件系统
-
增加卷组
[root@SpecialProtocol root]# pvcreate /dev/sda3 pvcreate -- physical volume "/dev/sda3" successfully created
[root@SpecialProtocol root]# vgextend test /dev/sda3 vgextend -- INFO: maximum logical volume size is 2 Terabyte vgextend -- doing automatic backup of volume group "test" vgextend -- volume group "test" successfully extended
-
增长逻辑卷
[root@SpecialProtocol root]# lvextend -L+300G /dev/test/lgdisk lvextend -- extending logical volume "/dev/test/lgdisk" to 606 GB lvextend -- doing automatic backup of volume group "test" lvextend -- logical volume "/dev/test/lgdisk" successfully extended
-
增长文件系统(对ext2,ext3文件有效)
[root@SpecialProtocol root]# e2fsck -f /dev/test/lgdisk e2fsck 1.32 (09-Nov-2002) Pass 1: Checking inodes, blocks, and sizes Pass 2: Checking directory structure Pass 3: Checking directory connectivity /lost+found not found. Create<y>? yes Pass 4: Checking reference counts Pass 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/lgdisk resize2fs 1.32 (09-Nov-2002) The filesystem on /dev/test/lgdisk is now 158859264 blocks long.
-
mount文件系统,就可以使用了
mount /dev/test/lgdisk /mnt