Use LVM to increase linux root partitions in VMware

Source: Internet
Author: User

Recently, when xen was installed on the virtual cent OS in VMware, after more than an hour of installation, make said that the disk space was insufficient and unexpectedly exited, Which is depressing. At this time, there are only two solutions: 1. Check whether VMware can change the hard disk size; 2. Use VMware to add a hard disk to the virtual machine operating system. Both methods can increase the disk capacity. After increasing the disk capacity, consider how to change the partition size.
The hard disk size of the guest operating system cannot be changed on the VMware graphic interface. Go to the installation directory of VMware in the command line and findProgramVmware-vdiskmanager.exe, its help shows what it can do. I searched the internet and used this tool to change the disk capacity. So:
D: \ Program Files \ VMware Workstation> vmware-vdiskmanager.exe-x 10 Gb "E: \ c
Ent OS \ cent OS. vmdk"

Grow: 100% done.
Disk expansion completed successfully.

Warning: If the virtual disk is partitioned, you must use a third-party
Utility in the virtual machine to expand the size of
Partitions. For more information, see:
Http://www.vmware.com/support/kb/enduser/std_adp.php? P_faqid = 1647

Then I began to find out how to change the partition size in Linux on the Internet. While reading documents and practices on the Internet, this process lasted for several hours and found many LVM documents, but it was also depressing to find that, the increased hard disk capacity is invisible to the guest operating system, and cannot be seen even.
I had to use the second method. The LVM documentation on the Internet also expanded the partition capacity when a hard disk was added. First use the vmware-vdiskmanager.exe to increase the disk capacity shrink back.
D: \ Program Files \ VMware Workstation> vmware-vdiskmanager.exe-k "E: \ cent o
S \ cent OS. vmdk"

Disable the guest operating system. In VMware, set the edit Vm and click Add to add a SCSI hard disk. Restart.
[Root @ jcwkyl ~] # Cd/dev
[Root @ jcwkyl Dev] # ls SD *

SDA sda1 sda2 SDB

This SDB is the newly added SCSI hard disk. Then:
[Root @ jcwkyl Dev] # LVM
LVM> pvcreate/dev/SDB
LVM> vgdisplay

--- Volume group ---
VG name volgroup00
System ID
Format lvm2
Metadata areas 2
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 2
Act PV 2
......

View the information of the volume group. Then:
LVM> vgextend volgroup00/dev/SDB
LVM> vgdisplay
At this time, we can see that the volgroup00 capacity has changed to 10.84 GB.
LVM> pvdisplay

--- Physical volume ---
PV name/dev/sda2
VG name volgroup00
PV size 5.90 GB/not usable 24.06 MB
Allocatable Yes (but full)
PE size (Kbytes) 32768
Total PE 188
Free pe 0
Allocated PE 188.
Pvuuid pCjs4H-Xygt-K332-rwkQ-sXwN-2LhC-MJkcw3

--- Physical volume ---
PV name/dev/SDB
VG name volgroup00
PV size 5.00 GB/not usable 32.00 MB
Allocatable Yes
PE size (Kbytes) 32768
Total PE 159
Free PE 15
Allocated PE 144.
Pv uuid 5l1qpe-ko2j-2myz-qn09-zxxr-1pwj-sc5dlr

LVM> lvdisplay

--- Logical volume ---
LV name/dev/volgroup00/logvol00
VG name volgroup00
Lv uuid 2rljvw-zmfe-daq9-erie-orze-gvhw-akzpsj
LV write access read/write
LV status available
# Open 1
LV size 4.88 GB
Current le 300
Segments 2
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Block device 253: 0

--- Logical volume ---
LV name/dev/volgroup00/logvol01
VG name volgroup00
Lvuuid Nx0PK2-Vb7Y-7YXe-Skd6-FCRD-xPI7-YJLjfZ
LV write access read/write
LV status available
# Open 1
LV size 1.00 GB
Current le 32
Segments 1
Allocation inherit
Read ahead sectors auto
-Currently sets to 256
Blocks device 253: 1

LVM & gt; lvextend-L + 4.5g/dev/volgroup00/logvol00
At the beginning, it was 5 GB, but the space was not enough. Therefore, it was changed to 4.5 GB.
LVM> quit
[Root @ jcwkyl Dev] # e2fsck-F/dev/volgroup00/logvol00
[Root @ jcwkyl Dev] # resize2fs/dev/volgroup00/logvol00
Now:
[Root @ jcwkyl Dev] # DF-H

filesystem size used avail use % mounted on
/dev/mapper/VolGroup00-LogVol00
9.1g 2.8g 5.9g 33%/
/dev/sda1 99 m 12 m 82 m 13%/boot
tmpfs 189 M 0 189 m 0%/dev/SHM

The above output is lengthy, because the first time LVM is used, it is updated. In general, the command used is:
To use LVM, initialize a physical volumn:
Pvcreate/dev/SDB
Then add it to the volume group:
Vgextend volgroup00/dev/SDB
The volume group name is displayed through vgdisplay. These commands are very useful: fdisk, parted, mkfs. ext3, DF, mount, and/etc/fstab files.
After successfully joining the volume group, expand the capacity of the logical volume. The logical volume is the partition mounted to/. You can see through Mount:
Lvextend-L + 4.5g/dev/volgroup00/logvol00
The last two commands are as follows:
E2fsck-F/dev/volgroup00/logvol00
Resize2fs/dev/volgroup00/logvol00

This article from the csdn blog, reproduced please indicate the source: http://blog.csdn.net/jcwkyl/archive/2009/07/25/4380290.aspx

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.