前言:
挂载在 / 目录的/dev/mapper/VolGroup-lv_root卷空间不够了,需要扩容。
df -h 查看 / 只有14G 太小了
-
[root@ip-172-30-0-175 pcre-8.40]# df -h
-
Filesystem Size Used Avail Use% Mounted on
-
/dev/mapper/VolGroup-lv_root
-
14G 5.6G 7.3G 44% /
-
tmpfs 7.8G 0 7.8G 0% /dev/shm
-
/dev/xvda1 485M 54M 407M 12% /boot
fdisk 查看剩余空间,/dev/xvda 还有一百多G可用
-
[root@ip-172-30-0-175 pcre-8.40]# fdisk -l
-
-
Disk /dev/xvda: 214.7 GB, 214748364800 bytes
-
255 heads, 63 sectors/track, 26108 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: 0x000eacf6
-
-
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 1958 15214611 83 Linux
-
-
Disk /dev/mapper/VolGroup-lv_root: 14.7 GB, 14722007040 bytes
-
255 heads, 63 sectors/track, 1789 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: 855 MB, 855638016 bytes
-
255 heads, 63 sectors/track, 104 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
fdisk 创建分区,pvcreate 创建物理卷
-
[root@ip-172-30-0-175 pcre-8.40]# fdisk /dev/xvda
-
-
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
-
switch off the mode (command 'c') and change display units to
-
sectors (command 'u').
-
-
Command (m for help): m
-
Command action
-
a toggle a bootable flag
-
b edit bsd disklabel
-
c toggle the dos compatibility flag
-
d delete a partition
-
l list known partition types
-
m print this menu
-
n add a new partition
-
o create a new empty DOS partition table
-
p print the partition table
-
q quit without saving changes
-
s create a new empty Sun disklabel
-
t change a partition's system id
-
u change display/entry units
-
v verify the partition table
-
w write table to disk and exit
-
x extra functionality (experts only)
-
-
Command (m for help): p
-
-
Disk /dev/xvda: 214.7 GB, 214748364800 bytes
-
255 heads, 63 sectors/track, 26108 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: 0x000eacf6
-
-
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 1958 15214611 83 Linux
-
-
Command (m for help): n
-
Command action
-
e extended
-
p primary partition (1-4)
-
p
-
Partition number (1-4): 3
-
First cylinder (1959-26108, default 1959):
-
Using default value 1959
-
Last cylinder, +cylinders or +size{K,M,G} (1959-26108, default 26108):
-
Using default value 26108
-
-
Command (m for help): w
-
The partition table has been
-
-
Calling ioctl() to re-read partition table.
-
-
WARNING: Re-reading the partition table failed with error 16: Device or resource busy.
-
The kernel still uses the old table. The new table will be used at
-
the next reboot or after you run partprobe(8) or kpartx(8)
-
Syncing disks.
fdisk -l 查看分区
-
[root@ip-172-30-0-175 ~]# fdisk -l
-
-
Disk /dev/xvda: 214.7 GB, 214748364800 bytes
-
255 heads, 63 sectors/track, 26108 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: 0x000eacf6
-
-
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 1958 15214611 83 Linux
-
/dev/xvda3 1959 26108 193984875 83 Linux
-
-
Disk /dev/mapper/VolGroup-lv_root: 14.7 GB, 14722007040 bytes
-
255 heads, 63 sectors/track, 1789 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: 855 MB, 855638016 bytes
-
255 heads, 63 sectors/track, 104 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
pvdisplay 查看物理卷
-
[root@ip-172-30-0-175 ~]# pvdisplay
-
--- Physical volume ---
-
PV Name /dev/xvda2
-
VG Name VolGroup
-
PV Size 14.51 GiB / not usable 1.02 MiB
-
Allocatable yes (but full)
-
PE Size 4.00 MiB
-
Total PE 3714
-
Free PE 0
-
Allocated PE 3714
-
PV UUID kbUoQF-zSiv-IwgC-3OtP-JbIV-9SXR-oPWJef
vgdisplay 查看逻辑卷组
-
[root@ip-172-30-0-175 ~]# vgdisplay
-
--- Volume group ---
-
VG Name VolGroup
-
System ID
-
Format lvm2
-
Metadata Areas 1
-
Metadata Sequence No 5
-
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 14.51 GiB
-
PE Size 4.00 MiB
-
Total PE 3714
-
Alloc PE / Size 3714 / 14.51 GiB
-
Free PE / Size 0 / 0
-
VG UUID lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk
-
[root@ip-172-30-0-175 ~]# vgdisplay
-
--- Volume group ---
-
VG Name VolGroup
-
System ID
-
Format lvm2
-
Metadata Areas 1
-
Metadata Sequence No 5
-
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 14.51 GiB
-
PE Size 4.00 MiB
-
Total PE 3714
-
Alloc PE / Size 3714 / 14.51 GiB
-
Free PE / Size 0 / 0
-
VG UUID lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk
lvdispaly 查看逻辑卷
-
[root@ip-172-30-0-175 ~]# lvdisplay
-
--- Logical volume ---
-
LV Path /dev/VolGroup/lv_root
-
LV Name lv_root
-
VG Name VolGroup
-
LV UUID tYQ8YA-ImhM-NLo8-HgVj-6snL-8qgS-32YBNi
-
LV Write Access read/write
-
LV Creation host, time localhost.localdomain, 2014-04-08 02:10:19 +0000
-
LV Status available
-
# open 1
-
LV Size 13.71 GiB
-
Current LE 3510
-
Segments 2
-
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 PF53Ol-MDZF-nWZb-jJeG-WIHZ-GFQJ-HvKKM5
-
LV Write Access read/write
-
LV Creation host, time localhost.localdomain, 2014-04-08 02:10:20 +0000
-
LV Status available
-
# open 1
-
LV Size 816.00 MiB
-
Current LE 204
-
Segments 1
-
Allocation inherit
-
Read ahead sectors auto
-
- currently set to 256
-
Block device 253:1
让分区生效
pvcreate 创建物理卷
-
[root@ip-172-30-0-175 ~]# partx -a /dev/xvda
-
[root@ip-172-30-0-175 ~]# partx -a /dev/xvda3 /dev/xvda
-
[root@ip-172-30-0-175 ~]# pvcreate /dev/xvda3
-
Physical volume "/dev/xvda3" successfully created
-
[root@ip-172-30-0-175 ~]# pvdisplay
--- Physical volume ---
PV Name /dev/xvda2
VG Name VolGroup
PV Size 14.51 GiB / not usable 1.02 MiB
Allocatable yes (but full)
PE Size 4.00 MiB
Total PE 3714
Free PE 0
Allocated PE 3714
PV UUID kbUoQF-zSiv-IwgC-3OtP-JbIV-9SXR-oPWJef
"/dev/xvda3" is a new physical volume of "185.00 GiB"
--- NEW Physical volume ---
PV Name /dev/xvda3
VG Name
PV Size 185.00 GiB
Allocatable NO
PE Size 0
Total PE 0
Free PE 0
Allocated PE 0
PV UUID b7Ykqm-c3ra-sAx7-srWW-kbT6-l4R1-R1cimn
将剩余空间都分配给 VolGroup 卷组
-
[root@ip-172-30-0-175 ~]# vgextend VolGroup /dev/xvda3
-
Volume group "VolGroup" successfully extended
-
[root@ip-172-30-0-175 ~]# vgdisplay
--- Volume group ---
VG Name VolGroup
System ID
Format lvm2
Metadata Areas 2
Metadata Sequence No 6
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 199.50 GiB
PE Size 4.00 MiB
Total PE 51073
Alloc PE / Size 3714 / 14.51 GiB
Free PE / Size 47359 / 185.00 GiB
VG UUID lvi8Kt-MMja-nTvI-terh-7ljb-ImyV-SScwRk
将卷组中的剩余空间都分配给/dev/VolGroup/lv_root 逻辑卷
-
[root@ip-172-30-0-175 ~]# lvextend -l +100%FREE /dev/VolGroup/lv_root
-
Extending logical volume lv_root to 198.71 GiB
-
Logical volume lv_root successfully resized
调整分区大小 resize2fs /dev/mapper/VolGroup-lv_root
-
[root@ip-172-30-0-175 ~]# resize2fs /dev/mapper/VolGroup-lv_root
-
resize2fs 1.41.12 (17-May-2010)
-
Filesystem at /dev/mapper/VolGroup-lv_root is mounted on /; on-line resizing required
-
old desc_blocks = 1, new_desc_blocks = 13
-
Performing an on-line resize of /dev/mapper/VolGroup-lv_root to 52089856 (4k) blocks.
-
The filesystem on /dev/mapper/VolGroup-lv_root is now 52089856 blocks long.
-
[root@ip-172-30-0-175 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root
196G 5.6G 181G 3% /
tmpfs 7.8G 0 7.8G 0% /dev/shm
/dev/xvda1 485M 54M 407M 12% /boot
可以看到
/dev/mapper/VolGroup-lv_root 的大小由14G变成196G了。
阅读(1551) | 评论(0) | 转发(0) |