::香农::青岛数据恢复中心::
作者:香农青岛数据恢复中心 2013-07-31 14:56
VPS空间原来为10G,现在升级为20G。使用LVM进行在线扩容。
[root@localhost dev]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
7.7G 2.8G 4.5G 38% /
/dev/hdd1 99M 22M 73M 23% /boot
tmpfs 252M 0 252M 0% /dev/shm
[root@localhost dev]# fdisk -l
Disk /dev/hdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 * 1 13 104391 83 Linux
/dev/hdd2 14 1305 10377990 8e Linux LVM
01. 首先分区格式化
[root@localhost dev]# fdisk /dev/hdd
The number of cylinders for this disk is set to 2610.
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): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 3
First cylinder (1306-2610, default 1306):
Using default value 1306
Last cylinder or +size or +sizeM or +sizeK (1306-2610, default 2610):
Using default value 2610
更改分区类型为LVM分区
Command (m for help): t
Partition number (1-4): 3
Hex code (type L to list codes): 8e
Changed system type of partition 3 to 8e (Linux LVM)
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
WARNING: Re-reading the partition table failed with error 16: 设备或资源忙.
The kernel still uses the old table.
The new table will be used at the next reboot.
Syncing disks.
[root@localhost dev]# fdisk -l
Disk /dev/hdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 * 1 13 104391 83 Linux
/dev/hdd2 14 1305 10377990 8e Linux LVM
/dev/hdd3 1306 2610 10482412+ 8e Linux LVM
02. 重启VPS服务器
[root@localhost dev]#reboot
重启后新建的分区已可用
root@localhost ~]# df
文件系统 1K-块 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
7998912 2880284 4705752 38% /
/dev/hdd1 101086 21949 73918 23% /boot
tmpfs 257404 0 257404 0% /dev/shm
[root@localhost ~]# fdisk -l
Disk /dev/hdd: 21.4 GB, 21474836480 bytes
255 heads, 63 sectors/track, 2610 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/hdd1 * 1 13 104391 83 Linux
/dev/hdd2 14 1305 10377990 8e Linux LVM
/dev/hdd3 1306 2610 10482412+ 8e Linux LVM
03.把新建的分区加入LVM中去
1.建立物理卷
[root@localhost ~]# pvcreate /dev/hdd3
Physical volume "/dev/hdd3" successfully created
2.把新建物理卷加入卷组中去
[root@localhost ~]# vgextend VolGroup00 /dev/hdd3
Volume group "VolGroup00" successfully extended
3.把新的空间加入逻辑卷中去
[root@localhost ~]# lvextend -L +10G /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 17.88 GB
Insufficient free space: 320 extents needed, but only 319 available
用LE数扩展
[root@localhost ~]# lvextend -l +319 /dev/VolGroup00/LogVol00
Extending logical volume LogVol00 to 17.84 GB
Logical volume LogVol00 successfully resized
4.激活,在线调整容量
[root@localhost ~]# resize2fs -p /dev/VolGroup00/LogVol00
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/LogVol00 is mounted on /; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/LogVol00 to 4677632 (4k) blocks.
The filesystem on /dev/VolGroup00/LogVol00 is now 4677632 blocks long.
04.扩容结束
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/VolGroup00-LogVol00
18G 2.8G 14G 17% /
/dev/hdd1 99M 22M 73M 23% /boot
tmpfs 252M 0 252M 0% /dev/shm
[root@localhost ~]# pvdisplay
--- Physical volume ---
PV Name /dev/hdd2
VG Name VolGroup00
PV Size 9.90 GB / not usable 22.76 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 316
Free PE 0
Allocated PE 316
PV UUID SFuI4R-VBNx-sJjp-IJlQ-oSh8-zQY1-Enq3G2
--- Physical volume ---
PV Name /dev/hdd3
VG Name VolGroup00
PV Size 10.00 GB / not usable 28.73 MB
Allocatable yes (but full)
PE Size (KByte) 32768
Total PE 319
Free PE 0
Allocated PE 319
PV UUID 0F7NZB-r0kf-mK4L-6wLO-z8qE-K0Y0-M3OJz0
[root@localhost ~]#