Udo's picture

I wanted to double the disk size of the VM
In VMWare I've expanded the HD from 20 to 40 GB.
In TKL apparently I did something different from the instructions here: https://www.turnkeylinux.org/blog/extending-lvm

When running:
root@QuesMail ~# cfdisk -L /dev/sda
Instead of creating sda3, I've expanded sda1 from 20G to 40G.

sda1 is now 40 GB.

Any idea how I can use the full 40G of sda1?

PV is 40 GB, but it isnt recognized as such. Therefore I can't expand the VG, and so on.

Here is the info I've got:

root@QuesMail ~# fdisk -l
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 sectors
Disk model: Virtual disk
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x06b75928

Device     Boot  Start      End  Sectors Size Id Type
/dev/sda1  *    123046 83885028 83761983  40G 8e Linux LVM

Disk /dev/mapper/turnkey-root: 17 GiB, 18253611008 bytes, 35651584 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 /dev/mapper/turnkey-swap_1: 512 MiB, 536870912 bytes, 1048576 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

root@QuesMail ~# lsblk
fd0                  2:0    1    4K  0 disk
sda                  8:0    0   40G  0 disk
`-sda1               8:1    0   40G  0 part
  |-turnkey-root   254:0    0   17G  0 lvm  /
  `-turnkey-swap_1 254:1    0  512M  0 lvm  [SWAP]
sr0                 11:0    1 1024M  0 rom

root@QuesMail ~# vgdisplay
  --- Volume group ---
  VG Name               turnkey
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  3
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               <18.57 GiB
  PE Size               4.00 MiB
  Total PE              4753
  Alloc PE / Size       4480 / 17.50 GiB
  Free  PE / Size       273 / <1.07 GiB
  VG UUID               3RRmMS-NlHO-iLFu-Q04W-Q3dS-otr9-jfrdCr

root@QuesMail ~# pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda1
  VG Name               turnkey
  PV Size               <18.57 GiB / not usable <1.41 MiB
  Allocatable           yes
  PE Size               4.00 MiB
  Total PE              4753
  Free PE               273
  Allocated PE          4480
  PV UUID               pqgVaP-UQcj-6Owx-AXFF-MInK-MKTT-kDRQux

root@QuesMail ~# lvextend -L +20G /dev/turnkey/root
  Insufficient free space: 5120 extents needed, but only 273 available

root@QuesMail ~# file -s /dev/sda*
/dev/sda:  DOS/MBR boot sector
/dev/sda1: LVM2 PV (Linux Logical Volume Manager), UUID: pqgVaP-UQcj-6Owx-AXFF-MInK-MKTT-kDRQux, size: 19937000960

Jeremy Davis's picture

Whilst what you've done so far probably isn't the quickest and easiest way to go, but it's not wrong per se. It's just incomplete. Essentially you've successfully increased the size of the (virtual) physical disk and you've added the extra disk space to the relevant partition.

But now you need to resize the PV. Once that's done, then the VG should automatically see the additional space. Then you can extend the LV and the filesystem itself. The step you appear to be missing is the resizing of the PV.

So to get LVM to see the bigger PV, try this:

pvresize /dev/sda1

Now check that you can see the additional space in your PV and VG. FWIW, in this instance I recommend the 'pvs' and 'vgs' commands, rather than 'pvdisplay' and 'vgdisplay' commands respectively. The shorter commands display less info, but in a more compact way and they will provide the specific info we need, so probably easier to read in this context. Regardless, use whichever command you prefer to confirm that both your PV and VG are now "seeing" the full 40G (or thereabouts).

Assuming that you can now see the additional space, if you wish to use all of the free space available in your VG (i.e. you are not using LVM snapshots etc), then you can just extend it to use 100% like this:

lvextend -l +100%FREE /dev/turnkey/root

If you wish to leave 10% of the VG free (e.g. if you are using or intend to use LVM snapshots or something else...) then you can use "+90%FREE" instead. Alternatively, you can add the desired size, as per what you tried already (i.e. 'lvextend -L +20G /dev/turnkey/root').

Once that's done, double check that the LV has been increased using either 'lvs' or 'lvdisplay'. Assuming it has, then extend the filesystem:

resize2fs /dev/turnkey/root

Then double check that the new space is now visable to the OS:

df -h /

You should now have ~40GB! :)

Udo's picture

Perfect! 40 GB available!



Add new comment