- français
- English
resizevm
Quick notes on how to resize a Ubuntu VM using ext4 and LVM.
- http://ryandoyle.net/posts/expanding-a-lvm-partition-to-fill-remaining-drive-space/
- https://askubuntu.com/a/119458/214944
- https://blog.sleeplessbeastie.eu/2012/05/14/how-to-backup-dos-type-partition-table-gpt-and-lvm-metadata/
FIRST MAKE A SNAPSHOT
SECOND BACKUP ALL PARTION/META DATA (
$ DOS: sudo sfdisk -d /dev/sda > sda_partitions
$ GPT: sudo sgdisk -b sda_gpt_backup /dev/sda
$ LVM: sudo lvm vgcfgbackup -f lvm_backup_vg my_vg_name
)
THE IDEA IS TO DELETE THE PARTITION TABLE AND RECREATE IT AT THE EXACT SAME PLACE WITHOUT TOUCHING AT THE DATA ON THE DISK.
USE IT AT YOUR OWN RISKS!
- Use
fdisk /dev/sda
to check the partition withp
Use "d" to delete the partition
Use "n" to create a new partition
Check again with "p"
If the Type / System is not the same that the previous check, use "t" to set it (e.g. "8e" for Linux LVM)
If the boot flag is gone, use the "a" to replace it.
Check again with "p" and,
if you are really really really sure of your backups, press "w"
reboot
Now you should be able to see some free space with "lsblk" (sda1 is extendend but not the LVM)
pvresize /dev/sda1
- lvresize -l +100%FREE /dev/ielgesrv4-vg/root
- resize2fs /dev/ielgesrv4-vg/root (PROBABLY NOT NEEDED)
- check with pvdisplay, vgdisplay, lvdisplay
- You are done