0

I'm using LVM with two logical volumes:

  • First LV is mounted to the root directory /
  • Second LV is mounted to /var/log directory

Those two LVs are based on a physical volume /dev/sda3. The device /dev/sda is using a GPT partition table.

My purpose is to resize the partition /dev/sda3 to occupy all the free memory on the disk.

For that I used gdisk command:

This is the current partition table I have:

Command (? for help): p
Disk /dev/sda: 4294967296 sectors, 2.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 546DEB45-C1DE-402B-BB51-4011AC159B4F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4294967262
Partitions will be aligned on 8-sector boundaries
Total free space is 4188012544 sectors (2.0 TiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34          614433   300.0 MiB   EF00
   2          614434        17386294   8.0 GiB     8200
   3        17386295       106954718   42.7 GiB    8E00

This is what I did to resize the 3rd partition:

Command (? for help): d
Partition number (1-3): 3

Command (? for help): n
Partition number (3-128, default 3): 3
First sector (17386295-4294967262, default = 17386296) or {+-}size{KMGTP}:
Last sector (17386296-4294967262, default = 4294967262) or {+-}size{KMGTP}:
Current type is 'Linux filesystem'
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to 'Linux LVM'

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
Warning: The kernel is still using the old partition table.
The new table will be used at the next reboot.
The operation has completed successfully.

Indeed, the 3rd partition has a new size:

Command (? for help): p
Disk /dev/sda: 4294967296 sectors, 2.0 TiB
Logical sector size: 512 bytes
Disk identifier (GUID): 546DEB45-C1DE-402B-BB51-4011AC159B4F
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 4294967262
Partitions will be aligned on 8-sector boundaries
Total free space is 1 sectors (512 bytes)

Number  Start (sector)    End (sector)  Size       Code  Name
   1              34          614433   300.0 MiB   EF00
   2          614434        17386294   8.0 GiB     8200
   3        17386296      4294967262   2.0 TiB     8E00  Linux LVM

Now, I need to inform the kernel of the new change in the partition table.

To my understanding there are three options:

partprobe:

Error: Partition(s) 3 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes.

partx -uv /dev/sda:

partition: none, disk: /dev/sda, lower: 0, upper: 0
/dev/sda: partition table type 'gpt' detected
/dev/sda: partition #1 resized
/dev/sda: partition #2 resized
/dev/sda: partition #3 resized
partx: /dev/sda: updating partition #3 failed: Invalid argument
partx: /dev/sda: error updating partition 3

reboot: The machine is not recovering and I entered a KDB shell.

Q: What am I doing wrong and what is the proper way to increase the size of the partition /dev/sda3?

BTW, I noticed that when I use a smaller disk like 100GiB (instead of the 2TiB I used earlier), then the command partx -uv /dev/sda is working without raising an error (partprobe is still complaining). How can this be explained?

Appreciating your help!

4
  • 2
    There is difference of one sector between start sector before extend and start sector after extend. This may cause the problem. Aug 7, 2022 at 15:42
  • Hi @RomeoNinov, When I put 17386295 as the starting sector (instead of the default 17386296) I get the following message: Information: Moved requested sector from 17386295 to 17386296 in order to align on 8-sector boundaries. Use 'l' on the experts' menu to adjust alignment. So how can it be that the last 3rd partition started from 17386295 and not 17386296? Thanks
    – user536698
    Aug 8, 2022 at 7:30
  • You can try in expert menu to disable align to n-sectors boundaries. Aug 8, 2022 at 8:11
  • 1
    YES, that solved the problem thank you!
    – user536698
    Aug 10, 2022 at 14:16

1 Answer 1

0

What is visible from the gdisk results is you have difference between the start sector before and after.

3 17386295 106954718 42.7 GiB 8E00

and

3 17386296 4294967262 2.0 TiB 8E00 Linux LVM

This lead to problem for LVM because it can't identify proper information for PV. Try to correct this (set start sector to be 17386295) and the visibility of the partition as PV will be restored.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .