Advertisement
efxtv

Setting Up Alpine Linux [ TERMUX NO ROOT ] on QEMU + Docker + SSH

Jan 7th, 2025 (edited)
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.28 KB | Cybersecurity | 0 0
  1. Setting Up Alpine Linux on QEMU + Docker + SSH (Termux no root required)
  2.  
  3. ##################################################################
  4. JOIN US ON TELEGRAM FOR MORE AND DETAILED CLASSES
  5. VISIT OUR TELEGRAM PROFILE: https://t.me/LinuxClassesEFXTv
  6. ##################################################################
  7.  
  8. In this post, we'll go through how to set up Alpine Linux on QEMU. This includes downloading the Alpine ISO, creating a virtual machine, configuring network interfaces, and installing Docker. Let's dive into the steps:
  9.  
  10. 1. Update and Install Required Packages
  11. pkg update && pkg upgrade
  12. pkg install qemu-utils qemu-common qemu-system-x86_64-headless
  13.  
  14. 2. Create a Directory for Alpine Linux
  15. mkdir ~/alpine && cd ~/alpine
  16.  
  17. 3. Download the Alpine ISO
  18. https://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.3-x86_64.iso
  19.  
  20. 4. Create a Virtual Machine Image
  21. qemu-img create -f qcow2 alpine.img 20G
  22.  
  23. 5. Start Alpine Linux in QEMU
  24. qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.12.3-x86_64.iso -nographic alpine.img
  25.  
  26. 6. Login as Root User
  27. login: root
  28. Password: (no password, just press Enter)
  29.  
  30. 7. Run the Alpine Setup Script
  31. localhost:~# setup-interfaces
  32.  
  33. 8. Enable Network Interface (eth0)
  34. localhost:~# ifup eth0
  35.  
  36. 8.1- Try to ping if it works move to step 9
  37. $ ping google.com
  38.  
  39. 8.2- if no internet follow the process else move to step 9
  40. $ service networking restart
  41. $ echo "nameserver 8.8.8.8" > /etc/resolv.conf
  42.  
  43. 9. Download an Answerfile for Automation
  44. wget https://raw.githubusercontent.com/efxtv/EFX-Tv-Bookmarks/refs/heads/main/bin/alpine/answerfile
  45.  
  46. --The answerfile should contain the following configuration--
  47. vi answerfile
  48. -------------------------------------------------------------
  49. KEYMAPOPTS="us us"
  50. HOSTNAMEOPTS="-n alpine"
  51. INTERFACESOPTS="auto lo
  52. iface lo inet loopback
  53.  
  54. auto eth0
  55. iface eth0 inet dhcp
  56. hostname alpine
  57. "
  58. TIMEZONEOPTS="-z UTC"
  59. PROXYOPTS="none"
  60. APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.12/main http://dl-cdn.alpinelinux.org/alpine/v3.12/community"
  61. SSHDOPTS="-c openssh"
  62. NTPOPTS="-c busybox"
  63. DISKOPTS="-v -m sys -s 0 /dev/sda"
  64. -------------------------------------------------------------
  65.  
  66. 10. Modify Setup Disk Configuration
  67. localhost:~# sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk
  68.  
  69. 11. Run the Setup Script
  70. localhost:~# setup-alpine -f answerfile
  71.  
  72. 11.1 - Just press y and hit enter
  73. Erase the above disk(s) and continue? [y/N]: y
  74.  
  75. 12. Shutdown the Virtual Machine
  76. localhost:~# poweroff
  77.  
  78. 13. Start Alpine Again
  79. qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img
  80.  
  81. 14. Update Alpine and Install Docker
  82. apk update && apk add docker
  83. service docker start
  84. rc-update add docker
  85.  
  86. EXTRA FIX
  87. 1. Restart network manager
  88. service networking restart
  89.  
  90. Read to fix networking issues https://wiki.alpinelinux.org/wiki/Configure_Networking
  91.  
  92. Join EFX Tv VIP Classes to learn more t.me/efxtv
  93.  
  94.  
  95.  
  96.  
  97.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement