I'm trying to extend the disk space on the root partition of my ubuntu VM from 1.5TB to 3.4TB. I thought this would be an easy task but I'm having a hard time figuring out how to do this on an OS level. The console outputs below explain my current setup (nothing fancy, just one partition with a large amount of storage):
root@ubuntu-samba:/home/joel# fdisk -l
Disk /dev/sda: 3.4 TiB, 3758096384000 bytes, 7340032000 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disklabel type: dos
Disk identifier: 0xbad8753d
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 999423 997376 487M 83 Linux
/dev/sda2 1001470 3147825151 3146823682 1.5T 5 Extended
/dev/sda5 1001472 3147825151 3146823680 1.5T 8e Linux LVM
Partition 2 does not start on physical sector boundary.
Disk /dev/mapper/ubuntu--samba--vg-root: 1.5 TiB, 1606879805440 bytes, 3138437120 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/ubuntu--samba--vg-swap_1: 4 GiB, 4290772992 bytes, 8380416 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
root@ubuntu-samba:/home/joel# vgdisplay
--- Volume group ---
VG Name ubuntu-samba-vg
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 10
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 1.47 TiB
PE Size 4.00 MiB
Total PE 384133
Alloc PE / Size 384133 / 1.47 TiB
Free PE / Size 0 / 0
VG UUID RZUZwh-xTB4-Dh90-vrYA-Ej1e-kUiM-az4y2k
root@ubuntu-samba:/home/joel# lvs
LV VG Attr LSize Pool Origin Data% Meta% Move Log Cpy%Sync Convert
root ubuntu-samba-vg -wi-ao---- 1.46t
swap_1 ubuntu-samba-vg -wi-ao---- 4.00g
root@ubuntu-samba:/home/joel# vgs
VG #PV #LV #SN Attr VSize VFree
ubuntu-samba-vg 1 2 0 wz--n- 1.47t 0
root@ubuntu-samba:/home/joel# pvs
PV VG Fmt Attr PSize PFree
/dev/sda5 ubuntu-samba-vg lvm2 a-- 1.47t 0
root@ubuntu-samba:/home/joel# df -h
Filesystem Size Used Avail Use% Mounted on
udev 2.0G 0 2.0G 0% /dev
tmpfs 395M 11M 385M 3% /run
/dev/mapper/ubuntu--samba--vg-root 1.5T 1.4T 55G 97% /
tmpfs 2.0G 0 2.0G 0% /dev/shm
tmpfs 5.0M 0 5.0M 0% /run/lock
tmpfs 2.0G 0 2.0G 0% /sys/fs/cgroup
/dev/sda1 472M 310M 138M 70% /boot
tmpfs 395M 0 395M 0% /run/user/1000
Question:
How do I extend the physical volume '/dev/sda5' to use 100% of '/dev/sda's storage (3.4TB)?
I've done a lot of playing around but getting nowhere.
A lot of online tutorials claim it's as simple as extending the logical volume, but that's not working for me as the additional storage isn't detected.
lvextend -L +100%FREE /dev/mapper/ubuntu--samba--vg-root
New size (383110 extents) matches existing size (383110 extents)
Any pointers would be greatly appreciated as I've wasted days on this and am desperate for additional storage :(
Top comments (3)
A full detailed steps to resize a /var partition with LVM and VMware vdisk
Need to resize the filesystem to extend /var
apt-get install parted
parted /dev/sda
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 256MB 255MB primary ext2 boot
256MB 257MB 1048kB Free Space
2 257MB 42.9GB 42.7GB extended
5 257MB 42.9GB 42.7GB logical lvm
42.9GB 85.9GB 43.0GB Free Space
(parted) resizepart 2
End? [42.9GB]? 80GB
(parted)
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 256MB 255MB primary ext2 boot
256MB 257MB 1048kB Free Space
2 257MB 80.0GB 79.7GB extended
5 257MB 42.9GB 42.7GB logical lvm
42.9GB 80.0GB 37.1GB Free Space
80.0GB 85.9GB 5899MB Free Space
(parted) resizepart 5
End? [42.9GB]? 80GB
(parted)
(parted) print free
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 85.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
32.3kB 1049kB 1016kB Free Space
1 1049kB 256MB 255MB primary ext2 boot
256MB 257MB 1048kB Free Space
2 257MB 80.0GB 79.7GB extended
5 257MB 80.0GB 79.7GB logical lvm
80.0GB 85.9GB 5899MB Free Space
quit
pvresize /dev/sda5
Physical volume "/dev/sda5" changed
1 physical volume(s) resized / 0 physical volume(s) not resized
then use 'lvdisplay' to get the LV path
lvdisplay
--- Logical volume ---
LV Path /dev/uctoolbox-vg/root
LV Name root
VG Name uctoolbox-vg
LV UUID THOVSb-Zh9S-wGCc-dWwf-Onl1-tbSo-UxCHTo
LV Write Access read/write
LV Creation host, time uctoolbox-dev, 2019-04-06 20:29:13 +0200
LV Status available
# open 1
LV Size 7.74 GiB
Current LE 1981
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/uctoolbox-vg/swap_1
LV Name swap_1
VG Name uctoolbox-vg
LV UUID 19bh25-4Egk-Xeij-k95D-LJkw-sO6w-ebl4R3
LV Write Access read/write
LV Creation host, time uctoolbox-dev, 2019-04-06 20:29:14 +0200
LV Status available
# open 2
LV Size 1020.00 MiB
Current LE 255
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/uctoolbox-vg/tmp
LV Name tmp
VG Name uctoolbox-vg
LV UUID hF1NTE-9YBh-VTZo-mMcT-Zfpd-WZ4O-WBl070
LV Write Access read/write
LV Creation host, time uctoolbox-dev, 2019-04-06 20:29:14 +0200
LV Status available
# open 1
LV Size 576.00 MiB
Current LE 144
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/uctoolbox-vg/home
LV Name home
VG Name uctoolbox-vg
LV UUID EDngfk-tjZ0-FHwZ-kPtN-hHDH-VaYQ-yN5wvv
LV Write Access read/write
LV Creation host, time uctoolbox-dev, 2019-04-06 20:42:16 +0200
LV Status available
# open 1
LV Size 4.66 GiB
Current LE 1192
Segments 1
Allocation inherit
Read ahead sectors auto
--- Logical volume ---
LV Path /dev/uctoolbox-vg/var
LV Name var
VG Name uctoolbox-vg
LV UUID 44f7qf-VlUF-7U7Z-VZA9-l9ht-XwsD-pCYQfy
LV Write Access read/write
LV Creation host, time uctoolbox-dev, 2019-04-06 20:42:42 +0200
LV Status available
# open 1
LV Size 25.80 GiB
Current LE 6606
Segments 2
Allocation inherit
Read ahead sectors auto
lvextend -L+34G /dev/uctoolbox-vg/var
Size of logical volume uctoolbox-vg/var changed from 25.80 GiB (6606 extents) to 59.80 GiB (15310 extents).
Logical volume uctoolbox-vg/var successfully resized.
resize2fs -p /dev/uctoolbox-vg/var
resize2fs 1.43.4 (31-Jan-2017)
Filesystem at /dev/uctoolbox-vg/var is mounted on /var; on-line resizing required
old_desc_blocks = 4, new_desc_blocks = 8
The filesystem on /dev/uctoolbox-vg/var is now 15677440 (4k) blocks long.
AFTER ALL OPERATIONS:
root@uctoolbox:~# fdisk -l
Disk /dev/sda: 80 GiB, 85899345920 bytes, 167772160 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: 0xd52d11a4
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 156250000 155748243 74.3G 5 Extended
/dev/sda5 501760 156250000 155748241 74.3G 8e Linux LVM
Disk /dev/mapper/uctoolbox--vg-root: 7.8 GiB, 8308916224 bytes, 16228352 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/uctoolbox--vg-swap_1: 1020 MiB, 1069547520 bytes, 2088960 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/uctoolbox--vg-tmp: 576 MiB, 603979776 bytes, 1179648 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/uctoolbox--vg-home: 4.7 GiB, 4999610368 bytes, 9764864 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/uctoolbox--vg-var: 59.8 GiB, 64214794240 bytes, 125419520 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
The lvextend is not applicable as the volume group first has to be resized.
1) Resize the partition /dev/sda2 in fdisk to the maximum cylinders/sectors available.
2) Then resize /dev/sda5 accordingly.
3) Then this command should do the trick: pvresize /dev/sda5
Check with command "vgs" the status of the volume group afterwards.
Alternatively create /dev/sda6 in fdisk to take up the rest of the device, also of type "Linux LVM". Then add the new physical volume: pvcreate /dev/sda6
Again: Check with "vgs" the status of the volume group afterwards.
Did you create the
/dev/sda5
partition ?