Extending root partition on Centos 7 VM

General support questions
Post Reply
LJS
Posts: 18
Joined: 2016/09/22 13:11:56

Extending root partition on Centos 7 VM

Post by LJS » 2017/09/19 10:35:15

I have a virtual machine of approx. 250GB that needs its root partition extending. I've allocated more space in vmware (now 300GB) but have tied myself in knots trying to extend that partition to make use of it.

Code: Select all

[root@xxx-xx-xxx ~]# df -h
Filesystem                                       Size  Used Avail Use% Mounted on
/dev/mapper/centos_xxx--xx-xxx-root  255G  247G  8.2G  97% /
devtmpfs                                         235M     0  235M   0% /dev
tmpfs                                            245M     0  245M   0% /dev/shm
tmpfs                                            245M  4.5M  241M   2% /run
tmpfs                                            245M     0  245M   0% /sys/fs/cgroup
/dev/sda1                                        497M  208M  290M  42% /boot
tmpfs                                             49M     0   49M   0% /run/user/0
The first and obvious question is can this be done? And secondly, what are the steps? I followed what this had to offer https://kb.vmware.com/selfservice/micro ... Id=1006371 but my new volume wasn't recognised and following that managed to bork the filesystem.

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

Re: Extending root partition on Centos 7 VM

Post by hunter86_bg » 2017/09/19 12:14:28

Have you tried the forum search/ google search ?
Here is a hint: yes you can

LJS
Posts: 18
Joined: 2016/09/22 13:11:56

Re: Extending root partition on Centos 7 VM

Post by LJS » 2017/09/19 14:36:35

Okay, I've read that thread and carried out the first set of steps with regard creating a new vmdks. In your post here I'm a bit confused by steps 4-7. Below is some of my output.

Step 4:

Code: Select all

[root@xxx-xx-xxx-i ~]# lsblk
NAME                                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0                                       2:0    1     4K  0 disk
sda                                       8:0    0   350G  0 disk
├─sda1                                    8:1    0   500M  0 part /boot
├─sda2                                    8:2    0 255.5G  0 part
│ ├─centos_xxx--xx--xxx--p1-root 253:0    0 254.5G  0 lvm  /
│ └─centos_xxx--xx--xxx--p1-swap 253:1    0     1G  0 lvm  [SWAP]
└─sda3                                    8:3    0    94G  0 part
sr0                                      11:0    1  1024M  0 rom
Step 5:

I assume this will be /dev/sda3/xxx, or something else?

Thanks for the help.

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

Re: Extending root partition on Centos 7 VM

Post by hunter86_bg » 2017/09/19 19:31:03

If you created a new vmdk -it should be sdb or something like that.
Rescan the scsi bus with the correct commands (previous post step 3B or 3C). You can always use the rescan-scsi-bus.sh tool.

EDIT:
It seems I mixed the disk rescan with the scsi bus rescan.I've updated the procedure and it now contains 1 ugly one-liner which basically does the following:

Code: Select all

find /sys -type f -iname "scan" -print
Expected result is like:
/sys/devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0/scan
/sys/devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1/scan
/sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan
/sys/module/scsi_mod/parameters/scan
Rescan the scsi bus by passing to each host the "- - -" instead of one. It should look like:

Code: Select all

# echo "- - -" > /sys/devices/pci0000:00/0000:00:07.1/ata1/host0/scsi_host/host0/scan
# echo "- - -" > /sys/devices/pci0000:00/0000:00:07.1/ata2/host1/scsi_host/host1/scan
# echo "- - -" > /sys/devices/pci0000:00/0000:00:10.0/host2/scsi_host/host2/scan
If you don't use "disk.enableuuid=true" , I'd recommend you to pvcreate the new disk with the unique identifier - > "/dev/disk/by-id/some-long-string"

LJS
Posts: 18
Joined: 2016/09/22 13:11:56

Re: Extending root partition on Centos 7 VM

Post by LJS » 2017/09/20 10:35:17

Thanks for the updated instructions, I'm making progress here.

Code: Select all

[root@xxx-xx-xxx ~]# find /sys -type f -iname "scan" -print
/sys/devices/pci0000:00/0000:00:07.1/ata1/host1/scsi_host/host1/scan
/sys/devices/pci0000:00/0000:00:07.1/ata2/host2/scsi_host/host2/scan
/sys/devices/pci0000:00/0000:00:10.0/host0/scsi_host/host0/scan
/sys/module/scsi_mod/parameters/scan
[root@xxx-xx-xxx ~]# lsblk
NAME                                    MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
fd0                                       2:0    1     4K  0 disk
sda                                       8:0    0   350G  0 disk
├─sda1                                    8:1    0   500M  0 part /boot
└─sda2                                    8:2    0 255.5G  0 part
  ├─centos_xxx--xx--xxx-root 253:0    0 254.5G  0 lvm  /
  └─centos_xxx-xx--xxx-swap 253:1    0     1G  0 lvm  [SWAP]
sdb                                       8:16   0    50G  0 disk
sr0                                      11:0    1  1024M  0 rom
As you can see I have sdb showing. This is probably blindingly obvious but in step 5 where do I obtain the value some-large-string-that-points-to-your-sdX-device ? Also, I assume /by-id/ is merely the number that follows sda/sdb, for example /dev/sda2/some-large-string-that-points-to-your-sdX-device ?

Below is the pvdisplay and lvdisplay output, and so for steps 6 & 7 I would want vgextend centos_xxx-xx-xxx /dev/sdb/some-large-string-that-points-to-your-sdX-device (whatever that last string might be) and lvextend -r -L +50G /dev/centos_xxx-xx-xxx/root ?

Code: Select all

[root@xxx-xx-xxx ~]# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               centos_xxx-xx-xxx
  PV Size               255.51 GiB / not usable 3.00 MiB
  Allocatable           yes (but full)
  PE Size               4.00 MiB
  Total PE              65410
  Free PE               0
  Allocated PE          65410
  PV UUID               RzUrwz-911D-qL6Z-WFdL-Ommu-HL98-IEbFaO

[root@root@xxx-xx-xxx ~]# lvdisplay
  --- Logical volume ---
  LV Path                /dev/centos_xxx-xx-xxx/swap
  LV Name                swap
  VG Name                centos_xxx-xx-xxx
  LV UUID                1S1Cov-dzGf-CO53-gPI4-05MP-f0Nh-Z3nS7U
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-07-01 18:40:02 +0000
  LV Status              available
  # open                 2
  LV Size                1.00 GiB
  Current LE             256
  Segments               1
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:1

  --- Logical volume ---
  LV Path                /dev/centos_xxx-xx-xxx/root
  LV Name                root
  VG Name                centos_xxx-xx-xxx
  LV UUID                Kt1TBW-DaYw-1HqB-xydJ-fGZQ-exhp-NNT6f0
  LV Write Access        read/write
  LV Creation host, time localhost, 2016-07-01 18:40:03 +0000
  LV Status              available
  # open                 1
  LV Size                254.51 GiB
  Current LE             65154
  Segments               2
  Allocation             inherit
  Read ahead sectors     auto
  - currently set to     8192
  Block device           253:0

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

Re: Extending root partition on Centos 7 VM

Post by hunter86_bg » 2017/09/20 12:56:40

just run

Code: Select all

ls -ltr /dev/disk/by-id/
and find the long string which is linked to sdb (marked with arrow on the end of the line).
Then just

Code: Select all

pvcreate /dev/disk/by-id/abcdefghijklmnopqrstuvwxyz
and you have left just to add it to your volumegroup and last to lvextend -r rootlv.

Warning:Have a backup just in case and be careful with XFS as it can't be shrunk.

LJS
Posts: 18
Joined: 2016/09/22 13:11:56

Re: Extending root partition on Centos 7 VM

Post by LJS » 2017/09/20 14:35:07

I've nothing marked with sdb, only sda2:

Code: Select all

[root@xxx-xx-xxx ~]# ls -ltr /dev/disk/by-id/
total 0
lrwxrwxrwx. 1 root root 10 Sep 20 09:23 dm-uuid-LVM-OKq9kFrTLuHZHVuTQs4DmNEAI23FPUMa1S1CovdzGfCO53gPI405MPf0NhZ3nS7U -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Sep 20 09:23 dm-name-centos_xxx--xxx--xxx-swap -> ../../dm-1
lrwxrwxrwx. 1 root root 10 Sep 20 09:23 dm-uuid-LVM-OKq9kFrTLuHZHVuTQs4DmNEAI23FPUMaKt1TBWDaYw1HqBxydJfGZQexhpNNT6f0 -> ../../dm-0
lrwxrwxrwx. 1 root root 10 Sep 20 09:23 dm-name-centos_xxx-xx-xxx-root -> ../../dm-0
lrwxrwxrwx. 1 root root  9 Sep 20 09:23 ata-VMware_Virtual_IDE_CDROM_Drive_10000000000000000001 -> ../../sr0
lrwxrwxrwx. 1 root root 10 Sep 20 09:23 lvm-pv-uuid-RzUrwz-911D-qL6Z-WFdL-Ommu-HL98-IEbFaO -> ../../sda2
Have I missed something partway through the process?

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

Re: Extending root partition on Centos 7 VM

Post by hunter86_bg » 2017/09/20 17:28:06

It seems that without 'disk.EnableUUID' setting in Vmware ,udev cannot generate /dev/disk/by-id/ entries.
Then you have to 'pvcreate /dev/sdb' and proceed with the extension, but be aware that not using persisting naming could cause problems in future (although I have seen mainly issues with SuSe).

Source:Some SuSe guide.

LJS
Posts: 18
Joined: 2016/09/22 13:11:56

Re: Extending root partition on Centos 7 VM

Post by LJS » 2017/09/21 08:47:06

All of that has worked a treat. I have an extended root partition with adequate space.

Code: Select all

[root@xxx-xxx-xxx~]# df -h
Filesystem                                       Size  Used Avail Use% Mounted on
/dev/mapper/centos_xxx--xx--xxx--xx-root  303G  248G   56G  82% /
devtmpfs                                         235M     0  235M   0% /dev
tmpfs                                            245M     0  245M   0% /dev/shm
tmpfs                                            245M  4.5M  241M   2% /run
tmpfs                                            245M     0  245M   0% /sys/fs/cgroup
/dev/sda1                                        497M  208M  290M  42% /boot
tmpfs                                             49M     0   49M   0% /run/user/0
Thanks for all your help here, I've certainly learnt a few things.

Post Reply