Vmware disk increase extend

General support questions
Post Reply
gokhan76
Posts: 3
Joined: 2019/06/28 23:03:50

Vmware disk increase extend

Post by gokhan76 » 2019/06/28 23:07:07

Hi Guys,

I have a production server and I just extended the disk space.

I found out the Server already have 4 primary partitions.

What can I do at this stage?

Any reccomendations will be helpfull..

Thanks,

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Vmware disk increase extend

Post by TrevorH » 2019/06/28 23:53:11

Show the output from

fdisk -lu /dev/[vs]d[a-z]
pvs
vgs
lvs
df -h

All but the last need to be run as root.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

gokhan76
Posts: 3
Joined: 2019/06/28 23:03:50

Re: Vmware disk increase extend

Post by gokhan76 » 2019/06/29 02:12:52

# fdisk -lu /dev/[vs]d[a-z]

Disk /dev/sda: 751.6 GB, 751619276800 bytes, 1468006400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0000f3fa

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 1026047 512000 8e Linux LVM
/dev/sda2 1026048 167772159 83373056 8e Linux LVM
/dev/sda3 167772160 419430399 125829120 8e Linux LVM
/dev/sda4 419430400 734003199 157286400 8e Linux LVM
[root@siriusly ~]#


# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 centos lvm2 a-- 79.51g 64.00m
/dev/sda3 centos lvm2 a-- 120.00g 0
/dev/sda4 centos lvm2 a-- 150.00g 0
[root@siriusly ~]#


vgs
VG #PV #LV #SN Attr VSize VFree
centos 3 3 0 wz--n- 349.50g 64.00m
[root@siriusly ~]#

lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
home centos -wi-ao---- 173.48g
root centos -wi-ao---- 168.09g
swap centos -wi-ao---- 7.88g
[root@siriusly ~]#

df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root 169G 147G 23G 87% /
devtmpfs 32G 0 32G 0% /dev
tmpfs 32G 0 32G 0% /dev/shm
tmpfs 32G 177M 32G 1% /run
tmpfs 32G 0 32G 0% /sys/fs/cgroup
/dev/sda1 494M 125M 370M 26% /boot
/dev/mapper/centos-home 174G 23G 151G 13% /home
tmpfs 6.3G 0 6.3G 0% /run/user/48
tmpfs 6.3G 0 6.3G 0% /run/user/0
[root@siriusly ~]#

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: Vmware disk increase extend

Post by TrevorH » 2019/06/29 11:23:50

OK, so things are not completely at a dead end. You have used all 4 primary partition slots on the disk and you are using an msdos label on it so that's all you can have but your system is using LVM and 3 of the 4 primary partitions are in use as LVM PVs.

Other than removing the added space and then attaching a separate disk containing the new space, your only other solution is slightly (but not very) dangerous. You will need to remove the 4th partition and then recreate it, starting on the exact same sector as it does now. The data will be safe as long as you get it right but that's what backups are for... right?

So, run fdisk -u /dev/sda then use 'p' to print the existing partition table so you have it on screen in front of you.

Now use 'd' to delete a partition, tell it to remove 4 when it asks. Add a new partition and again it has to be primary and it'll have to be #4 as that's the only slot left for it (so it won't even ask). It'll ask for the starting sector number and then you must tell it that it is the exact same starting sector that it is listed as using when you printed the partition table. Assuming that your forum post is correct (check it against the actual output before you use it, just to be sure) then your recreated partition needs to start on sector 419430400. It'll ask what the ending sector should be and the default should be the last available sector on the disk which is where you want it to be.

Lastly, use 't' to tag partition #4 as type '8e' to match how it is now. That's all done, now use 'p' once more to print out what it looks like now and then compare that with the print you did at the start and make sure that the starting sector of all partitions are the same as they were at the start of the exercise. Now and only now you can use 'w' to write the new partition table to disk - up to this point you can use 'q' to quit without saving it.

Since the partitions on the disk will all have been in use while you were doing this, you now need to reboot the system to pick up the new partition size. Once the reboot is complete you now need to tell LVM to resize the LVM PV on that partition using pvresize /dev/sda4 and now you will have the new freespace available in the VG that this PV belongs to. You can then use lvextend/lvresize/lvcreate to add space to existing LVs or create new ones.

Don't forget the backup...
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Vmware disk increase extend

Post by hunter86_bg » 2019/06/30 06:28:16

As this is a VM, the fastest and simplest approach is:
1) Add new Disk
2) Do not set partitions on it at all
3) extend your VG with the new PV

Code: Select all

vgextend centos /dev/sdb
4. Extend the LV with the size you want: (adjust size and LV name)

Code: Select all

lvextend -r -L +5GiB /dev/centos/MyLV
Voilà.
Last edited by hunter86_bg on 2019/06/30 13:59:21, edited 1 time in total.

gokhan76
Posts: 3
Joined: 2019/06/28 23:03:50

Re: Vmware disk increase extend

Post by gokhan76 » 2019/06/30 08:17:04

RE: Trevor

What would I use to extend to whole space as a lvextend command??

Thanks Trevor and Hunter for your replies

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: Vmware disk increase extend

Post by hunter86_bg » 2019/06/30 20:49:20

I guess you want to extend the root so:

Code: Select all

lvextend -r -l 100%FREE /dev/centos/root
Trevor's approach is slightly faster , as the other approach needs you to create a clone of your '/boot' and disk's MBR.

Before you start - > Create a snapshot on this VM ... Just in case something goes wrong.

Post Reply