Skip to content

Instantly share code, notes, and snippets.

@Sh4pe
Last active April 27, 2018 06:13
Show Gist options
  • Save Sh4pe/3d761e0aa57f38ca45a766b8661bdc06 to your computer and use it in GitHub Desktop.
Save Sh4pe/3d761e0aa57f38ca45a766b8661bdc06 to your computer and use it in GitHub Desktop.
Problems with bcc inside virtual machine
#!/usr/bin/env bash
# Setup for everything needed + cargo
set -ex
# In my original case, here is some setup code for Cargo (https://crates.io).
# I've left it out since I'm sure my problem with bcc does not depend on these settings.
# Setup bcc as described in the Ubuntu install instructions at
# https://github.com/iovisor/bcc/blob/master/INSTALL.md#ubuntu---binary
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys D4284CDD
echo "deb https://repo.iovisor.org/apt/xenial xenial main" | sudo tee /etc/apt/sources.list.d/iovisor.list
sudo apt-get update
sudo apt-get install -y bcc-tools libbcc-examples linux-headers-$(uname -r)
#!/usr/bin/env bash
# This script I've borrowed from the setup up of iovisor's own
# Vagrant box to test xdp, see
# https://github.com/iovisor/xdp-vagrant/blob/master/setup-kernel.sh
if [[ "$USER" != "root" ]]; then
echo "script must run as root"
exit 1
fi
set -eux
export DEBIAN_FRONTEND=noninteractive
apt-get install linux-image-4.9.0-0.bpo.2-amd64 linux-headers-4.9.0-0.bpo.2-amd64
# -*- mode: ruby -*-
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/xenial64"
config.vm.provider "virtualbox" do |vb|
vb.memory = "8192"
vb.cpus = 4
end
# These env vars are not important for my example, contained here
# for completeness
config.vm.provision "shell", inline: "echo export RUSTUP_HOME=/usr/local/rustup >> /home/vagrant/.bashrc"
config.vm.provision "shell", inline: "echo export CARGO_HOME=/usr/local/cargo >> /home/vagrant/.bashrc"
config.vm.provision "shell", inline: "echo export PATH=/usr/local/cargo/bin:$PATH >> /home/vagrant/.bashrc"
config.vm.provision "shell", inline: "echo export CARGO_TARGET_DIR=target_vagrant >> /home/vagrant/.bashrc"
config.vm.provision "shell", :privileged => true, path: "etc/vagrant/setup-cargo.sh"
config.vm.provision "shell", :privileged => true, path: "etc/vagrant/setup-kernel.sh"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment