Last active
January 15, 2022 09:17
-
-
Save olavmrk/7a0e98802bab91d8b944 to your computer and use it in GitHub Desktop.
kvm boot debian from initramfs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
cd /tmp | |
mkdir testroot | |
debootstrap wheezy testroot http://http.debian.net/debian | |
chroot testroot env LC_ALL=C apt-get install --no-install-recommends linux-image-amd64 | |
rm -rf testroot/var/cache/apt/* | |
ln -s bin/bash testroot/init | |
echo 'T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100' >>testroot/etc/inittab | |
passwd -R "$(pwd)"/testroot -d root | |
echo 'testroot' >testroot/etc/hostname | |
echo 'auto eth0' >>testroot/etc/network/interfaces | |
echo 'iface eth0 inet dhcp' >>testroot/etc/network/interfaces | |
( cd testroot && find . -print0 | cpio --null -ov --format=newc | gzip -9 > ../testroot.gz ) | |
kvm -m 1024 -kernel testroot/boot/vmlinuz-* -initrd testroot.gz -append 'console=ttyS0' -nographic -net nic,model=virtio -net user | |
# To continue with normal init, run: | |
# exec /sbin/init |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment