resizing a netbsd vm's disk

#author_luna #sysadmin-notes #netbsd

this took me a little while to learn but here is the process

  1. resize the disk (with qemu-img)
  2. boot into netbsd installer, exit the installer
  3. use dmesg to find out which disk is it mapped to
    1. i'm sure there's a better way to actually find out... i don't know how. an lsblk-type tool would help immensely
    2. for example, /dev/wd0 is the disk, but the partitions are wd0a/dk0 and wd0b/dk1 (root and swap respectively)
  4. use gpt show wd0 and keep the manpages for gpt(8) close to you. for my case
    1. delete swap partition
    2. resize root partition up to my desired space
    3. create swap partition with the remaining space
  5. then tell ffs that it got new space to expand to resize_ffs /dev/dk0
  6. reboot. profit