How to run SONiC VS in VirtualBox?

[stordis-toc]


Introduction

This article explains how to import a SONiC Virtual Switch (SONiC-VS) image into Oracle VirtualBox and run it as a custom node. The procedure covers image download, conversion, node definition creation, image upload, and basic post-deployment validation. 


Download the SONiC-VS Image

SONiC Virtual Switch images are published as builds. The most important is that we need to download the SONiC .vhdx image.

Please refer to article at our support side how to download pre-built SONiC image - 


Convert Using VBoxManage

You can use VBoxManage that comes with VirtualBox to convert the SONiC VS image from VHDX to VDI

VBoxManage clonehd sonic-vs.vhdx sonic-vs-202311.441687.vdi --format VDI

The resulting VDI file can then be used in the “Create a New Virtual Machine in Oracle VirtualBox” step.

Alternative: Convert the Image to VDI

Use qemu-img to convert the SONiC Virtual Switch image from VHDX to VDI.

qemu-img convert -p -f vhdx -O vdi sonic-vs.vhdx sonic-vs-202311.441687.vdi

After conversion, verify the image integrity:

qemu-img check sonic-vs-202311.441687.vdi

Expected output: 

No errors were found on the image.

You can find the instruction how-to install and use qemu-img in our article there:

How to install and use qemu-img on Windows and Linux?


Create a New Virtual Machine in Oracle VirtualBox

  1. Open Oracle VirtualBox - you can download it here

  2. Click New

 

  1. Configure the virtual machine:

    • Name: SONiC_VS - You can use whatever the name you want to use.

    • OS: Linux

    • OS Distribution and OS Version: Other Linux

     

  2. Click tab "Specify virtual hardware".

    • Base Memory: 4096 MB

    • Number of CPUs: 2

  3. Click tab "Specify virtual hard disk".

    • Select "Use an Existing Virtual Hard Disk Drive" and click the small icon on the right

       

      After that, the new window will appear. Click "Add" button and select the VDI file that you created in the step before. 

      After that, click Finish button at the bottom of the window.


Start your Virtual Machine with SONiC

Now you can start your virtual machine - To do so, please select your new VM and select "Start" button

 

After logging in using the default credentials admin / YourPaSsWoRd you can check the version of the installed SONiC using the following command:

show version

 


Congratulations!

You have successfully set up SONiC VS image in the VirtualBox environment. Now you can proceed with your tests.

Happy networking!

Useful links:

Where to download the SONiC Virtual Switch (VS) community pre-built image?

How to import Community SONiC to Cisco Modeling Labs (CML)?

How to install and use qemu-img on Windows and Linux?

Comments 0

Articles in this section