tinyemu

阅读更多
参考 https://bellard.org/jslinux/tech.html

使用的asm.js的emscripten 把tinyemu用js加载,tinyemu支持x86和精简指令集
https://bellard.org/tinyemu/tinyemu-2018-09-23.tar.gz
安装到/usr/local/bin/temu


精简指令集
https://bellard.org/tinyemu/diskimage-linux-riscv-2018-09-23.tar.gz

temu root-riscv64.cfg
运行成功
cat root-riscv64.cfg
/* VM configuration file */
{
    version: 1,
    machine: "riscv64",
    memory_size: 128,
    bios: "bbl64.bin",
    kernel: "kernel-riscv64.bin",
    cmdline: "console=hvc0 root=/dev/vda rw",
    drive0: { file: "root-riscv64.bin" },
    eth0: { driver: "tap", ifname: "tap0" },
}


control a  x 是退出


如果想运行x86的


先用qemu测试:x86
需要准备2.6内核的bzImage  和操作胸系统文件root.bin
/
usr/libexec/qemu-kvm -kernel bzImage -drive file=root.bin,if=ide,cache=none -append "console=ttyS0 root=/dev/hda rw init=/sbin/init notsc=1"  -boot order=dc,menu=on -nographic

bzImage参考jslinux的2.6的编译
root.bin来源[url] https://github.com/killinux/jslinux-deobfuscated[/url] 中的root.bin

配置文件参考
https://bellard.org/jslinux/buildroot-x86.cfg

/* VM configuration file */
{
    version: 1,
    machine: "pc",
    memory_size: 128,
    kernel: "kernel-x86.bin",
    cmdline: "loglevel=3 console=hvc0 root=root rootfstype=9p rootflags=trans=virtio ro TZ=${TZ}",
    fs0: { file: "https://vfsync.org/u/os/buildroot-x86" },
    eth0: { driver: "user" },
}

vfsync.org 上的是远程映射文件系统,改成本地的
把配置文件改成
my-x86.cfg
/* VM configuration file */
{
    version: 1,
    machine: "pc",
    memory_size: 128,
    kernel: "kernel-x86.bin",
    cmdline: "console=hvc0 root=/dev/vda rw init=/sbin/init notsc=1",
    drive0: { file: "root.bin" },
}


其中kernel-x86.bin 来源官网[url]https://bellard.org/jslinux/kernel-x86.bin [/url](这个需要自己想把发编译一次)

另外输入输出用的是hvc0, 与root.bin里面的用的不同

用qemu进入rootbin系统
修改/sbin/init 把最后
#  setsid sh -c 'exec sh /dev/ttyS0 2>&1'
改成
  setsid sh -c 'exec sh /dev/hvc0 2>&1'

是hvc0还是ttyS00应该是内核决定的
注意hda和vda也有区别
~ # cat /sbin/init
#!/bin/sh

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin
export HOME=/root
export TERM=vt100

mount -a

ifconfig lo 127.0.0.1

# allow running DOS .COM executables with the small 'runcom' utility
echo ':DOSCOM:E::com::/usr/bin/runcom:' > /proc/sys/fs/binfmt_misc/register

cd $HOME

#stty -F /dev/ttyS0 rows 30

show_boot_time

echo "Welcome to JS/Linux"

while /bin/true; do

#  setsid sh -c 'exec sh /dev/ttyS0 2>&1'
  setsid sh -c 'exec sh /dev/hvc0 2>&1'

done


最后启动
temu my-x86.cfg
就正常了

你可能感兴趣的:(linux,jslinux)