Problem extending partition for hass.io on Ubuntu Server

I have a Ubuntu Server VM running on my ESXi box for Home-Assistent (hass.io). And it has worked pretty well, until now. I am not able to update Home-Assistant due to low disc capasity. Since this is an VM i have changed the disc spance for the VM from 10GB to 24GB. But now I need to expand the partition, witch I have some problems with.

I have tried to follow this guide, but are stuck on “Extend your Logical Volume with the new partition” or maybe before

this is what I have done:

Summary
# flemmingss@Home-Assistant:~$ ls  /sys/class/scsi_host/
# host0   host11  host14  host17  host2   host22  host25  host28  host30  host4  host7
# host1   host12  host15  host18  host20  host23  host26  host29  host31  host5  host8
# host10  host13  host16  host19  host21  host24  host27  host3   host32  host6  host9
# flemmingss@Home-Assistant:~$ fdisk -l
# fdisk: cannot open /dev/sda: Permission denied
# fdisk: cannot open /dev/mapper/Home--Assistant--vg-root: Permission denied
# fdisk: cannot open /dev/mapper/Home--Assistant--vg-swap_1: Permission denied
# flemmingss@Home-Assistant:~$ sudo fdisk -l
# [sudo] password for flemmingss:
# Disk /dev/sda: 24 GiB, 25769803776 bytes, 50331648 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: 0xfce72dba
# 
# Device     Boot   Start      End  Sectors  Size Id Type
# /dev/sda1  *       2048   999423   997376  487M 83 Linux
# /dev/sda2       1001470 20969471 19968002  9.5G  5 Extended
# /dev/sda5       1001472 20969471 19968000  9.5G 8e Linux LVM
#  
# 
# 
# 
# Disk /dev/mapper/Home--Assistant--vg-root: 8.8 GiB, 9395240960 bytes, 18350080 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/Home--Assistant--vg-swap_1: 764 MiB, 801112064 bytes, 1564672 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
# flemmingss@Home-Assistant:~$ fdisk /dev/sda
# 
# Welcome to fdisk (util-linux 2.27.1).
# Changes will remain in memory only, until you decide to write them.
# Be careful before using the write command.
# 
# fdisk: cannot open /dev/sda: Permission denied
# flemmingss@Home-Assistant:~$ sudo fdisk /dev/sda
# 
# Welcome to fdisk (util-linux 2.27.1).
# Changes will remain in memory only, until you decide to write them.
# Be careful before using the write command.
# 
# 
# Command (m for help): n
# Partition type
#   p   primary (1 primary, 1 extended, 2 free)
#   l   logical (numbered from 5)
# Select (default p): p
# Partition number (3,4, default 3): 3
# First sector (999424-50331647, default 999424):
# Last sector, +sectors or +size{K,M,G,T,P} (999424-1001469, default 1001469):
#  
# Created a new partition 3 of type 'Linux' and of size 1023 KiB.
# 
# Command (m for help): t
# Partition number (1-3,5, default 5): 3
# Partition type (type L to list all types): 8e
# 
# Changed type of partition 'Linux' to 'Linux LVM'.
# 
# Command (m for help): w
# The partition table has been altered.
# Calling ioctl() to re-read partition table.
# Re-reading the partition table failed.: Device or resource busy
#  
# The kernel still uses the old table. The new table will be used at the next reboot or after you run partprobe(8) or kpartx(8).
# 
# flemmingss@Home-Assistant:~$
# 
# ***REBOOT****

And this is what happen when I try to extend the volume:

flemmingss@Home-Assistant:~$ sudo vgextend Home-Assistant-vg /dev/sda3
  Device /dev/sda3 not found (or ignored by filtering).
  Unable to add physical volume '/dev/sda3' to volume group 'Home-Assistant-vg'.

Here are my current status:
fdisk -l

flemmingss@Home-Assistant:~$ sudo fdisk -l
Disk /dev/sda: 24 GiB, 25769803776 bytes, 50331648 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: 0xfce72dba

Device     Boot   Start      End  Sectors  Size Id Type
/dev/sda1  *       2048   999423   997376  487M 83 Linux
/dev/sda2       1001470 20969471 19968002  9.5G  5 Extended
/dev/sda3        999424  1001469     2046 1023K 8e Linux LVM
/dev/sda5       1001472 20969471 19968000  9.5G 8e Linux LVM

