Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ec05936d2f | ||
|
|
41bc570bfb |
@@ -2,6 +2,8 @@ FROM alpine:latest
|
|||||||
RUN mkdir -p /lib/apk/db /run
|
RUN mkdir -p /lib/apk/db /run
|
||||||
RUN apk add --no-cache --initdb linux-virt busybox util-linux
|
RUN apk add --no-cache --initdb linux-virt busybox util-linux
|
||||||
RUN cp /boot/vmlinuz-virt /vmlinuz && echo "Welcome to slim!" > /etc/motd
|
RUN cp /boot/vmlinuz-virt /vmlinuz && echo "Welcome to slim!" > /etc/motd
|
||||||
|
|
||||||
|
# Use custom init script
|
||||||
COPY init /init
|
COPY init /init
|
||||||
RUN chmod +x /init
|
RUN chmod +x /init
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
# FROM archlinux:latest
|
||||||
|
FROM marvin
|
||||||
|
|
||||||
|
|
||||||
|
USER root
|
||||||
|
|
||||||
|
# Update, install kernel, initramfs tools, and utilities
|
||||||
|
# 'linux' includes mkinitcpio hooks that auto-generate the initramfs
|
||||||
|
RUN pacman -Syu --noconfirm linux busybox util-linux dhcpcd; \
|
||||||
|
pacman -Sc --noconfirm
|
||||||
|
|
||||||
|
# Copy kernel and initramfs to root for VM extraction
|
||||||
|
RUN cp /boot/vmlinuz-linux /vmlinuz && \
|
||||||
|
cp /boot/initramfs-linux.img /initrd.img
|
||||||
|
|
||||||
|
# Allow root login without password
|
||||||
|
RUN passwd -d root
|
||||||
|
|
||||||
|
# Set up timezone. Required to bypass archlinux's first-install setup.
|
||||||
|
RUN ln -s /usr/share/zoneinfo/Europe/Stockholm /etc/localtime
|
||||||
|
|
||||||
|
COPY init /init
|
||||||
|
RUN chmod +x /init
|
||||||
@@ -0,0 +1,30 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
# Mount special filesystems
|
||||||
|
mkdir -p /dev /proc /sys
|
||||||
|
[ -c /dev/console ] || mknod -m 600 /dev/console c 5 1
|
||||||
|
mount -t proc proc /proc
|
||||||
|
mount -t sysfs sysfs /sys
|
||||||
|
mount -t devtmpfs dev /dev
|
||||||
|
|
||||||
|
# Networking
|
||||||
|
echo slim > /proc/sys/kernel/hostname
|
||||||
|
modprobe virtio_net
|
||||||
|
ip link set lo up 2>/dev/null
|
||||||
|
ip link set eth0 up 2>/dev/null
|
||||||
|
# udhcpc -i eth0 -f -q # Get DHCP lease
|
||||||
|
|
||||||
|
echo
|
||||||
|
echo 'Welcome to slim!'
|
||||||
|
echo
|
||||||
|
|
||||||
|
# Start systemd
|
||||||
|
exec /sbin/init
|
||||||
|
|
||||||
|
# Or, just run a shell
|
||||||
|
# /bin/sh </dev/console >/dev/console 2>&1
|
||||||
|
# poweroff -f
|
||||||
|
# while true; do
|
||||||
|
# sleep 1
|
||||||
|
# poweroff -f
|
||||||
|
# done
|
||||||
+7
-2
@@ -33,7 +33,8 @@ pub(crate) fn run(name: &str) -> Result<()> {
|
|||||||
]
|
]
|
||||||
.join(" ");
|
.join(" ");
|
||||||
|
|
||||||
let status = Command::new("qemu-system-x86_64")
|
let mut command = Command::new("qemu-system-x86_64");
|
||||||
|
command
|
||||||
.args(["-m", "1024M"])
|
.args(["-m", "1024M"])
|
||||||
.arg("-kernel")
|
.arg("-kernel")
|
||||||
.arg(vmlinuz_path.as_os_str())
|
.arg(vmlinuz_path.as_os_str())
|
||||||
@@ -41,7 +42,11 @@ pub(crate) fn run(name: &str) -> Result<()> {
|
|||||||
.arg(initrd_path.as_os_str())
|
.arg(initrd_path.as_os_str())
|
||||||
.args(["-append", &cmdline])
|
.args(["-append", &cmdline])
|
||||||
.args(["-nographic"])
|
.args(["-nographic"])
|
||||||
.args(["-nic", "user,model=virtio-net-pci"])
|
.args(["-nic", "user,model=virtio-net-pci"]);
|
||||||
|
|
||||||
|
println!("{command:?}");
|
||||||
|
|
||||||
|
let status = command
|
||||||
.status()
|
.status()
|
||||||
.context("Failed to launch qemu-system-x86_64")?;
|
.context("Failed to launch qemu-system-x86_64")?;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user