HOW-TO resize a .img Ubuntu guest

Rudy crapsh at monkeybrains.net
Tue Apr 22 21:48:27 UTC 2014


Cloning images and growing them.


We have a 'standard install' image called, 'ubuntu14-clone-me.img'.
To copy, enlarge, and then grow the guest image size, we use the process 
below.  Let's take an Ubuntu image (ubuntu14-clone-me.img), clone it, 
grow the system, then log into the Ubuntu guest (vm12) and resize the / 
partition (all our guests are single partition).



In FreeBSD:
  FreeBSD# gcp --sparse=always ubuntu14-clone-me.img vm12.img
  FreeBSD# truncate -s 300g vm12.img

Launch guest with bhyve, get on console, and use these commands:
  Guest-VM# swapoff -a
  Guest-VM# fdisk /dev/vda
         hit 'p' to print existing table
         delete all the paritions
         recreate partition '1' with same stating block noted in the 'print'
         make end block near end but with enough room for your swap
         create an extended parition '5' and put the rest in there for
         guest swap

  Guest-VM# reboot
  Guest-VM# resize2fs /dev/vda1

Done!

Pro tip: research sparse files, install gcp (pkg install coreutils).


Rudy

MonkeyBrains.net Local ISP


More information about the freebsd-virtualization mailing list