Skip to content

Instantly share code, notes, and snippets.

@blakethepatton
Last active February 19, 2022 16:58
Show Gist options
  • Save blakethepatton/34076bc58d17df075f3bb8ccd9fa83c0 to your computer and use it in GitHub Desktop.
Save blakethepatton/34076bc58d17df075f3bb8ccd9fa83c0 to your computer and use it in GitHub Desktop.
Live expand disk ubuntu and esx

Expand the disk in esx

Take a snapshot

sudo su

make it look for the bigger disks

echo "1" > /sys/class/scsi_disk/{your device here}/device/rescan

make sure it's seen the change

lsblk

https://askubuntu.com/questions/24027/how-can-i-resize-an-ext-root-partition-at-runtime

$ sudo fdisk /dev/sda

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     9437183     4717568   83  Linux

Command (m for help): d
Selected partition 1

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4, default 1): 1
First sector (2048-10485759, default 2048):
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-10485759, default 10485759):
Using default value 10485759

Command (m for help): p

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1            2048    10485759     5241856   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.

WARNING: Re-reading the partition table failed with error 16: 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)
Syncing disks.

pvresize /dev/sda3

lvextend -r -l +100%FREE /dev/mapper/ubuntu--vg-ubuntu--lv

df -h

Delete your snapshot

Crack on with your holiday (because systems always run out of space when you'd like to be away from your computer).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment