How do I extend a sda2 to sda3 hosted on VMWare.

Latest response

I have a redhat enterprise linux hosted on Exsi Sphere VMware.

On VMWare I expanded the hard drive from 20gig to 100gig.
However after I power up the server it has now one additional partition. On this partition is not currently format but on the terminal indicated sda3, so I just want to extended but in the internet are various examples and but creates errors and I can not extend the sda2. could someone help me by putting step by step instructions.

Thank you.

Responses

Extending a VMware virtual disk typically won't automatically create a new partition in the added space, just more unallocated space on the virtual disk. I would be very suspicious of a new partition device appearing without using fdisk, parted or a similar partitioning tool. Or perhaps you're omitting some important details here?

If your existing system is using LVM (which is likely if you only had sda1 and sda2 before), you'll need to know the name of your system volume group. That's easiest to achieve using the pvs or vgs commands. Example:

# pvs
  PV        VG    Fmt  Attr PSize   PFree  
  /dev/sda3 vgsys lvm2 a--  476.20g 136.94g

In this example, the existing partition is /dev/sda3 and the name of the LVM volume group on it is vgsys. In your case it might be different.

The vgs command would list all the VGs on the system, but would not indicate which disk(s) hold each of them.

# vgs
  VG    #PV #LV #SN Attr   VSize   VFree  
  vgsys   1   5   0 wz--n- 476.20g 136.94g

If the pvs and vgs commands output only the title line, then you are not using LVM and the virtual disk contains plain old partitions. Those are a bit more tricky to extend, and extending a partition that contains a filesystem that cannot be unmounted may require a reboot.

The procedure if you are using LVM:

If you are certain that /dev/sda3 exists as a partition and is currently unused, the first step would be to initialize it as a LVM PV (physical volume). That can be done with pvcreate /dev/sda3. After this, you can run the pvs command again: if successful, then /dev/sda3 will appear as a new PV with no VG assignment yet, and with PFree value equal to its PSize (= it is completely unused). If the pvcreate command reports an error, the partition might be already in use: please check carefully to verify you aren't overwriting an existing filesystem.

The next step would be to add this new PV to your existing VG. Here you will need the name of your VG. For example, to add /dev/sda3 to VG named "vgsys", the command would be: vgextend vgsys /dev/sda3. If this command is successful, then the pvs command will now show this PV assigned to the VG, and the vgs command will show increased VSize and VFree values.

Now the added disk space is available within your LVM volume group, but you'll want to add it - or at least some of it - into one or more filesystems. In RHEL 6+, there's the lvresize command that can extend both the LV and the filesystem inside it as a single operation. For example, if your filesystem device is /dev/mapper/vgsys-root, then the command to extend it by 50 gigabytes would be:

# lvresize -r -L +50G /dev/mapper/vgsys-root

This can be done while the system is running, and won't require a reboot.

On RHEL 5.x and older, you would have to do it in two steps: first extend the LV, and then the filesystem inside it using a filesystem-specific command:

# lvextend -L +50G /dev/mapper/vgsys-root
then
# resize2fs /dev/mapper/vgsys-root
or 
# xfs_growfs / 

Note that xfs_growfs takes as parameter the filesystem mount point, not the disk device name.

Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.