FreeBSD disk extend


I use KVM. I upgraded to a single disk that was owned by FreeBSD with Qemu. But the disk "ROOT" is still small. What should I do for it ?

root@test:~ # gpart show ada0
=>      34  83886013  ada0  GPT  (40G)
           34      1024    1  freebsd-boot  (512K)
      1058  39844864   2  freebsd-ufs  (19G)
  39845922   2097084 3  freebsd-swap  (1.0G)
  41943006  41943041        - free -  (20G)

I did so;
root@test:~ # gpart resize -i 2 -s 20971520 ada0
gpart: Device busy

How can I do this safely?

It should be:

gpart resize -i 1 -s 20G ada0
growfs /dev/ada0p1

I did that also around a month ago.

Thanks. But , the disk is giving a busy warning ?

root@test:~ # gpart resize -i 2 -s 20971520 ada0
gpart: Device busy

growfs /dev/ada0p2
growfs: requested size 19GB is not larger than the current filesystem size 19GB
I just realized that the disk that I grew did not have a boot sector. So, the information that I gave you might me wrong: gpart resize [B]-i 1[/B] -s 20G ada0

In your case it should be gpart resize [B]-i 2[/B] -s 20G ada0, however since this is the root partition, I believe that you need to boot off from an install medium and do it from there.
Note, that you will need to remove the swap partition first before you can extend the freebsd-ufs partition.

It's a good idea to put the swap partition before the root partition for virtual machines, that will make it easier to extend the freebsd-ufs partition as the swap won't be in the way.