Increase LVM Partition to Take Up Remaining Space UBUNTU

(For Cloud VPS, and Cloud servers NOT dedicated)

Ubuntu VPS / Cloud

  1. Change configuration to the size you want. Then reboot.
  2. Via your cloud panel do a snapshot (actions > create snapshot)
  3. SSH in and perform the below.

fdisk -l

Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x41577866

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 62914559 61915136 29.5G 8e Linux LVM

Disk /dev/mapper/vg00-lv00: 1.9 GiB, 2046820352 bytes, 3997696 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/vg00-lv01: 27.6 GiB, 29649534976 bytes, 57909248 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@:~# fdisk /dev/sda

Welcome to fdisk (util-linux 2.31.1).
Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Command (m for help): p
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x41577866

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 62914559 61915136 29.5G 8e Linux LVM

Command (m for help): d
Partition number (1,2, default 2): 2

Partition 2 has been deleted.

Command (m for help): n
Partition type
p primary (1 primary, 0 extended, 3 free)
e extended (container for logical partitions)
Select (default p): p
Partition number (2-4, default 2): 2
First sector (999424-83886079, default 999424): <<< hit ENTER
Last sector, +sectors or +size{K,M,G,T,P} (999424-83886079, default 83886079): <<< hit ENTER

Created a new partition 2 of type ‘Linux’ and of size 39.5 GiB.
Partition #2 contains a LVM2_member signature.

Do you want to remove the signature? [Y]es/[N]o: n

Command (m for help): p

Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x41577866

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 83886079 82886656 39.5G 83 Linux

Command (m for help): t
Partition number (1,2, default 2): 2
Hex code (type L to list all codes): L

0 Empty 24 NEC DOS 81 Minix / old Lin bf Solaris
1 FAT12 27 Hidden NTFS Win 82 Linux swap / So c1 DRDOS/sec (FAT-
2 XENIX root 39 Plan 9 83 Linux c4 DRDOS/sec (FAT-
3 XENIX usr 3c PartitionMagic 84 OS/2 hidden or c6 DRDOS/sec (FAT-
4 FAT16 <32M 40 Venix 80286 85 Linux extended c7 Syrinx
5 Extended 41 PPC PReP Boot 86 NTFS volume set da Non-FS data
6 FAT16 42 SFS 87 NTFS volume set db CP/M / CTOS / .
7 HPFS/NTFS/exFAT 4d QNX4.x 88 Linux plaintext de Dell Utility
8 AIX 4e QNX4.x 2nd part 8e Linux LVM df BootIt
9 AIX bootable 4f QNX4.x 3rd part 93 Amoeba e1 DOS access
a OS/2 Boot Manag 50 OnTrack DM 94 Amoeba BBT e3 DOS R/O
b W95 FAT32 51 OnTrack DM6 Aux 9f BSD/OS e4 SpeedStor
c W95 FAT32 (LBA) 52 CP/M a0 IBM Thinkpad hi ea Rufus alignment
e W95 FAT16 (LBA) 53 OnTrack DM6 Aux a5 FreeBSD eb BeOS fs
f W95 Ext’d (LBA) 54 OnTrackDM6 a6 OpenBSD ee GPT
10 OPUS 55 EZ-Drive a7 NeXTSTEP ef EFI (FAT-12/16/
11 Hidden FAT12 56 Golden Bow a8 Darwin UFS f0 Linux/PA-RISC b
12 Compaq diagnost 5c Priam Edisk a9 NetBSD f1 SpeedStor
14 Hidden FAT16 <3 61 SpeedStor ab Darwin boot f4 SpeedStor
16 Hidden FAT16 63 GNU HURD or Sys af HFS / HFS+ f2 DOS secondary
17 Hidden HPFS/NTF 64 Novell Netware b7 BSDI fs fb VMware VMFS
18 AST SmartSleep 65 Novell Netware b8 BSDI swap fc VMware VMKCORE
1b Hidden W95 FAT3 70 DiskSecure Mult bb Boot Wizard hid fd Linux raid auto
1c Hidden W95 FAT3 75 PC/IX bc Acronis FAT32 L fe LANstep
1e Hidden W95 FAT1 80 Old Minix be Solaris boot ff BBT
Hex code (type L to list all codes): 8e

Changed type of partition ‘Linux’ to ‘Linux LVM’.

Command (m for help): p
Disk /dev/sda: 40 GiB, 42949672960 bytes, 83886080 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
Disklabel type: dos
Disk identifier: 0x41577866

Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 999424 83886079 82886656 39.5G 8e Linux LVM

Command (m for help): w
The partition table has been altered.
Syncing disks.

root@:~# partprobe


root@:~# pvresize /dev/sda2
Physical volume “/dev/sda2” changed
1 physical volume(s) resized / 0 physical volume(s) not resized


root@:~# pvs
PV VG Fmt Attr PSize PFree
/dev/sda2 vg00 lvm2 a– <39.52g 10.00g


root@:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 459M 0 459M 0% /dev
tmpfs 97M 860K 96M 1% /run
/dev/mapper/vg00-lv01 28G 18G 8.9G 66% /
tmpfs 482M 0 482M 0% /dev/shm
tmpfs 5.0M 16K 5.0M 1% /run/lock
tmpfs 482M 0 482M 0% /sys/fs/cgroup
/dev/sda1 464M 113M 323M 26% /boot
tmpfs 97M 0 97M 0% /run/user/0


root@:~# lvresize -l +100%FREE /dev/mapper/vg00-lv01
Size of logical volume vg00/lv01 changed from 27.61 GiB (7069 extents) to 37.61 GiB (9629 extents).
Logical volume vg00/lv01 successfully resized.


root@:~# mount | grep vg00-lv01
/dev/mapper/vg00-lv01 on / type ext4 (rw,relatime,errors=remount-ro,data=ordered)


root@:~# resize2fs /dev/mapper/vg00-lv01
resize2fs 1.44.1 (24-Mar-2018)
Filesystem at /dev/mapper/vg00-lv01 is mounted on /; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 5
The filesystem on /dev/mapper/vg00-lv01 is now 9860096 (4k) blocks long.

root@:~# df -h
Filesystem Size Used Avail Use% Mounted on
udev 459M 0 459M 0% /dev
tmpfs 97M 860K 96M 1% /run
/dev/mapper/vg00-lv01 37G 18G 19G 49% /
tmpfs 482M 0 482M 0% /dev/shm
tmpfs 5.0M 16K 5.0M 1% /run/lock
tmpfs 482M 0 482M 0% /sys/fs/cgroup
/dev/sda1 464M 113M 323M 26% /boot
tmpfs 97M 0 97M 0% /run/user/0

cbinkley has written 5 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>