...
 
Commits (3)
FROM debian:unstable
ENV DEBIAN_FRONTEND=noninteractive
RUN printf "deb http://deb.debian.org/debian unstable main\ndeb-src http://deb.debian.org/debian unstable main\n" > /etc/apt/sources.list
RUN apt-get update && apt-get install -y eatmydata
RUN eatmydata apt-get update && eatmydata apt-get dist-upgrade -y
RUN eatmydata apt-get install -y qemu-user-static qemu-utils debootstrap debian-archive-keyring debian-ports-archive-keyring
RUN eatmydata qemu-debootstrap --arch=mipsel --include=linux-image-4.19.0-2-4kc-malta,systemd --verbose unstable /tmp/chroot http://deb.debian.org/debian
ENV DEBIAN_FRONTEND=noninteractive
RUN eatmydata apt-get install -y qemu-user-static qemu-utils debootstrap debian-archive-keyring debian-ports-archive-keyring libguestfs-tools
RUN eatmydata apt-get install -y apt-utils qemu-user-static qemu-utils debootstrap debian-archive-keyring debian-ports-archive-keyring libguestfs-tools
#RUN eatmydata dd if=/dev/zero bs=1M count=1 seek=10000 of=/tmp/image && eatmydata mkfs.ext4 -L rootfs /tmp/image && eatmydata qemu-img convert -O qcow2 /tmp/image /tmp/image.qcow2 && rm /tmp/image
RUN eatmydata virt-make-fs --format=qcow2 --size=10G --partition=gpt --type=ext4 --label=rootfs /tmp/chroot /tmp/image.qcow2 && rm -fr /tmp/image
RUN eatmydata apt-get install -y apt-utils qemu-user-static qemu-system qemu-utils debootstrap debian-archive-keyring debian-ports-archive-keyring libguestfs-tools linux-image-amd64
COPY create.sh fstab interfaces /root/
#!/bin/bash
set -e
SYSTEM="$1"
if [ -z "$DISK_SIZE" ] ; then
DISK_SIZE="10G"
fi
if [ -z "$MEM" ] ; then
MEM="1G"
fi
if [ -z "$SUITE" ] ; then
SUITE="unstable"
fi
if [ -z "$MIRROR" ] ; then
MIRROR="http://deb.debian.org/debian"
fi
DISK="image.qcow2"
FOUND="no"
if [ "$SYSTEM" == "i386-pc" ] ; then
ARCH="i386"
LINUX="linux-image-686"
QEMU_ARCH="i386"
QEMU_MACHINE="pc"
QEMU_DISK="-drive file=$DISK"
QEMU_CPU="coreduo"
QEMU_NET_DRIVER="e1000"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyS0"
FOUND="yes"
fi
if [ "$SYSTEM" == "amd64-pc" ] ; then
ARCH="amd64"
LINUX="linux-image-amd64"
QEMU_ARCH="x86_64"
QEMU_MACHINE="pc"
QEMU_CPU="Nehalem"
QEMU_DISK="-drive file=$DISK"
QEMU_NET_DRIVER="e1000"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyS0"
FOUND="yes"
fi
if [ "$SYSTEM" == "mips-malta" ] ; then
ARCH="mips"
LINUX="linux-image-4kc-malta"
QEMU_ARCH="mips"
QEMU_MACHINE="malta"
QEMU_CPU="4KEc"
QEMU_DISK="-drive file=$DISK"
QEMU_NET_DRIVER="e1000"
LINUX_FILENAME="vmlinux"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyS0"
FOUND="yes"
fi
if [ "$SYSTEM" == "mipsel-malta" ] ; then
ARCH="mipsel"
LINUX="linux-image-4kc-malta"
QEMU_ARCH="mipsel"
QEMU_MACHINE="malta"
QEMU_DISK="-drive file=$DISK"
QEMU_CPU="4KEc"
QEMU_NET_DRIVER="e1000"
LINUX_FILENAME="vmlinux"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyS0"
FOUND="yes"
fi
if [ "$SYSTEM" == "mips64el-malta" ] ; then
ARCH="mips64el"
LINUX="linux-image-5kc-malta"
QEMU_ARCH="mips64el"
QEMU_MACHINE="malta"
QEMU_CPU="5KEc"
QEMU_DISK="-drive file=$DISK"
QEMU_NET_DRIVER="e1000"
LINUX_FILENAME="vmlinux"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyS0"
FOUND="yes"
fi
# Does not work for the moment
if [ "$SYSTEM" == "armel-virt" ] ; then
ARCH="armel"
LINUX="linux-image-marvell"
QEMU_ARCH="arm"
QEMU_MACHINE="virt"
QEMU_CPU="arm946"
QEMU_DISK="-device virtio-blk-device,drive=hd -drive file=$DISK,if=none,id=hd"
QEMU_NET_DRIVER="virtio-net-device"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyAMA0"
FOUND="yes"
fi
if [ "$SYSTEM" == "armhf-virt" ] ; then
ARCH="armhf"
LINUX="linux-image-armmp"
QEMU_ARCH="arm"
QEMU_MACHINE="virt"
QEMU_CPU="cortex-a15"
QEMU_DISK="-device virtio-blk-device,drive=hd -drive file=$DISK,if=none,id=hd"
QEMU_NET_DRIVER="virtio-net-device"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyAMA0"
FOUND="yes"
fi
if [ "$SYSTEM" == "arm64-virt" ] ; then
ARCH="arm64"
LINUX="linux-image-arm64"
QEMU_ARCH="aarch64"
QEMU_MACHINE="virt"
QEMU_CPU="cortex-a57"
QEMU_DISK="-device virtio-blk-device,drive=hd -drive file=$DISK,if=none,id=hd"
QEMU_NET_DRIVER="virtio-net-device"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyAMA0"
FOUND="yes"
fi
if [ "$SYSTEM" == "s390x-virt" ] ; then
ARCH="s390x"
LINUX="linux-image-s390x"
QEMU_ARCH="s390x"
QEMU_MACHINE="s390-ccw-virtio"
QEMU_CPU="z900"
QEMU_DISK="-drive file=$DISK"
QEMU_NET_DRIVER="virtio-net-ccw"
LINUX_FILENAME="vmlinuz"
INITRD_FILENAME="initrd.img"
CONSOLE="ttyAMA0"
FOUND="yes"
fi
if [ "$FOUND" != "yes" ] ; then
echo "Could not find system type: $SYSTEM"
exit 1
fi
QEMU_NET="-device $QEMU_NET_DRIVER,netdev=net -netdev user,id=net,hostfwd=tcp::2222-:22"
# Create the filesystem
eatmydata qemu-debootstrap --arch="$ARCH" --include="$LINUX",systemd --verbose "$SUITE" /tmp/chroot "$MIRROR"
# Install a simple fstab and set hostname
cp fstab /tmp/chroot/etc/fstab
echo "debian" > /tmp/chroot/etc/hostname
# Create and set passwords for root and user debian
chroot /tmp/chroot adduser --gecos "Debian user,,," --disabled-password debian
echo "root:root" | chroot /tmp/chroot chpasswd
echo "debian:debian" | chroot /tmp/chroot chpasswd
# Disable predictable interface naming and configure dhcp by default
ln -s /dev/null /tmp/chroot/etc/systemd/network/99-default.link
cp interfaces /tmp/chroot/etc/network/interfaces
# Recreate initrd
chroot /tmp/chroot update-initramfs -k all -c
# Create the qcow2 image
eatmydata virt-make-fs --format=qcow2 --size="$DISK_SIZE" --partition=gpt --type=ext4 --label=rootfs /tmp/chroot /tmp/"$DISK"
# Extract kernel and initrd
ln -L /tmp/chroot/"$LINUX_FILENAME" /tmp/kernel
ln -L /tmp/chroot/"$INITRD_FILENAME" /tmp/initrd
# Propose a boot command line
echo "(Try to) boot with:"
echo cd /tmp
echo qemu-system-"$QEMU_ARCH" -machine "$QEMU_MACHINE" -cpu "$QEMU_CPU" -m "$MEM" $QEMU_DISK $QEMU_NET -kernel kernel -initrd initrd -nographic -append '"'root=LABEL=rootfs console="$CONSOLE"'"'
echo "You can use Ctrl-a x to exit from QEMU"
#rm -fr /tmp/chroot
LABEL=rootfs / ext4 user_xattr,errors=remount-ro 0 1
auto eth0
iface eth0 inet dhcp