วันนี้เราจะมาเล่น QEMU โดยสร้าง Virtual Machine Alpine Linux

screen1

ขั้นตอนการสร้าง Virtual Machine

เตรียม image สำหรับการติดตั้ง ดาวน์โหลด Alpine Linux ได้จากที่นี่ https://alpinelinux.org/downloads/

สร้าง qcow2 image ใน KVM

  1. สร้าง disk image สำหรับติดตั้ง Alpine Linux.
qemu-img create -f qcow2 alpine.qcow2 8G
  1. เริ่ม QEMU ด้วยไฟล์ image ISO ของ Alpine กำหนดค่าเริ่มต้นของ RAM 512MB โดยใช้คำสั่งนี้
qemu-system-x86_64 -m 512 -nic user -boot d -cdrom alpine-standard-3.21.0-x86_64.iso -hda alpine.qcow2 -display gtk -enable-kvm

ติดตั้ง Alpine Linux

  1. ล็อกอิน root โดยไม่ต้องใส่ password:

  2. ใช้คำสั่ง setup

setup-alpine
  1. กำหนดค่าเริ่มต้นต่างๆ

screen2

   1. เลือก Keyboard Layout
   2. ตั้ง Hostname (The name for the computer.)
   3. Network Setup [eth0]
   4. Do you want to do any manual network configuration? (y/n) [n] (Default uses "DHCP".)
   5. กำหนด DNS Servers
   6. กำหนด Root password (the password used to login to the root account)
   7. กำหนด Timezone (Optionally display times/dates in your local time zone)
   8. กำหนด HTTP/FTP Proxy (Proxy server to use for accessing the web/ftp. Use "none" for direct connections to websites and FTP servers.)
   9. เลือก Mirror (From where to download packages. Choose the organization you trust giving your usage patterns to.)
   10. เพิ่ม user อื่น (Setting up a regular user account)
   11. เลือก Disk Mode
  1. รอทำการติดตั้งจนเสร็จ

  2. รัน poweroff เพื่อปิดเครื่อง

Booting QEMU Virtual Machine

หลังจากการติดตั้งแล้ว สามารถเริ่ม QEMU จากดิสก์อิมเมจได้โดยไม่ต้องใช้ CDROM โดยใช้คำสั่งนี้

qemu-system-x86_64 -m 512 -name valpinetest -hda alpine.qcow2

screen3