Skip to content

pkg_add is working very slow on NetBSD

Host environment

  • Operating system: openSUSE Tumbleweed
  • OS/kernel version: Linux 5.17.1-1-default #1 SMP PREEMPT Thu Mar 31 05:28:33 UTC 2022 (58205bc) x86_64 x86_64 x86_64 GNU/Linux
  • Architecture: x86_64
  • QEMU flavor: qemu-system-x86_64
  • QEMU version: Tested on both 6.2.0 and 6.2.94
  • QEMU command line:
# Run
 qemu-system-x86_64 -m 2048 \
  -drive if=virtio,file=disk.qcow2,format=qcow2 \
  -enable-kvm  \
  -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7722-:22 \
  -device e1000,netdev=mynet0

# In NetBSD
export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r)/All/" && \
pkg_add pkgin

Emulated/Virtualized environment

  • Operating system: NetBSD
  • OS/kernel version: 9.2
  • Architecture: x86_64

Description of problem

pkg_add is working very slow, it installs one package in ~30 minutes although network speed is normal.

Steps to reproduce

  1. wget https://cdn.netbsd.org/pub/NetBSD/NetBSD-9.2/images/NetBSD-9.2-amd64.iso
  2. qemu-img create -f qcow2 disk.qcow2 15G
  3. Install
qemu-system-x86_64 -m 2048 -enable-kvm \
  -drive if=virtio,file=disk.qcow2,format=qcow2 \
  -netdev user,id=mynet0,hostfwd=tcp::7722-:22 \
  -device e1000,netdev=mynet0 \
  -cdrom NetBSD-9.2-amd64.iso
   # Installation steps
   - 1) Boot Normally
   - a) Installation messages in English
   - a) unchanged
   - a) Install NetBSD to hard disk
   - b) Yes
   - a) 15G
   - a) GPT
   - a) This is the correct geometry
   - b) Use default partition sizes
   - x) Partition sizes are ok
   - b) Yes
   - a) Use BIOS console
   - b) Installation without X11
   - a) CD-ROM / DVD / install image media
   - Hit enter to continue
   - a) configure network (Select defaults here, perform autoconf)
   - x) Finished configuring
   - Hit enter to continue
   - x) Exit Install System
   - Close QEMU
  1. Run
 qemu-system-x86_64 -m 2048 \
  -drive if=virtio,file=disk.qcow2,format=qcow2 \
  -enable-kvm  \
  -netdev user,id=mynet0,hostfwd=tcp:127.0.0.1:7722-:22 \
  -device e1000,netdev=mynet0
  1. Login as root
  2. In NetBSD
export PKG_PATH="http://cdn.NetBSD.org/pub/pkgsrc/packages/NetBSD/$(uname -p)/$(uname -r)/All/" && \
pkg_add pkgin

You should see that each of the package's installation takes ~30 minutes.

Additional information

NetBSD 9.2 is also tested in Debian 11 with 'QEMU 6.2.0' and encountered same slowness.

NetBSD 7.1 and 8.1 are tested on openSUSE Tumbleweed and encountered same slowness.

OpenBSD's pkg_add is working correctly.

I am not sure if it will help but Virtualbox(at least 6.1) is working correctly.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information