Partition table entries are not in disk order.


Disk /dev/mapper/Home--Assistant--vg-root: 8.8 GiB, 9395240960 bytes, 18350080 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/Home--Assistant--vg-swap_1: 764 MiB, 801112064 bytes, 1564672 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
flemmingss@Home-Assistant:~$

pvscan

flemmingss@Home-Assistant:~$ sudo pvscan
  PV /dev/sda5   VG Home-Assistant-vg   lvm2 [9.52 GiB / 24.00 MiB free]
  Total: 1 [9.52 GiB] / in use: 1 [9.52 GiB] / in no VG: 0 [0   ]

vgdisplay

flemmingss@Home-Assistant:~$ sudo vgdisplay
  --- Volume group ---
  VG Name               Home-Assistant-vg
  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               9.52 GiB
  PE Size               4.00 MiB
  Total PE              2437
  Alloc PE / Size       2431 / 9.50 GiB
  Free  PE / Size       6 / 24.00 MiB
  VG UUID               0wPc92-CBZG-mYBJ-vIpk-JYrO-uyij-c53LNq

lsblk

flemmingss@Home-Assistant:~$ lsblk
NAME                           MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                              8:0    0   24G  0 disk
├─sda1                           8:1    0  487M  0 part /boot
├─sda2                           8:2    0    1K  0 part
├─sda3                           8:3    0 1023K  0 part
└─sda5                           8:5    0  9.5G  0 part
  ├─Home--Assistant--vg-root   252:0    0  8.8G  0 lvm  /
  └─Home--Assistant--vg-swap_1 252:1    0  764M  0 lvm  [SWAP]
sr0                             11:0    1 1024M  0 rom

So, do anyone have a solution for me?
I can say I am not a linux person, so in detail please.

I am thinking this is because there is no room between sda3 and sda2. You can’t expand a partition without some spare space.

But I have total of 24GB?

flemmingss@Home-Assistant:~$ sudo fdisk -l
Disk /dev/sda: 24 GiB, 25769803776 bytes, 50331648 sectors

Boot up a live distro with a GUI and it will be much easier.

GParted, resize your partitions, and then run your LVM commands.

Not a bad ide, I will try that

any ide how I can unlock this?

when i right click i only got “manage flags” and “info”

also tried this in console:
wapoff -a
swapoff -a /dev/sda2
umount /dev/sda2

sda2 is an extended partition. sda5 is inside sda2. I think it is sda5 you need to deal with.

Well, i left it to watch some youtube, and when I came back the locks was gone, so no its done :slight_smile:

Well, but now i see that size may not be the couse for the update problems.
WARNING (MainThread) [hassio.host.services] Can’t update host service information!

Well well, looks like i was wrong, when I try apt-get update it say 28: No space left on device)

flemmingss@Home-Assistant:~$ lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 24G 0 disk
├─sda1 8:1 0 487M 0 part /boot
├─sda2 8:2 0 1K 0 part
├─sda3 8:3 0 1023K 0 part
└─sda5 8:5 0 23.5G 0 part
├─Home–Assistant–vg-root 252:0 0 8.8G 0 lvm /
└─Home–Assistant–vg-swap_1 252:1 0 764M 0 lvm [SWAP]

Why don’t you try deleting some unneeded files ?

eg /var/cache/apt/archives is disposable, and often collects a lot of crap.

Well, now that I have resized the drive I might as well extend it to be used for somthing.

Also tried this:

flemmingss@Home-Assistant:~$ sudo resize2fs /dev/mapper/Home--Assistant--vg-root
resize2fs 1.42.13 (17-May-2015)
The filesystem is already 2293760 (4k) blocks long.  Nothing to do!

btw: are all files in that dir unneeded and safe to delete?

Yes they are a cache of downloaded packages that have already been installed.

By the way, it is a long time since I used lvm, but when I did, I found I couldn’t find anything better than

Thanks for the link. But still not able to solve this.
But do anyone else have some suggestions?

I fixed this problem by reinstalling ubuntu :slight_smile:

Well that was overkill

Well, it was done in 40 minutes including install of Hass.io and backup/restore. Way less time then I have used to try to extend the partition until now.