Git Product home page Git Product logo

debianonqemu's Introduction

DebianOnQEMU

Debian qcow2 multi-arch images on QEMU.

If this project helps you, please give it a star!

You may be also interested in the side project: qemu-full

Quick Start

Download vmlinuz, initrd and qcow2 image from the release page, and start your virtual machine with QEMU.

In most cases, you want to access the virtual machine via SSH, so don't forget to add a port forwarding or bridge your network interfaces.

Below are a few quick start command lines. Note the file names should be replaced by the ones you download.

AMD64

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-x86_64 -m 512 -kernel ./vmlinuz-5.10.0-13-amd64 \
                   -initrd ./initrd.img-5.10.0-13-amd64 \
                   -append "console=ttyS0 debug root=/dev/sda net.ifnames=0" \
                   -hda ./debian-bullseye-amd64.qcow2 -nographic \
                   -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

i386

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-i386 -m 512 -kernel ./vmlinuz-5.10.0-26-686 \
                 -initrd ./initrd.img-5.10.0-26-686 \
                 -append "console=ttyS0 debug root=/dev/sda net.ifnames=0" \
                 -hda ./debian-bullseye-i386.qcow2 -nographic \
                 -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

ARM

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full:v8.2.0 \
qemu-system-arm -m 512 -M virt -cpu cortex-a15 \
                -kernel ./vmlinuz-5.10.0-26-armmp \
                -initrd ./initrd.img-5.10.0-26-armmp \
                -device virtio-blk-device,drive=hd0 \
                -drive if=none,file=debian-bullseye-armhf-armmp.qcow2,id=hd0 \
                -append "root=/dev/vda rw console=ttyAMA0 rodata=n net.ifnames=0" \
                -device virtio-net-device,netdev=usernet \
		-netdev user,id=usernet,hostfwd=tcp::5555-:22 -nographic

Refer to QEMU ARM doc for details.

ARM64

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-aarch64 -m 512 -M virt -cpu cortex-a57 -kernel ./vmlinuz-5.10.0-26-arm64 \
                    -initrd ./initrd.img-5.10.0-26-arm64 \
                    -append "console=ttyAMA0 debug root=/dev/sda net.ifnames=0" \
                    -hda ./debian-bullseye-arm64.qcow2 -nographic \
                    -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

cortext-a8 or cortext-a9 are not supported.

RISCV64

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-riscv64 -m 512 -M virt -kernel ./vmlinux-6.6.8-riscv64\
                    -initrd ./initrd.img-6.6.8-riscv64 \
                    -append "rw console=ttyS0 debug root=/dev/vda net.ifnames=0" \
                    -device virtio-blk-device,drive=hd0 \
                    -object rng-random,filename=/dev/urandom,id=rng0 -device virtio-rng-device,rng=rng0 \
                    -drive file=./debian-bullseye-riscv64.qcow2,id=hd0 -nographic \
                    -device virtio-net-device,netdev=usernet -netdev user,id=usernet,hostfwd=tcp::5555-:22 

Refer to QEMU doc and Debian doc for more configurations.

S390x

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-s390x -m 512 -machine s390-ccw-virtio -cpu max,zpci=on \
                    -kernel ./vmlinuz-5.10.0-26-s390x -initrd ./initrd.img-5.10.0-26-s390x \
                    -append "console=ttyAMA0 debug root=/dev/vda rw net.ifnames=0"\
                    -hda ./debian-bullseye-s390x.qcow2 \
                    -nographic -nic user,model=virtio,hostfwd=tcp::5555-:22

Refer to QEMU doc for details.

PPC

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-ppc64 -m 512 -cpu power9 -kernel ./vmlinux-5.10.0-26-powerpc64le \
                  -initrd ./initrd.img-5.10.0-26-powerpc64le \
                  -append "console=hvc0 debug root=/dev/sda net.ifnames=0" \
                  -hda ./debian-bullseye-ppc64el.qcow2 -nographic \
                  -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

MIPS

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-mipsel -m 512 -M malta -kernel ./vmlinuz-5.10.0-26-4kc-malta \
                   -initrd ./initrd.img-5.10.0-26-4kc-malta \
                   -append "console=ttyAMA0 debug root=/dev/sda net.ifnames=0" \
                   -hda ./debian-bullseye-mipsel-malta.qcow2 -nographic \
                   -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22
docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full \
qemu-system-mips64el -m 512 -M malta -cpu 5KEc -kernel ./vmlinuz-5.10.0-26-5kc-malta \
            -initrd ./initrd.img-5.10.0-26-5kc-malta \
            -append "console=ttyAMA0 debug root=/dev/sda net.ifnames=0" \
            -hda ./debian-bullseye-mips64el-malta.qcow2 \
            -nographic -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

