Need help: how to get SAI and kernel modules out of an existing SONiC image?

101 views
Skip to first unread message

dodol...@gmail.com

unread,
Apr 8, 2026, 9:37:13 PM (7 days ago) Apr 8
to sonicp...@googlegroups.com
Hi everyone,
I’m fairly new to SONiC and hoping someone can point me in the right direction.
Our switch vendor gave us a working SONiC image (.bin file) for our hardware, and it runs fine. But now I’d like to try building SONiC from source so I can make some modifications.
The problem is, I don’t think the SAI library for our platform is available anywhere publicly — it seems like it’s only included in the image the vendor gave us. Same for some kernel modules.
So I’m wondering — is there a way to extract those packages from the .bin image? I’m not really sure how the image is structured internally. I tried poking around but I’m a bit lost on where things are stored.
Specifically:
• How do I open up a .bin image and look at what’s inside?
• Where would the SAI package and kernel modules normally be?
• Once I have them, how do I tell the build system to use those instead of downloading them?
Sorry if this is a basic question — I searched around but couldn’t find a clear guide on this. Any help would be really appreciated!

黃俊睿

unread,
Apr 10, 2026, 2:45:14 AM (6 days ago) Apr 10
to sonicproject

Extracting the SAI library from an image is a relatively complex operation. If you already have the hardware, I recommend installing it directly onto the machine. You can then find libsai.so within syncd container.

奶油君

unread,
Apr 10, 2026, 3:34:06 AM (6 days ago) Apr 10
to sonicproject
Thanks for the help! I logged into the running device and got into the syncd container with docker exec -it syncd bash.
Now I have a few follow-up questions — sorry in advance, I'm pretty new to this:

Once inside the syncd container, how do I identify which files are the SAI library? I see a lot of .so files and I'm not sure which ones are SAI-related and which are just general dependencies.
If my goal is to build my own SONiC image using sonic-buildimage, are there other components besides SAI that I also need to extract? For example, are there platform drivers or kernel modules on the host side that I should grab too?
After I collect all the necessary files, how would I repackage them into .deb packages? Is there a standard approach for this?
Once I have the .deb packages ready, what do I need to modify in the sonic-buildimage repo so that the build system uses my repacked packages instead of trying to pull them from somewhere else?

Thanks again for pointing me in the right direction!

黃俊睿 在 2026年4月10日 星期五下午2:45:14 [UTC+8] 的信中寫道:

chenchi

unread,
Apr 12, 2026, 9:06:35 PM (3 days ago) Apr 12
to sonicproject
you just need to use dpkg-repack to repackage it.

奶油君 在 2026年4月10日 星期五下午3:34:06 [UTC+8] 的信中寫道:

奶油君

unread,
Apr 13, 2026, 3:56:47 AM (3 days ago) Apr 13
to sonicproject
Thanks! That's helpful — I'll look into dpkg-repack.
But I'm still a little unsure about the earlier steps before I get to that point. When I'm inside the syncd container, how do I know which packages to run dpkg-repack on? Like, is there a way to figure out which installed packages are the SAI-related ones? I tried dpkg -l but I got a long list and I'm not sure which ones I actually need.
And besides the packages inside the syncd container, is there anything else on the host side I should also repack? I saw some .ko files under /lib/modules/ and I'm not sure if those are important for my build too.
Lastly — once I have the repacked .deb files, where exactly do I drop them in the sonic-buildimage tree? Do I just put them in target/debs/ or is there something else I need to change so the build system knows to use them?
Sorry to keep asking — just trying to connect all the dots. Thanks!

chenchi 在 2026年4月13日 星期一上午9:06:35 [UTC+8] 的信中寫道:
Reply all
Reply to author
Forward
0 new messages