Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Setting Up Alpine Linux on QEMU + Docker + SSH (Termux no root required)
- ##################################################################
- JOIN US ON TELEGRAM FOR MORE AND DETAILED CLASSES
- VISIT OUR TELEGRAM PROFILE: https://t.me/LinuxClassesEFXTv
- ##################################################################
- 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:
- 1. Update and Install Required Packages
- pkg update && pkg upgrade
- pkg install qemu-utils qemu-common qemu-system-x86_64-headless
- 2. Create a Directory for Alpine Linux
- mkdir ~/alpine && cd ~/alpine
- 3. Download the Alpine ISO
- https://dl-cdn.alpinelinux.org/alpine/v3.12/releases/x86_64/alpine-virt-3.12.3-x86_64.iso
- 4. Create a Virtual Machine Image
- qemu-img create -f qcow2 alpine.img 20G
- 5. Start Alpine Linux in QEMU
- 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
- 6. Login as Root User
- login: root
- Password: (no password, just press Enter)
- 7. Run the Alpine Setup Script
- localhost:~# setup-interfaces
- 8. Enable Network Interface (eth0)
- localhost:~# ifup eth0
- 8.1- Try to ping if it works move to step 9
- $ ping google.com
- 8.2- if no internet follow the process else move to step 9
- $ service networking restart
- $ echo "nameserver 8.8.8.8" > /etc/resolv.conf
- 9. Download an Answerfile for Automation
- wget https://raw.githubusercontent.com/efxtv/EFX-Tv-Bookmarks/refs/heads/main/bin/alpine/answerfile
- --The answerfile should contain the following configuration--
- vi answerfile
- -------------------------------------------------------------
- KEYMAPOPTS="us us"
- HOSTNAMEOPTS="-n alpine"
- INTERFACESOPTS="auto lo
- iface lo inet loopback
- auto eth0
- iface eth0 inet dhcp
- hostname alpine
- "
- TIMEZONEOPTS="-z UTC"
- PROXYOPTS="none"
- APKREPOSOPTS="http://dl-cdn.alpinelinux.org/alpine/v3.12/main http://dl-cdn.alpinelinux.org/alpine/v3.12/community"
- SSHDOPTS="-c openssh"
- NTPOPTS="-c busybox"
- DISKOPTS="-v -m sys -s 0 /dev/sda"
- -------------------------------------------------------------
- 10. Modify Setup Disk Configuration
- localhost:~# sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk
- 11. Run the Setup Script
- localhost:~# setup-alpine -f answerfile
- 11.1 - Just press y and hit enter
- Erase the above disk(s) and continue? [y/N]: y
- 12. Shutdown the Virtual Machine
- localhost:~# poweroff
- 13. Start Alpine Again
- 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
- 14. Update Alpine and Install Docker
- apk update && apk add docker
- service docker start
- rc-update add docker
- EXTRA FIX
- 1. Restart network manager
- service networking restart
- Read to fix networking issues https://wiki.alpinelinux.org/wiki/Configure_Networking
- Join EFX Tv VIP Classes to learn more t.me/efxtv
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement