# busybear-linux
busybear-linux is a tiny RISC-V Linux root filesystem image that targets
the `virt` machine in riscv-qemu. As the name suggests, busybear-linux is
a riscv-linux root image comprised of busybox and dropbear.
The root image is intended to demonstrate virtio-net and virtio-block in
riscv-qemu and features a dropbear ssh server which allows out-of-the-box
ssh access to a RISC-V virtual machine.
See the [releases](https://github.com/michaeljclark/busybear-linux/releases)
for pre-built kernel and filesystem images.
## Copyright and License
The busybear build system has been written by and is
copyright (C) 2017 by Michael J. Clark <michaeljclark@mac.com>.
Enhancements to the build system have been contributed by and
are copyright (C) 2017 by Karsten Merker <merker@debian.org>.
The busybear build system is provided under the following license
("MIT license"):
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
## Dependencies
- [riscv-gnu-toolchain](https://github.com/riscv/riscv-gnu-toolchain) (RISC-V Linux toolchain)
- [busybox](https://busybox.net/) (downloaded automatically)
- [dropbear](https://matt.ucc.asn.au/dropbear/dropbear.html) (downloaded automatically)
- sudo, curl, openssl and rsync
## Features
- `ntpd` for time configuration
- `klog` for kernel logging
- `syslog` for system logging
- `dropbear` for ssh access
- `busybox` with almost everything enabled
## Configuration
- `conf` contains the linux image build configuration
- `conf/linux.config` contains the linux-kernel configuration
- `conf/busybox.config` contains the busybox configuration
- `conf/busybear.config` contains the image build configuration
- `ROOT_PASSWORD=busybear`
- `IMAGE_FILE=busybear.bin`
- `etc` contains the linux guest system configuration
- `etc/network/interfaces` (guest 192.168.100.2, router 192.168.100.1)
- `etc/resolv.conf` (nameserver 8.8.8.8, nameserver 8.8.4.4)
- `etc/ntp.conf` (server 0.pool.ntp.org, server 1.pool.ntp.org)
- `etc/passwd`, `etc/shadow`, `etc/group` and `etc/hosts`
The default config assumes bridged networking with `192.168.100.1`
on the host and `192.168.100.2` in the guest.
## Build
The build process downloads busybox and dropbear, compiles them and prepares
a root filesystem image to the file `busybear.bin`. The build script needs
to be run in Linux, even if preparing a root filesystem image for macOS.
### busybear-linux
```
git clone --recursive https://github.com/michaeljclark/busybear-linux.git
cd busybear-linux
make
```
### QEMU
```
git clone https://github.com/riscv/riscv-qemu.git
cd riscv-qemu
./configure --target-list=riscv64-softmmu,riscv32-softmmu
make
```
### riscv-linux
_Note: busybear-linux builds linux kernel automatically_
```
git clone https://github.com/riscv/riscv-linux.git
cd riscv-linux
git checkout riscv-linux-4.14
cp ../busybear-linux/conf/linux.config .config
make ARCH=riscv olddefconfig
make ARCH=riscv vmlinux
```
### bbl
_Note: busybear-linux builds bbl automatically_
```
git clone https://github.com/riscv/riscv-pk.git
cd riscv-pk
mkdir build
cd build
../configure \
--enable-logo \
--host=riscv64-unknown-elf \
--with-payload=../../riscv-linux/vmlinux
make
```
## Running
busybear requires the riscv-qemu `virt` board with virtio-block
and virtio-net devices.
The following command starts busybear-linux:
```
./scripts/run-qemu.sh
```
which runs executes this command:
```
sudo qemu-system-riscv64 -nographic -machine virt \
-kernel bbl -append "root=/dev/vda ro console=ttyS0" \
-drive file=busybear.bin,format=raw,id=hd0 \
-device virtio-blk-device,drive=hd0 \
-netdev type=tap,script=scripts/ifup.sh,downscript=scripts/ifdown.sh,id=net0 \
-device virtio-net-device,netdev=net0
```
After booting the virtual machine you should be able to ssh into it.
```
$ ssh root@192.168.100.2
The authenticity of host '192.168.100.2 (192.168.100.2)' can't be established.
ECDSA key fingerprint is 3f:4b:69:59:01:c8:b2:9c:fb:52:a5:d4:21:c9:3c:1b.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.100.2' (ECDSA) to the list of known hosts.
root@192.168.100.2's password:
____ ____ __ _
/ __ )__ _________ __/ __ )___ ____ ______ / / (_)___ __ ___ __
/ __ / / / / ___/ / / / __ / _ \/ __ `/ ___/ / / / / __ \/ / / / |/_/
/ /_/ / /_/ (__ ) /_/ / /_/ / __/ /_/ / / / /___/ / / / / /_/ /> <
/_____/\__,_/____/\__, /_____/\___/\__,_/_/ /_____/_/_/ /_/\__,_/_/|_|
/____/
root@ucbvax:~# uname -a
Linux ucbvax 4.14.0-00030-gc2d852cb2f3d #56 Thu Dec 14 10:12:10 NZDT 2017 riscv64 GNU/Linux
root@ucbvax:~# cat /proc/interrupts
CPU0
1: 107 riscv,plic0,c000000 10 ttyS0
7: 115 riscv,plic0,c000000 7 virtio1
8: 135 riscv,plic0,c000000 8 virtio0
root@ucbvax:~#
```
Note: the disk image is stateful and needs to be shutdown cleanly.
```
root@ucbvax:~# halt
```
## linux bridged networking
### bridge
`/etc/network/interfaces`
```
iface br0 inet static
bridge_ports eth0
address 192.168.100.1
netmask 255.255.255.0
network 192.168.100.0
broadcast 192.168.100.255
```
### ifup script
```
#!/bin/sh
brctl addif br0 $1
ifconfig $1 up
```
### ifdown script
```
#!/bin/sh
ifconfig $1 down
brctl delif br0 $1
```
## macOS bridged networking
These steps show how to setup tuntap bridged networking on macOS:
### install tuntap
Note: the tuntap driver installation requires authorization in the
macOS Security and Privacy section of System Preferences.
```
brew tap caskroom/cask
brew install caskroom/cask/tuntap
```
### create bridge
```
sudo ifconfig bridge1 create
sudo ifconfig bridge1 192.168.100.1/24
```
### ifup script
```
#!/bin/sh
ifconfig bridge1 addm $1
```
### ifdown script
```
#!/bin/sh
ifconfig bridge1 deletem $1
```
### pfctl.rules (packet filter rules)
```
nat on en0 from { 192.168.100.0/24 } to any -> (en0)
pass from {lo0, 192.168.100.0/24} to any keep state
```
### NAT forwarding (guest access to the Internet)
```
sudo sysctl -w net.inet.ip.forwarding=1
sudo pfctl -e
sudo pfctl -F all
sudo pfctl -f pfctl.rules
```
没有合适的资源?快使用搜索试试~ 我知道了~
busybear-linux:busybear-linux是一个微型RISC-V Linux根文件系统映像,其目标是riscv-...
共30个文件
sh:5个
conf:3个
config:3个
5星 · 超过95%的资源 需积分: 10 1 下载量 29 浏览量
2021-05-26
16:58:14
上传
评论 1
收藏 21KB ZIP 举报
温馨提示
busybear-linux busybear-linux是一个微型RISC-V Linux根文件系统映像,其目标是riscv-qemu中的virt计算机。 顾名思义,busybear-linux是由busybox和dropbear组成的riscv-linux根映像。 根映像旨在演示riscv-qemu中的virtio-net和virtio-block,并具有一个dropbear ssh服务器,该服务器允许现成的ssh访问RISC-V虚拟机。 有关预构建的内核和文件系统映像,请参见。 版权和许可 busybear构建系统已由Michael 编写,版权所有(C)2017。 系统的增强功能由Karsten 贡献并拥有版权(C)2017。 busybear构建系统是根据以下许可证(“ MIT许可证”)提供的: 特此免费授予获得此软件和相关文档文件(“软件”)副本的任何人无限制地处理软件
资源详情
资源评论
资源推荐
收起资源包目录
busybear-linux-master.zip (30个子文件)
busybear-linux-master
etc
inittab 233B
group 10B
resolv.conf 38B
services 12B
fstab 335B
hosts 20B
nsswitch.conf 249B
shells 17B
network
interfaces 161B
init.d
S01mdev 224B
rcS 273B
profile 72B
gshadow 9B
motd 462B
passwd 30B
ntp.conf 44B
shadow 26B
.gitignore 33B
README.md 7KB
.gitmodules 67B
bin
ldd 39B
conf
linux.config 1KB
busybox.config 27KB
busybear.config 201B
src
riscv-pk
scripts
build.sh 3KB
start-qemu.sh 942B
ifdown.sh 50B
image.sh 3KB
ifup.sh 48B
Makefile 272B
共 30 条
- 1
花花鼓
- 粉丝: 24
- 资源: 4648
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论1