Last active
January 30, 2025 10:56
-
-
Save changhoon-sung/ae39b28c6bc542263cfd92f777c2a377 to your computer and use it in GitHub Desktop.
Create jammy rootfs image for QEMU in command-line
This file contains hidden or 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/sh | |
# check file exists | |
if [ -f "rootfs.qcow2" ]; then | |
echo -n "Overwrite existing rootfs.qcow2? [y/N] > " | |
read ans | |
if [ "$ans" != "y" ]; then | |
exit 0 | |
fi | |
fi | |
qemu-img create -f qcow2 rootfs.qcow2 30G | |
echo "" | |
echo "====================================================================================" | |
echo "Type 'e' in GRUB menu and add 'console=ttyS0' at the end of line starts with 'linux'" | |
echo "====================================================================================" | |
echo "" | |
# check file exists | |
if [ ! -f "ubuntu-22.04.5-live-server-amd64.iso" ]; then | |
echo "Downloading ubuntu-22.04.4-live-server-amd64.iso..." | |
# wget https://mirror.kakao.com/ubuntu-releases/jammy/ubuntu-22.04.5-live-server-amd64.iso | |
wget https://releases.ubuntu.com/jammy/ubuntu-22.04.5-live-server-amd64.iso | |
fi | |
echo "Verifying..." | |
echo "9bc6028870aef3f74f4e16b900008179e78b130e6b0b9a140635434a46aa98b0 *ubuntu-22.04.5-live-server-amd64.iso" | sha256sum -c | |
if [ $? -ne 0 ]; then | |
exit 1 | |
fi | |
echo "" | |
echo "Require root permission to enable KVM" | |
sudo qemu-system-x86_64 \ | |
-enable-kvm \ | |
-smp 2 \ | |
-m 4G \ | |
-drive file=rootfs.qcow2,if=virtio,id=disk0 \ | |
-cdrom ubuntu-22.04.5-live-server-amd64.iso \ | |
-nographic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment