Skip to content

Instantly share code, notes, and snippets.

@leifwalsh
Created August 7, 2013 21:08
Show Gist options
  • Save leifwalsh/6178694 to your computer and use it in GitHub Desktop.
Save leifwalsh/6178694 to your computer and use it in GitHub Desktop.
resize ubuntu 12.10 root partition (after resizing virtualbox disk)
$ fdisk /dev/sda
Command (m for help): p
Disk /dev/sda: 137.4 GB, 137438953472 bytes
255 heads, 63 sectors/track, 16709 cylinders, total 268435456 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 identifier: 0x0007427a
Device Boot Start End Blocks Id System
/dev/sda1 * 2048 499711 248832 83 Linux
/dev/sda2 501758 20764671 10131457 5 Extended
/dev/sda5 501760 20764671 10131456 8e Linux LVM
Command (m for help): d
Partition number (1-5): 5
Command (m for help): d
Partition number (1-5): 2
Command (m for help): n
Partition type:
p primary (1 primary, 0 extended, 3 free)
e extended
Select (default p): e
Partition number (1-4, default 2):
Using default value 2
First sector (499712-268435455, default 499712):
Using default value 499712
Last sector, +sectors or +size{K,M,G} (499712-268435455, default 268435455):
Using default value 268435455
Command (m for help): n
Partition type:
p primary (1 primary, 1 extended, 2 free)
l logical (numbered from 5)
Select (default p): l
Adding logical partition 5
First sector (501760-268435455, default 501760):
Using default value 501760
Last sector, +sectors or +size{K,M,G} (501760-268435455, default 268435455):
Using default value 268435455
Command (m for help): t
Partition number (1-5): 5
Hex code (type L to list codes): 8e
Changed system type of partition 5 to 8e (Linux LVM)
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.
$ reboot
$ pvresize /dev/sda5
$ lvresize -l '+100%FREE' /dev/quantal64/root
$ resize2fs -p /dev/quantal64/root
$ reboot
@leifwalsh
Copy link
Author

copy-paste-able sudo pvresize /dev/sda5 && sudo lvresize -l '+100%FREE' /dev/quantal64/root && sudo resize2fs -p /dev/quantal64/root

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