Extend a PV partition in Linux

1

I have a situation where there is ~300G available on /dev/sda and I want to extend a partition /dev/sda3 with the additional ~300G.

However from what I read online if /dev/sda4 exists, I cannot increase /dev/sda3 unless I remove /dev/sda4 which contains /boot/efi (which I don't believe is an option).

fdisk -l /dev/sda

Disk /dev/sda: 644.2 GB, 644245094400 bytes, 1258291200 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: 0x00000000

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1   629145599   314572799+  ee  GPT

What is also interesting is that the "Disk label type" is dos when I think it is GPT. This seems to be preventing it from showing /dev/sda2, /dev/sda3, and /dev/sda4 when running fdisk -l. I do not have gparted on this system.

I know these partition exist because it can be seen in df -h:

df -h
Filesystem                       Size  Used Avail Use% Mounted on
/dev/mapper/vg-root            10G  5.4G  4.7G  54% /
devtmpfs                          24G     0   24G   0% /dev
tmpfs                             24G   39M   24G   1% /dev/shm
tmpfs                             24G  209M   24G   1% /run
tmpfs                             24G     0   24G   0% /sys/fs/cgroup
/dev/sda2                        509M  124M  386M  25% /boot
/dev/sda4                        200M  5.1M  195M   3% /boot/efi
/dev/mapper/vg-tmp            8.0G   33M  8.0G   1% /tmp
/dev/mapper/vg-var            3.0G  268M  2.8G   9% /var
/dev/mapper/vg-home           509M   28M  482M   6% /home
/dev/mapper/vg-var_log        5.0G  215M  4.8G   5% /var/log
/dev/mapper/vg-var_log_audit  2.0G   65M  2.0G   4% /var/log/audit

/dev/sda3 is using lvm on it and that will allow me to extend the /dev/mappers once I have the additional 300gb on the PV.

I see the free space from the parted command:

parted /dev/sda unit MiB print free
    Model: VMware Virtual disk (scsi)
    Disk /dev/sda: 614400MiB
    Sector size (logical/physical): 512B/512B
    Partition Table: gpt
    Disk Flags: pmbr_boot

    Number  Start      End        Size       File system  Name  Flags
            0.02MiB    1.00MiB    0.98MiB    Free Space
     1      1.00MiB    2.00MiB    1.00MiB                       bios_grub
     2      2.00MiB    514MiB     512MiB     xfs
     3      514MiB     306999MiB  306485MiB                     lvm
     4      306999MiB  307199MiB  200MiB     fat16
            307199MiB  614400MiB  307201MiB  Free Space

My Question: Is there anyway I can increase the pv /dev/sda3 without removing /dev/sda4 so that I can increase the vg's that exist on /dev/sda3 with that additional 300gb?

linux
partitioning
lvm
fdisk
asked on Super User Dec 13, 2018 by Kirs Kringle

1 Answer

1

First off, you're mixing old with new. LVM doesn't care where the disk is located, as long as it is formatted for LVM. Secondly, you're in a bit of a pickle, since you need the fourth partition to be an Extended partition, not a FAT16 partition. MBR disks can only handle up to 4 primary/extended partitions.

In order to work around this, systems will create the first three partitions as Primary by default, and any additional as Logical Partitions within one large Extended partition. If you want to keep your current setup, you're going to need to get rid of that 4th partition, or use a partition editor to move the partition to the end of the drive.

Since this is a VM, it should not matter where the partitions physically are. Is there a reason for that FAT16 partition to be there? I see you have a boot partition - at least, you have a BIOS_GRUB partition already... Load up a tool like GPartEd to move the partition over, and extend sda3.

Next, after you boot back into your OS, run through your LVM tutorial to make sure it is taking advantage of the extra 300GB in the partition. You can check this by running (as root) pvs. After you know the entire physical volume is used, run vgs to check that the volume groups it is assigned to has increased as well. If so, then you can manage the partitions as LVM intended.

answered on Super User Dec 13, 2018 by Canadian Luke

User contributions licensed under CC BY-SA 3.0