标签:
While i am using VMWARE, i use thin mode for harddisk. But as i only allocate 40G for each VM, soon i find the disk is short of size.
Do i need to rebuilt VM or have some easy way to go?
First, i tried to add space to VM. But soon i find failed. As the size can only be recognized as a new space in the disk, i need to add the spare space to one partion.
Luckly i find the partion i want to add with new space is LVM.
Below is steps for this:
1. Create partion for new space
[root@localhost ~]# fdisk /dev/sda
Command (m for help): n
First cylinder (1160-1305, default 1160):1160
Last cylinder or +size or +sizeM or +sizeK(1160-1305, default 1305): 1305
Command (m for help): p
Disk /dev/sda: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 395 3068415 8e Linux LVM
/dev/sda3 396 777 3068415 8e Linux LVM
/dev/sda4 778 1305 4241160 5 Extended
/dev/sda5 778 1159 3068383+ 8e Linux LVM
/dev/sda6 1160 1305 1172713+ 83 Linux \\the new partion
Command (m for help): t \\change partion to LVM
Partition number (1-6): 6
Hex code (type L to list codes): 8e
Changed system type of partition 6 to 8e(Linux LVM)
Command (m for help): w
The partition table has been altered!
OK here i find needs to reboot the linux, otherwise the pvcreate may failed. Is there any good solution for this? I do not know
[root@localhost ~]# pvcreate /dev/sda6 \\create new PV
Physical volume "/dev/sda6" successfully created
[root@localhost ~]# pvscan
PV/dev/sda2 VG rootvg lvm2 [2.93 GB / 0 free]
PV/dev/sda3 VG rootvg lvm2 [2.93 GB / 0 free]
PV/dev/sda5 VG rootvg lvm2 [2.93 GB / 0 free]
PV /dev/sda6 lvm2[1.12 GB] \\newed pv
Total: 4 [9.90 GB] / in use: 3 [8.78 GB] / in no VG: 1 [1.12 GB]
3、Add pv to vg
[root@localhost ~]# vgextend rootvg/dev/sda6
Volume group "rootvg" successfully extended
[root@localhost ~]# pvscan
PV/dev/sda2 VG rootvg lvm2 [2.93 GB / 0 free]
PV/dev/sda3 VG rootvg lvm2 [2.93 GB / 0 free]
PV/dev/sda5 VG rootvg lvm2 [2.93 GB / 0 free]
PV /dev/sda6 VG rootvg lvm2 [1.12 GB / 1.12 GB free]
Total: 4 [9.89 GB] / in use: 4 [9.89 GB] / in no VG: 0 [0 ]
4、LV extend
[root@localhost ~]# lvextend -L +100M/dev/rootvg/homelv
Extending logical volume homelv to 612.00 MB
Logical volume homelv successfully resized
5、using resize2fs
[root@localhost ~]# resize2fs/dev/rootvg/homelv
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/rootvg/homelv is mountedon /home; on-line resizing required
Performing an on-line resize of/dev/rootvg/homelv to 626688 (1k) blocks.
The filesystem on /dev/rootvg/homelv is now626688 blocks long.
[root@localhost ~]# df -h
文件系统 容量 已用 可用 已用% 挂载点
/dev/mapper/rootvg-rootlv
7.6G 2.0G 5.2G 28% /
/dev/sda1 99M 11M 83M 12% /boot
tmpfs 125M 0 125M 0% /dev/shm
/dev/mapper/rootvg-homelv
593M 19M 544M 4% /home
标签:
原文地址:http://www.cnblogs.com/leon-zhu/p/4285617.html