<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by belltoy on Medium]]></title>
        <description><![CDATA[Stories by belltoy on Medium]]></description>
        <link>https://medium.com/@belltoy?source=rss-6ccf632f8a5f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*fsUQ6A1TOyVbJ4ayfdoXBA.jpeg</url>
            <title>Stories by belltoy on Medium</title>
            <link>https://medium.com/@belltoy?source=rss-6ccf632f8a5f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 18:16:02 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@belltoy/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[The Rust eBPF development environment on M1 macOS]]></title>
            <link>https://medium.com/@belltoy/the-rust-ebpf-development-environment-on-m1-macos-cb6545625f5a?source=rss-6ccf632f8a5f------2</link>
            <guid isPermaLink="false">https://medium.com/p/cb6545625f5a</guid>
            <category><![CDATA[ebpf]]></category>
            <category><![CDATA[rust-programming-language]]></category>
            <dc:creator><![CDATA[belltoy]]></dc:creator>
            <pubDate>Sat, 24 Jan 2026 09:22:40 GMT</pubDate>
            <atom:updated>2026-01-24T16:57:09.965Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yuYNfEoKfhggRxvHy82H-A.png" /><figcaption>Generated by Gemini</figcaption></figure><p>eBPF (Extended Berkeley Packet Filter) is a powerful Linux kernel technology that allows developers to run sandboxed programs directly within the kernel, extending its functionality safely and efficiently without changing source code or loading modules.</p><p>On macOS, we need a virtual machine to test and run eBPF programs. There are several choices, including Docker, Lima, QEMU, VirtualBox, VMWare, etc. Some of them do not support all kinds of eBPF programs. For example, if you want to run XDP programs, you need to use a VM that supports full networking features. In this tutorial, we will set up an eBPF development environment using VirtualBox on an M1 macOS machine.</p><p>Before the Apple M1 (ARM architecture), I used VirtualBox on Intel macOS to run an Ubuntu VM for eBPF development. Back then, I was using the <a href="https://crates.io/crates/redbpf">redbpf</a> library, which has been deprecated, to write eBPF programs in Rust. After switching to M1 macOS, VirtualBox was not available for a long time. Recently, I found that VirtualBox now supports ARM architecture and can run ARM-based Linux distributions. This makes it possible to set up an eBPF development environment on M1 macOS using VirtualBox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9H_wbRR_Nvh-ehuxuFXQxg.png" /><figcaption>VirtualBox on M1 macOS</figcaption></figure><h4>Prerequisites</h4><pre>brew install filosottile/musl-cross/musl-cross</pre><p>By default, it will install full cross compiler toolchains targeting <em>musl</em> Linux amd64, arm64, and arm.</p><pre>which x86_64-linux-musl-gcc<br>which aarch64-linux-musl-gcc</pre><p>Install VirtualBox for Apple Silicon hosts from <a href="https://www.virtualbox.org/wiki/Downloads">here</a>.</p><p>Install <em>rustup</em> and Rust toolchain if you haven’t already:</p><pre>curl --proto &#39;=https&#39; --tlsv1.2 -sSf https://sh.rustup.rs | sh<br>rustup target install aarch64-unknown-linux-musl<br>rustup target install x86_64-unknown-linux-musl</pre><p>Install <em>vagrant</em> via <em>homebrew</em>:</p><pre>brew tap hashicorp/tap<br>brew install hashicorp/tap/hashicorp-vagrant</pre><p>Install the <em>vagrant-reload</em> plugin to allow reloading the VM without destroying it:</p><pre>vagrant plugin install vagrant-reload</pre><h4>Set up the VM</h4><p>Create a <em>Vagrantfile</em> with the following content in your project directory:</p><pre>Vagrant.configure(&quot;2&quot;) do |config|<br>  config.vm.box = &quot;cloud-image/debian-13&quot;<br>  config.vm.box_version = &quot;20260112.2355.0&quot;<br><br>  # Disable synced folder<br>  config.vm.synced_folder &quot;.&quot;, &quot;/vagrant&quot;, disabled: true<br>  config.vm.synced_folder &quot;.&quot;, &quot;/home/vagrant/aya-hello&quot;, automount: true<br><br>  config.vm.network &quot;private_network&quot;, type: &quot;dhcp&quot;<br>  config.vm.box_check_update = false<br><br>  config.vagrant.plugins = [&quot;vagrant-reload&quot;]<br><br>  config.vm.provider &quot;virtualbox&quot; do |virtualbox|<br>    virtualbox.memory = 4096<br>    virtualbox.cpus = 2<br>  end<br><br>  # Eventually use cloud-init to execute jobs<br>  config.vm.cloud_init do |cloud_init|<br>    cloud_init.content_type = &quot;text/cloud-config&quot;<br>    cloud_init.inline = &lt;&lt;-EOF<br>      apt:<br>        ## Use mirrors if needed<br>        # primary:<br>        #   - arches: [default]<br>        #     uri: https://mirrors.ustc.edu.cn/debian<br>        # security:<br>        #   - arches: [default]<br>        #     uri: https://mirrors.ustc.edu.cn/debian-security<br><br>      package_update: true<br><br>      packages:<br>        - build-essential<br>        - linux-headers-arm64<br>        - dkms<br>        - bpfcc-tools<br>        - bpftool<br><br>      runcmd:<br>        - wget http://download.virtualbox.org/virtualbox/7.2.4/VBoxGuestAdditions_7.2.4.iso<br>        - mkdir /media/VBoxGuestAdditions<br>        - mount -o loop,ro VBoxGuestAdditions_7.2.4.iso /media/VBoxGuestAdditions<br>        - sh /media/VBoxGuestAdditions/VBoxLinuxAdditions-arm64.run<br>        - rm VBoxGuestAdditions_7.2.4.iso<br>        - umount /media/VBoxGuestAdditions<br>        - rmdir /media/VBoxGuestAdditions<br>        - sed -i -e &#39;s/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/&#39; /etc/locale.gen<br>        - echo &#39;LANG=&quot;en_US.UTF-8&quot;&#39; &gt; /etc/default/locale<br>        - dpkg-reconfigure --frontend=noninteractive locales<br>        - update-locale LANG=en_US.UTF-8<br>        - chsh -s /bin/bash vagrant<br>    EOF<br>  end<br>end</pre><h4>Cross-compile and run eBPF program</h4><p>To cross-compile the eBPF program for the VM, run the following command on your macOS host:</p><pre>cargo build --release --target=aarch64-unknown-linux-musl</pre><p>Start the VM:</p><pre>vagrant up</pre><p>Wait for the VM to be fully set up. This may take some time as it installs the necessary packages.</p><p>SSH into the VM:</p><pre>vagrant ssh</pre><p>Navigate to the shared folder where your project is located:</p><pre>cd /home/vagrant/aya-hello</pre><p>Run the eBPF program inside the VM:</p><pre>sudo RUST_LOG=debug target/aarch64-unknown-linux-musl/release/aya-hello</pre><h4>Conclusion</h4><p>You have successfully set up an eBPF development and test environment on M1 macOS using VirtualBox. VirtualBox provides a full-featured VM with networking support, making it suitable for testing various types of eBPF programs, including XDP.</p><p>If you are not developing eBPF programs for network devices, you can also consider other VM solutions such as Docker, Lima, or QEMU, based on your requirements.</p><p>You can find the complete code for this tutorial in the <a href="https://github.com/belltoy/aya-hello">aya-hello</a> repository.</p><h4>References</h4><ul><li><a href="https://rustup.rs/">rustup.rs</a></li><li><a href="https://developer.hashicorp.com/vagrant/install">Install Vagrant</a></li><li><a href="https://brew.sh/">Homebrew</a></li><li><a href="https://github.com/FiloSottile/homebrew-musl-cross">homebrew-musl-cross</a></li><li><a href="https://www.virtualbox.org/wiki/Downloads">VirtualBox for Apple Silicon hosts</a></li><li><a href="https://aya-rs.dev/">Aya</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cb6545625f5a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>