Last active
February 24, 2024 17:16
-
-
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 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 | |
#!/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.4-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.4-live-server-amd64.iso | |
wget https://releases.ubuntu.com/jammy/ubuntu-22.04.4-live-server-amd64.iso | |
fi | |
echo "Verifying..." | |
echo "45f873de9f8cb637345d6e66a583762730bbea30277ef7b32c9c3bd6700a32b2 ubuntu-22.04.4-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.4-live-server-amd64.iso \ | |
-nographic |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment