Enlarging the /home directory

Issues related to hardware problems
johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Enlarging the /home directory

Post by johnwmcc » 2019/03/18 22:53:41

I accepted the default partitioning when installing CentOS 7.6.1810 as a virtual machine (VM) under VMWare ESXi 6.5.

I want to use most of the disk for media, and find that I've twice put the media folder in a place which has too small a portion of the disk - first in a subdirectory of / which was allocated only 50GB, then in /home/john/plexmedia, which seems to be limited to just under 150GB out of a 1TB disk, of which I've allocated 800GB to the CentOS VM.

I used the df -h command to see what is in use, and can only see about 200GB reported for the VM file system in use. See image below (I can't copy the text itself from the console).
df command output.png
df command output.png (97.42 KiB) Viewed 9963 times
Looking at the Datastore information, it seems I have 8 partitions numbered 1 - 3, then 5-9 (see image below).
Partitioning.png
Partitioning.png (58.99 KiB) Viewed 9966 times
Four are Basic Data partitions, one of 4GB and three of almost 250GB each. Looks as if the /home directories are on one of these.

Any idea how I can merge these three large Basic Data partitions into one without losing data?

I have Webmin, if that helps, and it seems to have a partitioning tool - it can certainly view the partitions, but I'm not sure if it can edit them, let alone how to.

I'd be grateful for any help you can offer.

PS. Editing seems to keep dropping or doubling up images and losing later edits if I Preview them.

PPS. VMWare console shows confusing information about the virtual hard disk. Says there's 800 GB allocated, but only 118.3GB Maximum Size, and it's Thick provisioned, lazily zeroed.

As a new forum member, am I limited to one attachment per post? I seem to have got three when I preview the post, but only one attachment lists, and I can't add another.
Attachments
df command output.png
df command output.png (97.42 KiB) Viewed 9964 times
Last edited by johnwmcc on 2019/03/18 23:10:26, edited 2 times in total.

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

Re: Enlarging the /home directory

Post by TrevorH » 2019/03/18 23:06:44

Four are Basic Data partitions, one of 4GB and three of almost 250GB each. Looks as if the /home directories are on one of these.
You're misreading that, those are 250MB not GB. And you're also confusing yourself by looking at the space allocations in two different places. Your "Partition Diagram" is a view from the vmware POV and by far the majority of your space there is in partition 3: VMFS which is 924GB. I am fairly sure you can ignore all the rest of those partitions as they're all VMWare things and, in any case, they only take up just over 7GB.

But you want the space in your CentOS guest so we need to look at the info from that. Post the output from the following commands, run as root:

fdisk -lu /dev/sd[a-z]
pvs
vgs
lvs
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

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/18 23:11:52

Thanks, and I apologize for misreading the MB as GB.

Will run those commands as soo as I can and post back.

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/18 23:18:53

Here are images of the output - I can't copy text from the VM console.

And I can only add three images - see next post for the lvs output.
Attachments
vgs output.png
vgs output.png (16.22 KiB) Viewed 9955 times
pvs output.png
pvs output.png (17.29 KiB) Viewed 9955 times
fdisk output.png
fdisk output.png (54.29 KiB) Viewed 9955 times
Last edited by johnwmcc on 2019/03/18 23:19:52, edited 1 time in total.

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/18 23:19:31

And the last one.
lvs output.png
lvs output.png (27.28 KiB) Viewed 9955 times
And what VMWare says about provisioning the hard disk for the VM (or would, if it doesn't lose the attachment again)
Hard disk allocation.png
Hard disk allocation.png (27.44 KiB) Viewed 9952 times

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

Re: Enlarging the /home directory

Post by TrevorH » 2019/03/19 00:28:52

OK, so your current disk is seen as being 800GB but how you are set up at the moment is not using all of its space. Your current partition 2 is only 200GB in size. What I would do, is take the easy option and use fdisk to add a new partition that uses up the rest of the space then tag it as type 0x8e LVM. When you're happy with the new partition just use 'w' to write it out or 'q' to quit without saving. To get that seen you will now need to reboot the guest.

After the reboot, run pvcreate /dev/sda3 then vgextend centos /dev/sda3 and now your 'centos' volume group contains all that new space.

I presume you want to enlarge /home? If so then now you need to run something like lvextend -r -L+nnG centos/home - please read man lvextend before you try it to find out what it does. The -L+nnG tells it to add (+) nnGB to the LV, the -r tells it to resize the filesystem at the same time as extending the LV.
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

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/19 00:33:14

Thank you very much indeed.

I'll have to do some homework to understand what you say I should do (too late tonight and busy almost all tomorrow, but hope to try again on Wednesday).

I'm very glad there IS apparently, then, a way to enlarge the available space without having to reinstall everything from scratch.

Thanks again. I'll post later how it all works out.

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/19 00:36:57

TrevorH wrote:
2019/03/19 00:28:52
use fdisk to add a new partition that uses up the rest of the space then tag it as type 0x8e LVM.
Sounds easy when you say it quickly, but I've no idea at the moment how to do that!

Will have to look up fdisk options and behaviour.

darthbolek
Posts: 26
Joined: 2019/03/17 11:48:21

Re: Enlarging the /home directory

Post by darthbolek » 2019/03/19 01:49:26

It looks like there is some unallocated free space on your disk.
To confirm it you can run command (display only, will not modify anything):

Code: Select all

sudo parted /dev/sda unit b print free
to see better overview of the disk there is command:

Code: Select all

lsblk
As a alternative to creating new partition and second physical volume and extending volume group you could just extend the existing physical volume.

General steps:
1. extend partition (google: parted resizepart)

Code: Select all

sudo parted /dev/sda unit b resizepart 2 <partition new end/size>B
2. resize physical volume

Code: Select all

sudo pvresize /dev/sda2
3. resize logical volume (set appropriate size)

Code: Select all

sudo lvresize -L +600G /dev/centos/home
4. resize filesystem (get filesystem_name from cat /etc/fstab) (by default centos uses xfs, and it is grow only, you can't shrink it)

Code: Select all

sudo xfs_growfs filesystem_name

johnwmcc
Posts: 15
Joined: 2019/03/18 01:43:35

Re: Enlarging the /home directory

Post by johnwmcc » 2019/03/19 17:04:18

Many thanks. Busy rest of today, but may be able to try late tonight. If not tonight, then some time tomorrow.

[LATER] See later post on next page
Last edited by johnwmcc on 2019/03/25 13:16:09, edited 1 time in total.

Post Reply