Loongarch64

So far, Loongarch64 Debian ports are not complete but we can boot Loong Archlinux and run debian userland inside.

docker run -p 5555:5555 -v `pwd`:/work --rm -it lazymio/qemu-full:v8.2.0 \
qemu-system-loongarch64 -m 1024m -cpu la464-loongarch-cpu \
                    -M virt -append "console=ttyS0 rw debug root=/dev/vda" \
                    -kernel ./vmlinuz-loong64 -initrd ./initrd.img-loong64 \
                    -bios ./bios-loong64-8.1.bin \
                    -hda ./debian-bullseye-loong64.qcow2 --nographic \
                    -nic user,model=virtio-net-pci,hostfwd=tcp::5555-:22

After the system is up, SSH into it and use:

[root@debian-bullseye-loong64 ~]# cd /debian/
[root@debian-bullseye-loong64 debian]# chroot .
root@debian-bullseye-loong64:/# cat /etc/issue
Debian GNU/Linux trixie/sid \n \l

root@debian-bullseye-loong64:/# uname -a
Linux debian-bullseye-loong64 6.7.0-rc2-2 #1 SMP PREEMPT Mon, 27 Nov 2023 08:42:49 +0000 loongarch64 GNU/Linux
root@debian-bullseye-loong64:/# apt
apt 2.7.7 (loong64)
Usage: apt [options] command

apt is a commandline package manager and provides commands for
searching and managing as well as querying information about packages.
It provides the same functionality as the specialized APT tools,
like apt-get and apt-cache, but enables options more suitable for
interactive use by default.

Most used commands:
  list - list packages based on package names
  search - search in package descriptions
  show - show package details
  install - install packages
  reinstall - reinstall packages
  remove - remove packages
  autoremove - automatically remove all unused packages
  update - update list of available packages
  upgrade - upgrade the system by installing/upgrading packages
  full-upgrade - upgrade the system by removing/installing/upgrading packages
  edit-sources - edit the source information file
  satisfy - satisfy dependency strings

See apt(8) for more information about the available commands.
Configuration options and syntax is detailed in apt.conf(5).
Information about how to configure sources can be found in sources.list(5).
Package and version choices can be expressed via apt_preferences(5).
Security details are available in apt-secure(8).
                                        This APT has Super Cow Powers.
root@debian-bullseye-loong64:/#

Or using a docker approach:

pacmam -Syu docker
mkdir -p /etc/docker
# This is important to avoid ip addresses conflicting with host's docker!
echo > /etc/docker/daemon.json <<EOF
{
	"default-address-pools": [
		{"base": "10.99.0.0/16", "size":24}
	]
}
EOF
systemctl start docker && systemctl enable docker
echo "FROM scratch" > /debian/Dockerfile
echo "ADD . /" >> /debian/Dockerfile
cd /debian && docker build -t debian_rootfs .
docker run -it --rm debian_rootfs bash

Once Debian ports is available we can jump over ArchLinux and boot Debian directly.

Usage

SSH

Two users created: root:root and debian:debian and ssh server is up by default.

Resize disk

On host:

qemu-img resize ./debian-bullseye-loong64.qcow2 16G

On emulated targets:

parted /dev/vda resizepart 1 100%
resize2fs /dev/vda
reboot

debianonqemu's People

Contributors

wtdcode avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

debianonqemu's Issues

arm cannot start

qemu-system-arm -m 2048 -M virt -cpu cortex-a15 -smp cpus=4,maxcpus=4
-kernel vmlinuz -initrd initrd.img -append "root=/dev/mmcblk0 net.ifnames=0 biosdevname=0 nokaslr"
-hda rootfs.qcow2 -net nic -net tap,ifname=tap108,script="./qemu-brup",downscript="./qemu-brdown"
-nographic

Begin: Loading essential drivers ... done.
Begin: Running /scripts/init-premount ... done.
Begin: Mounting root file system ... Begin: Running /scripts/local-top ... done.
Begin: Running /scripts/local-premount ... done.
Begin: Waiting for root file system ... Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
Begin: Running /scripts/local-block ... done.
done.
Gave up waiting for root file system device. Common problems:

  • Boot args (cat /proc/cmdline)
    • Check rootdelay= (did the system wait long enough?)
  • Missing modules (cat /proc/modules; ls /dev)
    ALERT! /dev/mmcblk0 does not exist. Dropping to a shell!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.