操作环境:
[root@zwf ~]# uname -a
Linux zwf 2.6.32-504.16.2.el6.x86_64 #1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@zwf ~]# cat /etc/issue
CentOS release 6.6 (Final)
Kernel \r on an \m
[root@zwf ~]#
1
2
3
4
5
6
7
[root@zwf~]# uname -a
Linuxzwf2.6.32-504.16.2.el6.x86_64#1 SMP Wed Apr 22 06:48:29 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@zwf~]# cat /etc/issue
CentOSrelease6.6(Final)
Kernel\ronan\m
[root@zwf~]#
扩容前,服务器磁盘分区情况:
[root@zwf ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 3.4G 13G 21% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/xvda1 477M 52M 400M 12% /boot
1
2
3
4
5
6
[root@zwf~]# df -h
FilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
18G3.4G13G21%/
tmpfs3.9G03.9G0%/dev/shm
/dev/xvda1477M52M400M12%/boot
可以看到跟目录只有18个G的大小,现在增加一块磁盘100G:
[root@zwf ~]# fdisk -l
Disk /dev/xvdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 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: 0x3f057d6e
Device Boot Start End Blocks Id System
/dev/xvdb1 1 13054 104856223+ 83 Linux
Disk /dev/xvda: 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: 0x0002051c
Device Boot Start End Blocks Id System
/dev/xvda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/xvda2 64 2611 20458496 8e Linux LVM
Disk /dev/mapper/VolGroup-lv_root: 18.8 GB, 18798870528 bytes
255 heads, 63 sectors/track, 2285 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: 0x00000000
Disk /dev/mapper/VolGroup-lv_swap: 2147 MB, 2147483648 bytes
255 heads, 63 sectors/track, 261 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: 0x00000000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
[root@zwf~]# fdisk -l
Disk/dev/xvdb:107.4GB,107374182400bytes
255heads,63sectors/track,13054cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x3f057d6e
DeviceBootStartEndBlocksIdSystem
/dev/xvdb1113054104856223+83Linux
Disk/dev/xvda:21.5GB,21474836480bytes
255heads,63sectors/track,2610cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x0002051c
DeviceBootStartEndBlocksIdSystem
/dev/xvda1 *16451200083Linux
Partition1doesnotendoncylinderboundary.
/dev/xvda2642611204584968eLinuxLVM
Disk/dev/mapper/VolGroup-lv_root:18.8GB,18798870528bytes
255heads,63sectors/track,2285cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x00000000
Disk/dev/mapper/VolGroup-lv_swap:2147MB,2147483648bytes
255heads,63sectors/track,261cylinders
Units=cylindersof16065*512=8225280bytes
Sectorsize(logical/physical):512bytes/512bytes
I/Osize(minimum/optimal):512bytes/512bytes
Diskidentifier:0x00000000
/dev/xvdb1 就是新增的磁盘,已经分区并格式化,还没有挂载,给此磁盘添加物理卷:
[root@zwf ~]# pvcreate /dev/xvdb1
Physical volume "/dev/xvdb1" successfully created
1
2
[root@zwf~]# pvcreate /dev/xvdb1
Physicalvolume"/dev/xvdb1"successfullycreated
查看当前服务器物理卷(PV)的情况:
[root@zwf ~]# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name VolGroup
PV Size 19.51 GiB / not usable 3.00 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 4994
Free PE 0
Allocated PE 4994
PV UUID QKYKlh-t5DO-1gFR-QZrl-I3iB-NbP2-IkvyHa
"/dev/xvdb1" is a new physical volume of "100.00 GiB"
--- NEW Physical volume ---
PV Name /dev/xvdb1
VG Name
PV Size 100.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID lodesI-sjY8-K3Bo-ZzCz-ghQq-24rg-ITlzXm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
[root@zwf~]# pvdisplay
---Physicalvolume---
PVName/dev/xvda2
VGNameVolGroup
PVSize19.51GiB/notusable3.00MiB
Allocatableyes(butfull)
PESize4.00MiB
TotalPE4994
FreePE0
AllocatedPE4994
PVUUIDQKYKlh-t5DO-1gFR-QZrl-I3iB-NbP2-IkvyHa
"/dev/xvdb1"isanewphysicalvolumeof"100.00 GiB"
---NEWPhysicalvolume---
PVName/dev/xvdb1
VGName
PVSize100.00GiB
AllocatableNO
PESize0
TotalPE0
FreePE0
AllocatedPE0
PVUUIDlodesI-sjY8-K3Bo-ZzCz-ghQq-24rg-ITlzXm
可以看到新添加的物理卷/dev/xvdb1,大小为100G,查看当前卷组情况:
[root@zwf ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 3
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 1
Act PV 1
VG Size 19.51 GiB
PE Size 4.00 MiB
Total PE 4994
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 0 / 0
VG UUID V6yHrx-YXrI-q6gb-fg51-ECNZ-cnE3-Oj0lNf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@zwf~]# vgdisplay
---Volumegroup---
VGNameVolGroup
SystemID
Formatlvm2
MetadataAreas1
MetadataSequenceNo3
VGAccessread/write
VGStatusresizable
MAXLV0
CurLV2
OpenLV2
MaxPV0
CurPV1
ActPV1
VGSize19.51GiB
PESize4.00MiB
TotalPE4994
AllocPE/Size4994/19.51GiB
FreePE/Size0/0
VGUUIDV6yHrx-YXrI-q6gb-fg51-ECNZ-cnE3-Oj0lNf
将分区/dev/xvdb1转换为扩展分区:
[root@zwf ~]# vgextend VolGroup /dev/xvdb1
Volume group "VolGroup" successfully extended
1
2
[root@zwf~]# vgextend VolGroup /dev/xvdb1
Volumegroup"VolGroup"successfullyextended
查看逻辑卷:
[root@zwf ~]# lvdisplay
--- Logical volume ---
LV Path /dev/VolGroup/lv_root
LV Name lv_root
VG Name VolGroup
LV UUID YCl5Qf-H6rc-xIw1-0DCL-csgP-6jRV-J8wPzR
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-06-05 14:15:42 +0800
LV Status available
# open 1
LV Size 17.51 GiB
Current LE 4482
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:0
--- Logical volume ---
LV Path /dev/VolGroup/lv_swap
LV Name lv_swap
VG Name VolGroup
LV UUID YZbRLA-gCBf-hPtV-mryG-szfu-j8i4-ulbcHj
LV Write Access read/write
LV Creation host, time localhost.localdomain, 2015-06-05 14:15:47 +0800
LV Status available
# open 1
LV Size 2.00 GiB
Current LE 512
Segments 1
Allocation inherit
Read ahead sectors auto
- currently set to 256
Block device 253:1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
[root@zwf~]# lvdisplay
---Logicalvolume---
LVPath/dev/VolGroup/lv_root
LVNamelv_root
VGNameVolGroup
LVUUIDYCl5Qf-H6rc-xIw1-0DCL-csgP-6jRV-J8wPzR
LVWriteAccessread/write
LVCreationhost,timelocalhost.localdomain,2015-06-0514:15:42+0800
LVStatusavailable
# open 1
LVSize17.51GiB
CurrentLE4482
Segments1
Allocationinherit
Readaheadsectorsauto
-currentlysetto256
Blockdevice253:0
---Logicalvolume---
LVPath/dev/VolGroup/lv_swap
LVNamelv_swap
VGNameVolGroup
LVUUIDYZbRLA-gCBf-hPtV-mryG-szfu-j8i4-ulbcHj
LVWriteAccessread/write
LVCreationhost,timelocalhost.localdomain,2015-06-0514:15:47+0800
LVStatusavailable
# open 1
LVSize2.00GiB
CurrentLE512
Segments1
Allocationinherit
Readaheadsectorsauto
-currentlysetto256
Blockdevice253:1
这里可以看到根分区的路径为:/dev/VolGroup/lv_root,查看扩展后的卷组情况
[root@zwf ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 2
Open LV 2
Max PV 0
Cur PV 2
Act PV 2
VG Size 119.50 GiB
PE Size 4.00 MiB
Total PE 30593
Alloc PE / Size 4994 / 19.51 GiB
Free PE / Size 25599 / 100.00 GiB
VG UUID V6yHrx-YXrI-q6gb-fg51-ECNZ-cnE3-Oj0lNf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
[root@zwf~]# vgdisplay
---Volumegroup---
VGNameVolGroup
SystemID
Formatlvm2
MetadataAreas2
MetadataSequenceNo4
VGAccessread/write
VGStatusresizable
MAXLV0
CurLV2
OpenLV2
MaxPV0
CurPV2
ActPV2
VGSize119.50GiB
PESize4.00MiB
TotalPE30593
AllocPE/Size4994/19.51GiB
FreePE/Size25599/100.00GiB
VGUUIDV6yHrx-YXrI-q6gb-fg51-ECNZ-cnE3-Oj0lNf
此时还没刷新根分区大小,看到的分区还没有添加
[root@zwf ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
18G 3.4G 13G 21% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/xvda1 477M 52M 400M 12% /boot
1
2
3
4
5
6
[root@zwf~]# df -h
FilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
18G3.4G13G21%/
tmpfs3.9G03.9G0%/dev/shm
/dev/xvda1477M52M400M12%/boot
刷新根分区大小:
[root@zwf ~]# lvextend -L +99.99G /dev/VolGroup/lv_root
Rounding size to boundary between physical extents: 99.99 GiB
Size of logical volume VolGroup/lv_root changed from 17.51 GiB (4482 extents) to 117.50 GiB (30080 extents).
Logical volume lv_root successfully resized
[root@zwf ~]# e2fsck -f /dev/VolGroup/lv_root
e2fsck 1.41.12 (17-May-2010)
/dev/VolGroup/lv_root is mounted.
e2fsck: Cannot continue, aborting.
1
2
3
4
5
6
7
8
[root@zwf~]# lvextend -L +99.99G /dev/VolGroup/lv_root
Roundingsizetoboundarybetweenphysicalextents:99.99GiB
SizeoflogicalvolumeVolGroup/lv_rootchangedfrom17.51GiB(4482extents)to117.50GiB(30080extents).
Logicalvolumelv_rootsuccessfullyresized
[root@zwf~]# e2fsck -f /dev/VolGroup/lv_root
e2fsck1.41.12(17-May-2010)
/dev/VolGroup/lv_rootismounted.
e2fsck:Cannotcontinue,aborting.
命令resize2fs即刷新根分区“/dev/VolGroup/lv_root”的容量,再次查看次磁盘分区情况
[root@zwf ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
116G 3.4G 107G 4% /
tmpfs 3.9G 0 3.9G 0% /dev/shm
/dev/xvda1 477M 52M 400M 12% /boot
1
2
3
4
5
6
[root@zwf~]# df -h
FilesystemSizeUsedAvailUse%Mountedon
/dev/mapper/VolGroup-lv_root
116G3.4G107G4%/
tmpfs3.9G03.9G0%/dev/shm
/dev/xvda1477M52M400M12%/boot
添加分区成功。
转载请注明: 版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
最后编辑:2015-12-09作者:Jerry
一个积极向上的小青年,热衷于分享--Focus on DB,BI,ETL