I've just manually tested on raring, and the following seems to work the whole way through, when having installed psusi's branch at https://code.launchpad.net/~psusi/ubuntu/raring/util-linux/cherry-pick-resize and the new growpart with gpt partition support.
$ img=/tmp/my.img $ mp=/tmp/mp $ size=800M $ osize="400M" $ sudo rm -f $img; sudo rm -Rf $mp; sudo mkdir $mp
## create a new image $osize big $ sudo truncate --size $osize "$img"
## add a single GPT partition that takes up the whole image $ sudo sgdisk --new 1:2048: "$img"
## grow the image (as a hypervisor would do) $ sudo truncate --size $size $img
## attach the image to a device $ lodev=$(sudo losetup --show --find "$img") $ echo $lodev /dev/loop0
## put a filesystem on it, mount it, then grow the partition $ sudo mkfs.ext4 ${lodev}p1 $ sudo mount ${lodev}p1 "$mp" $ sudo growpart ${lodev} 1
## /proc/partitions still has old information
## tell kernel about grown partition $ sudo partx --update 1 ${lodev}
## /proc/partitions has new information
## filesystem can now be re-sized $ sudo resize2fs ${lodev}p1
I've just manually tested on raring, and the following seems to work the whole way through, when having installed psusi's branch at https:/ /code.launchpad .net/~psusi/ ubuntu/ raring/ util-linux/ cherry- pick-resize and the new growpart with gpt partition support.
$ img=/tmp/my.img
$ mp=/tmp/mp
$ size=800M
$ osize="400M"
$ sudo rm -f $img; sudo rm -Rf $mp; sudo mkdir $mp
## create a new image $osize big
$ sudo truncate --size $osize "$img"
## add a single GPT partition that takes up the whole image
$ sudo sgdisk --new 1:2048: "$img"
## grow the image (as a hypervisor would do)
$ sudo truncate --size $size $img
## attach the image to a device
$ lodev=$(sudo losetup --show --find "$img")
$ echo $lodev
/dev/loop0
## put a filesystem on it, mount it, then grow the partition
$ sudo mkfs.ext4 ${lodev}p1
$ sudo mount ${lodev}p1 "$mp"
$ sudo growpart ${lodev} 1
## /proc/partitions still has old information
## tell kernel about grown partition
$ sudo partx --update 1 ${lodev}
## /proc/partitions has new information
## filesystem can now be re-sized
$ sudo resize2fs ${lodev}p1