From 706f2e987abd51eae50a8fce6ad5659934a3b037 Mon Sep 17 00:00:00 2001 From: "James R. Heselden" <34611419+Iranaphor@users.noreply.github.com> Date: Sat, 31 May 2025 14:58:42 +0100 Subject: [PATCH 1/3] Update README.md --- README.md | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 46dddda..3fbab95 100644 --- a/README.md +++ b/README.md @@ -25,9 +25,9 @@ pkg install qemu-utils qemu-common qemu-system-x86_64-headless wget -y mkdir alpine && cd alpine ``` -5. Download Alpine Linux 3.20.2 (virt optimized) ISO: +5. Download Alpine Linux 3.22.0 (virt optimized) ISO: ```bash -wget http://dl-cdn.alpinelinux.org/alpine/v3.20/releases/x86_64/alpine-virt-3.20.2-x86_64.iso +wget http://dl-cdn.alpinelinux.org/alpine/v3.22/releases/x86_64/alpine-virt-3.22.0-x86_64.iso ``` 6. Create disk (note it won't actually take 5GB of space, more like 500-600MB): @@ -38,7 +38,7 @@ qemu-img create -f qcow2 alpine.img 5G 7. Boot it up: Here we're using 1024MB of memory and 2 cpus ```bash -qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.20.2-x86_64.iso -nographic alpine.img +qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -cdrom alpine-virt-3.22.0-x86_64.iso -nographic alpine.img ``` > you can get number of useable cpus using `nproc` and total memory using `free -m | grep -oP '\d+' | head -n 1` 8. Login with username ``root`` (no password) @@ -70,6 +70,7 @@ wget https://raw.githubusercontent.com/cyberkernelofficial/docker-in-termux/main ```bash sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk ``` +If this does not work check the location of setup-disk, if not in `/sbin` it may be in `/usr/sbin` 12. Run setup to install to disk ```bash @@ -78,25 +79,32 @@ setup-alpine -f answerfile 13. Once installation is complete, power off the VM (command ``poweroff``) -14. Boot again without cdrom: +> Boot again without cdrom: ```bash qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img ``` +> Quit emulation with: `Ctrl+a x` -A - -`nano run_qemu.sh` -In the text editor, write the following: +14. Outside the emulation install nano with `apk install nano` and run: +```bash +nano run_qemu.sh +``` + +15. In the text editor, write the following: ```bash #!/bin/bash qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img ``` Save and close the file. In nano, you can do this by pressing Ctrl+X, then Y to confirm saving, and then Enter to confirm the filename. -B - chmod command: `chmod +x run_qemu.sh` +16. Set the script as executable with the chmod command: +```bash +chmod +x run_qemu.sh +``` -C - `./run_qemu.sh` +17. Now you can connect to the emulation using: `./run_qemu.sh` -15. Update system and install docker: +18. Update system and install docker: ```bash echo "nameserver 8.8.8.8" > /etc/resolv.conf @@ -105,17 +113,17 @@ echo "nameserver 8.8.4.4" >> /etc/resolv.conf apk update && apk add docker ``` -16. Start docker: +19. Start docker: ```bash service docker start ``` -17. Enable docker on boot: +20. Enable docker on boot: ```bash rc-update add docker ``` -18. Check docker install successfully or not: +21. Check docker install successfully or not: ```bash docker run hello-world ``` From 55336555c6d4c006fb20227c35285fde21a5c6da Mon Sep 17 00:00:00 2001 From: "James R. Heselden" <34611419+Iranaphor@users.noreply.github.com> Date: Sat, 31 May 2025 15:05:33 +0100 Subject: [PATCH 2/3] Update README.md --- README.md | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 3fbab95..7a039ba 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ Follow the steps below to install Docker in Termux: pkg update -y && pkg upgrade -y ``` +## Install Qemu and setup Environment 3. Install the necessary dependencies by running the following command: ```bash pkg install qemu-utils qemu-common qemu-system-x86_64-headless wget -y @@ -72,39 +73,49 @@ sed -i -E 's/(local kernel_opts)=.*/\1="console=ttyS0"/' /sbin/setup-disk ``` If this does not work check the location of setup-disk, if not in `/sbin` it may be in `/usr/sbin` -12. Run setup to install to disk +12. (optional) Configure the answerfile to your local keymap and language (`gb`/`us`): +```bash +sed -i 's/^KEYMAPOPTS=.*/KEYMAPOPTS="gb"/' answerfile +``` + +13. Run setup to install to disk ```bash setup-alpine -f answerfile ``` -13. Once installation is complete, power off the VM (command ``poweroff``) +14. Once installation is complete, power off the VM (command ``poweroff``) +## Create Boot Executable +> **Boot instructions:** > Boot again without cdrom: -```bash -qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img -``` +> ```bash +> qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-> code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img +> ``` > Quit emulation with: `Ctrl+a x` +> Now we will create a boot script with this command -14. Outside the emulation install nano with `apk install nano` and run: +15. Outside the emulation install nano with `apk install nano` and run: ```bash nano run_qemu.sh ``` -15. In the text editor, write the following: +16. In the text editor, write the following: ```bash #!/bin/bash qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img ``` Save and close the file. In nano, you can do this by pressing Ctrl+X, then Y to confirm saving, and then Enter to confirm the filename. -16. Set the script as executable with the chmod command: +17. Set the script as executable with the chmod command: ```bash chmod +x run_qemu.sh ``` -17. Now you can connect to the emulation using: `./run_qemu.sh` +18. Now you can connect to the emulation using: `./run_qemu.sh` + -18. Update system and install docker: +## Install Docker +19. Update system and install docker: ```bash echo "nameserver 8.8.8.8" > /etc/resolv.conf @@ -113,17 +124,17 @@ echo "nameserver 8.8.4.4" >> /etc/resolv.conf apk update && apk add docker ``` -19. Start docker: +20. Start docker: ```bash service docker start ``` -20. Enable docker on boot: +21. Enable docker on boot: ```bash rc-update add docker ``` -21. Check docker install successfully or not: +22. Check docker install successfully or not: ```bash docker run hello-world ``` From 256a61304502728dee22bc2b598d3f4044aa3eea Mon Sep 17 00:00:00 2001 From: "James R. Heselden" <34611419+Iranaphor@users.noreply.github.com> Date: Sat, 31 May 2025 15:06:09 +0100 Subject: [PATCH 3/3] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 7a039ba..8a956c8 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,7 @@ setup-alpine -f answerfile > qemu-system-x86_64 -machine q35 -m 1024 -smp cpus=2 -cpu qemu64 -drive if=pflash,format=raw,read-only=on,file=$PREFIX/share/qemu/edk2-x86_64-> code.fd -netdev user,id=n1,dns=8.8.8.8,hostfwd=tcp::2222-:22 -device virtio-net,netdev=n1 -nographic alpine.img > ``` > Quit emulation with: `Ctrl+a x` +> > Now we will create a boot script with this command 15. Outside the emulation install nano with `apk install nano` and run: