truncate
:
truncate -s<newsize> ubuntu.img
fdisk
or gdisk
remove the partition and create a larger one starting from the same sector. Then reboot Ubuntu and run:
resize2fs <device_node>
mdconfig ubuntu.img
gpart show md0
gpart resize -iN md0 # N - the partition index
resize2fs /dev/md0sN # could be md0pN in case of GPT scheme
mdconfig -d -u0
gpart recover md0
before resizing the partition with gpart().