Skip to main content

Adding an additional disk

in Increasing your disk space (Ubuntu)
Authors list
Published: Nov 30, 2023|Last updated: Nov 30, 2023

For this method, you will need to attach a new disk to your Deskpro server in your hypervisor, then restart your VM in order for the kernel to recognise the new disk has been added.

Note

All commands listed below must be run as the root user on the server. You can escalate to root from a sudoer user with the command sudo su -

Identifying the additional diskCopy link to Identifying the additional disk to clipboard

Once the VM has restarted, run the command fdisk -l, and you should see your original disk, your Logical Volume, and your new disk.

Disk /dev/sda: 50 GiB, 53687091200 bytes, 104857600 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: gpt Disk identifier: 0F162CEE-5CE2-4CFB-8187-C1770A85FA78 Device Start End Sectors Size Type /dev/sda1 2048 4095 2048 1M BIOS boot /dev/sda2 4096 4198399 4194304 2G Linux filesystem /dev/sda3 4198400 104857566 100659167 48G Linux filesystem Disk /dev/sdb: 50 GiB, 53687091200 bytes, 104857600 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 Disk /dev/mapper/ubuntu--vg-ubuntu--lv: 48 GiB, 51535413248 bytes, 100655104 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
copy

In the example above, the original disk is /dev/sda, the new disk is /dev/sdb and the logical volume is /dev/mapper/ubuntu--vg-ubuntu--lv. You can easily identify the new disk added as it will have a 'Disk model', but no partitions mapped.

Creating a Physical VolumeCopy link to Creating a Physical Volume to clipboard

As we are adding the entire disk to the volume group, we can create a physical volume on this new disk without partitioning.

To do so, simply run the command pvcreate </path/to/disk>:

root@deskpro:~# pvcreate /dev/sdb Physical volume "/dev/sdb" successfully created.
copy

If you now run the command pvdisplay, you should see that your disk added to the list marked as a 'new physical volume':

root@deskpro:~# pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <48.00 GiB / not usable 16.50 KiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12287 Free PE 0 Allocated PE 12287 PV UUID nCxUhI-F1e4-BYBy-oMzz-QOaV-ksfK-VRcz1f "/dev/sdb" is a new physical volume of "50.00 GiB" --- NEW Physical volume --- PV Name /dev/sdb VG Name PV Size 50.00 GiB Allocatable NO PE Size 0 Total PE 0 Free PE 0 Allocated PE 0 PV UUID p2zEOF-yyMd-1nni-09yQ-4WqP-eC66-NhHDh7
copy

Adding to the Volume GroupCopy link to Adding to the Volume Group to clipboard

Now the Physical Volume has been created we need to add it to the Volume Group so it can be allocated.

First, run vgdisplay and make a note of the VG Name. You should also see that the 'Free PE / Size' is currently 0 / 0:

root@deskpro:~# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 1 Metadata Sequence No 4 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 1 Act PV 1 VG Size <48.00 GiB PE Size 4.00 MiB Total PE 12287 Alloc PE / Size 12287 / <48.00 GiB Free PE / Size 0 / 0 VG UUID YuHCnH-4xGx-jk7p-52mH-epkG-Qbvn-OVjYBw
copy

To extend the volume group, run the command vgextend <VG Name> <PV Name>:

root@deskpro:~# vgextend ubuntu-vg /dev/sdb Volume group "ubuntu-vg" successfully extended
copy

Now, check both pvdisplay and vgdisplay. You should see that the new physical volume has been added to your virtual group and is allocatable, and the volume group now has additional space in Free PE / Size:

root@deskpro:~# pvdisplay --- Physical volume --- PV Name /dev/sda3 VG Name ubuntu-vg PV Size <48.00 GiB / not usable 16.50 KiB Allocatable yes (but full) PE Size 4.00 MiB Total PE 12287 Free PE 0 Allocated PE 12287 PV UUID nCxUhI-F1e4-BYBy-oMzz-QOaV-ksfK-VRcz1f --- Physical volume --- PV Name /dev/sdb VG Name ubuntu-vg PV Size 50.00 GiB / not usable 4.00 MiB Allocatable yes PE Size 4.00 MiB Total PE 12799 Free PE 12799 Allocated PE 0 PV UUID p2zEOF-yyMd-1nni-09yQ-4WqP-eC66-NhHDh7 root@deskpro:~# vgdisplay --- Volume group --- VG Name ubuntu-vg System ID Format lvm2 Metadata Areas 2 Metadata Sequence No 5 VG Access read/write VG Status resizable MAX LV 0 Cur LV 1 Open LV 1 Max PV 0 Cur PV 2 Act PV 2 VG Size 97.99 GiB PE Size 4.00 MiB Total PE 25086 Alloc PE / Size 12287 / <48.00 GiB Free PE / Size 12799 / <50.00 GiB VG UUID YuHCnH-4xGx-jk7p-52mH-epkG-Qbvn-OVjYBw
copy

With the space now being available to the volume group, move on to Growing the Logical Volume

HelpfulUnhelpful

1 of 1 people found this page helpful

next pageGrowing the Logical Volume
previous pageExpanding your existing disk

Please log in or register to submit a comment.