{"id":18349469,"url":"https://github.com/michaeljclark/busybear-linux","last_synced_at":"2025-04-12T18:23:26.794Z","repository":{"id":45768534,"uuid":"114305427","full_name":"michaeljclark/busybear-linux","owner":"michaeljclark","description":"busybear-linux is a tiny RISC-V Linux root filesystem image that targets the VirtIO board in riscv-qemu.","archived":false,"fork":false,"pushed_at":"2024-07-09T08:40:51.000Z","size":36,"stargazers_count":98,"open_issues_count":15,"forks_count":33,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-03-26T12:46:18.293Z","etag":null,"topics":["busybear","busybox","dropbear","linux-kernel","qemu","qemu-riscv","risc-v","riscv-linux","virtio","virtual-machine"],"latest_commit_sha":null,"homepage":"","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/michaeljclark.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-12-14T23:18:38.000Z","updated_at":"2025-03-04T12:49:45.000Z","dependencies_parsed_at":"2024-12-16T04:05:50.106Z","dependency_job_id":"38532f86-a52c-4f20-bb64-2e79069c60ff","html_url":"https://github.com/michaeljclark/busybear-linux","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljclark%2Fbusybear-linux","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljclark%2Fbusybear-linux/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljclark%2Fbusybear-linux/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michaeljclark%2Fbusybear-linux/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michaeljclark","download_url":"https://codeload.github.com/michaeljclark/busybear-linux/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248610844,"owners_count":21133002,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["busybear","busybox","dropbear","linux-kernel","qemu","qemu-riscv","risc-v","riscv-linux","virtio","virtual-machine"],"created_at":"2024-11-05T21:22:17.079Z","updated_at":"2025-04-12T18:23:26.769Z","avatar_url":"https://github.com/michaeljclark.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# busybear-linux\n\nbusybear-linux is a tiny RISC-V Linux root filesystem image that targets\nthe `virt` machine in riscv-qemu. As the name suggests, busybear-linux is\na riscv-linux root image comprised of busybox and dropbear.\n\nThe root image is intended to demonstrate virtio-net and virtio-block in\nriscv-qemu and features a dropbear ssh server which allows out-of-the-box\nssh access to a RISC-V virtual machine.\n\nSee the [releases](https://github.com/michaeljclark/busybear-linux/releases)\nfor pre-built kernel and filesystem images.\n\n## Copyright and License\n\nThe busybear build system has been written by and is\ncopyright (C) 2017 by Michael J. Clark \u003cmichaeljclark@mac.com\u003e.\nEnhancements to the build system have been contributed by and\nare copyright (C) 2017 by Karsten Merker \u003cmerker@debian.org\u003e.\n\nThe busybear build system is provided under the following license\n(\"MIT license\"):\n\nPermission is hereby granted, free of charge, to any person obtaining a\ncopy of this software and associated documentation files (the \"Software\"),\nto deal in the Software without restriction, including without limitation\nthe rights to use, copy, modify, merge, publish, distribute, sublicense,\nand/or sell copies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL\nTHE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\nDEALINGS IN THE SOFTWARE.\n\n## Dependencies\n\n- [riscv-gnu-toolchain](https://github.com/riscv/riscv-gnu-toolchain) (RISC-V Linux toolchain)\n- [busybox](https://busybox.net/) (downloaded automatically)\n- [dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html) (downloaded automatically)\n- sudo, curl, openssl and rsync\n\n## Features\n\n- `ntpd` for time configuration\n- `klog` for kernel logging\n- `syslog` for system logging\n- `dropbear` for ssh access\n- `busybox` with almost everything enabled\n\n## Configuration\n\n- `conf` contains the linux image build configuration\n  - `conf/linux.config` contains the linux-kernel configuration\n  - `conf/busybox.config` contains the busybox configuration\n  - `conf/busybear.config` contains the image build configuration\n    - `ROOT_PASSWORD=busybear`\n    - `IMAGE_FILE=busybear.bin`\n- `etc` contains the linux guest system configuration\n  - `etc/network/interfaces` (guest 192.168.100.2, router 192.168.100.1)\n  - `etc/resolv.conf` (nameserver 8.8.8.8, nameserver 8.8.4.4)\n  - `etc/ntp.conf` (server 0.pool.ntp.org, server 1.pool.ntp.org)\n  - `etc/passwd`, `etc/shadow`, `etc/group` and `etc/hosts`\n\nThe default config assumes bridged networking with `192.168.100.1`\non the host and `192.168.100.2` in the guest.\n\n## Build\n\nThe build process downloads busybox and dropbear, compiles them and prepares\na root filesystem image to the file `busybear.bin`. The build script needs\nto be run in Linux, even if preparing a root filesystem image for macOS.\n\n### busybear-linux\n\n```\ngit clone --recursive https://github.com/michaeljclark/busybear-linux.git\ncd busybear-linux\nmake\n```\n\n### QEMU\n\n```\ngit clone https://github.com/riscv/riscv-qemu.git\ncd riscv-qemu\n./configure --target-list=riscv64-softmmu,riscv32-softmmu\nmake\n```\n\n### riscv-linux\n\n_Note: busybear-linux builds linux kernel automatically_\n\n```\ngit clone https://github.com/riscv/riscv-linux.git\ncd riscv-linux\ngit checkout riscv-linux-4.14\ncp ../busybear-linux/conf/linux.config .config\nmake ARCH=riscv olddefconfig\nmake ARCH=riscv vmlinux\n```\n\n### bbl\n\n_Note: busybear-linux builds bbl automatically_\n\n```\ngit clone https://github.com/riscv/riscv-pk.git\ncd riscv-pk\nmkdir build\ncd build\n../configure \\\n    --enable-logo \\\n    --host=riscv64-unknown-elf \\\n    --with-payload=../../riscv-linux/vmlinux\nmake\n```\n\n## Running\n\nbusybear requires the riscv-qemu `virt` board with virtio-block\nand virtio-net devices.\n\nThe following command starts busybear-linux:\n\n```\n./scripts/run-qemu.sh\n```\n\nwhich runs executes this command:\n\n```\nsudo qemu-system-riscv64 -nographic -machine virt \\\n  -kernel bbl -append \"root=/dev/vda ro console=ttyS0\" \\\n  -drive file=busybear.bin,format=raw,id=hd0 \\\n  -device virtio-blk-device,drive=hd0 \\\n  -netdev type=tap,script=scripts/ifup.sh,downscript=scripts/ifdown.sh,id=net0 \\\n  -device virtio-net-device,netdev=net0\n```\n\nAfter booting the virtual machine you should be able to ssh into it.\n\n```\n$ ssh root@192.168.100.2\nThe authenticity of host '192.168.100.2 (192.168.100.2)' can't be established.\nECDSA key fingerprint is 3f:4b:69:59:01:c8:b2:9c:fb:52:a5:d4:21:c9:3c:1b.\nAre you sure you want to continue connecting (yes/no)? yes\nWarning: Permanently added '192.168.100.2' (ECDSA) to the list of known hosts.\nroot@192.168.100.2's password: \n    ____                   ____                     __    _                 \n   / __ )__  _________  __/ __ )___  ____ ______   / /   (_)___  __  ___  __\n  / __  / / / / ___/ / / / __  / _ \\/ __ `/ ___/  / /   / / __ \\/ / / / |/_/\n / /_/ / /_/ (__  ) /_/ / /_/ /  __/ /_/ / /     / /___/ / / / / /_/ /\u003e  \u003c  \n/_____/\\__,_/____/\\__, /_____/\\___/\\__,_/_/     /_____/_/_/ /_/\\__,_/_/|_|  \n                 /____/                                                     \nroot@ucbvax:~# uname -a\nLinux ucbvax 4.14.0-00030-gc2d852cb2f3d #56 Thu Dec 14 10:12:10 NZDT 2017 riscv64 GNU/Linux\nroot@ucbvax:~# cat /proc/interrupts \n           CPU0       \n  1:        107  riscv,plic0,c000000  10  ttyS0\n  7:        115  riscv,plic0,c000000   7  virtio1\n  8:        135  riscv,plic0,c000000   8  virtio0\nroot@ucbvax:~# \n```\n\nNote: the disk image is stateful and needs to be shutdown cleanly.\n\n```\nroot@ucbvax:~# halt\n```\n\n## linux bridged networking\n\n### bridge\n\n`/etc/network/interfaces`\n```\niface br0 inet static\n  bridge_ports eth0\n  address 192.168.100.1\n  netmask 255.255.255.0\n  network 192.168.100.0\n  broadcast 192.168.100.255\n```\n\n### ifup script\n\n```\n#!/bin/sh\n\nbrctl addif br0 $1\nifconfig $1 up\n```\n\n### ifdown script\n\n```\n#!/bin/sh\n\nifconfig $1 down\nbrctl delif br0 $1\n```\n\n## macOS bridged networking\n\nThese steps show how to setup tuntap bridged networking on macOS:\n\n### install tuntap\n\nNote: the tuntap driver installation requires authorization in the\nmacOS Security and Privacy section of System Preferences.\n\n```\nbrew tap caskroom/cask\nbrew install caskroom/cask/tuntap\n```\n\n### create bridge\n\n```\nsudo ifconfig bridge1 create\nsudo ifconfig bridge1 192.168.100.1/24\n```\n\n### ifup script\n\n```\n#!/bin/sh\nifconfig bridge1 addm $1\n```\n\n### ifdown script\n\n```\n#!/bin/sh\nifconfig bridge1 deletem $1\n```\n\n### pfctl.rules (packet filter rules)\n\n```\nnat on en0 from { 192.168.100.0/24 } to any -\u003e (en0)\npass from {lo0, 192.168.100.0/24} to any keep state\n```\n\n### NAT forwarding (guest access to the Internet)\n\n```\nsudo sysctl -w net.inet.ip.forwarding=1\nsudo pfctl -e\nsudo pfctl -F all\nsudo pfctl -f pfctl.rules \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeljclark%2Fbusybear-linux","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichaeljclark%2Fbusybear-linux","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichaeljclark%2Fbusybear-linux/lists"}