Building a Sonic Vagrant Libvirt Box

You can use the netlab libvirt package command to build a Sonic Vagrant box for a Sonic virtual machine:

  • Download the sonic-vs.img.gz image from Azure or sonic.software into an empty directory.

  • Unzip image with gunzip gz-file-name.

  • Execute netlab libvirt package sonic img-file-name and follow the instructions

Warning

If you’re using a ‌netlab release older than 1.8.2, or if you’re using a Linux distribution other than Ubuntu, please read the box-building caveats first.

Initial Device Configuration

During the box-building process, you might have to disable ZTP or clean up the initial configuration database. The netlab libvirt config sonic command displays the build recipe:

Sonic: Disabling ZTP and Cleaning Initial Configuration
=======================================================

* Wait for the 'login' prompt
* Login as 'admin', password 'YourPaSsWoRd'
* If needed, disable zero-touch with 'sudo config ztp disable --yes'.
  Don't despair, disabling ZTP takes a long while to complete.
* Remove BGP, interface, and MAC address configuration from the initial
  configuration (required on Azure images)
---------------------
sudo bash
cd /etc/sonic
jq "del(.INTERFACE,.BGP_NEIGHBOR,.LOOPBACK_INTERFACE,.DEVICE_METADATA.localhost.mac)" config_db.json >config_db.new
mv config_db.new config_db.json
---------------------
* Power down the virtual machine with 'sudo poweroff'
* If the device starts reloading instead of shutting down, disconnect
  from the console (ctrl-] usually works).