Skip to content

Instantly share code, notes, and snippets.

@tcz001
Last active November 26, 2021 10:13
Show Gist options
  • Save tcz001/4e5a59362d6665fe83ec8ac54bccc7f5 to your computer and use it in GitHub Desktop.
Save tcz001/4e5a59362d6665fe83ec8ac54bccc7f5 to your computer and use it in GitHub Desktop.
run alpine linux on qemu on windows
  1. create a folder in C:\ as workspace (because download folder is a remote volumn, it won't be accessable in powershell/cmd.exe)
  2. download and unzip qemu pre-built binaries.
  3. download alpine-extended-x86_64 iso cdrom.
  4. use qemu-img.exe to create a disk image: qemu-img create hd.img 10G.
  5. download and run start.bat to execute qemu, it will boot from an alpine iso and mount an disk we just created.
  6. login use root, then run setup-alpine in command line, choose us timezone and keyboard layout, setup your root passwd, type enters until:
  • enable openssh service for later usage.
  • when asked "which disk would you like to use?" enter "sda".
  • when asked "How would you like to use it?" enter "sys".
  • confirm disk will be erased.
  • reboot after installation.
  • change /etc/ssh/sshd_config configure PermitRootLogin yes
  1. download and open putty.exe to ssh into root@localhost:22022
  2. add default apk repos http://dl-3.alpinelinux.org/alpine/v3.10/main into /etc/apk/repositories, then apk update
  3. download and copy zscalar CA certs into alpine linux via Putty's scp tool (PSCP.exe), go to our conluence page "Data Platform & Product" "Development Environment & Access - Software installation (onshore)"
  4. tell openssl to trust ca certs apk add ca-certificates && cp *.pem /usr/local/share/ca-certificates/ && update-ca-certificates
  5. follow alpine wiki to install docker

Notes: if you see some trouble like Certificate or Signature error, this maybe related with zscalar hijack, make sure you have trust the two CAs (cert3.pem, intermediate3.pem) from our confluence page. try restart services like service docker restart to enable the trust.

..\qemu\qemu-system-x86_64.exe -m 2G -k none -nic user,ipv6=off,hostfwd=tcp::22022-:22 -boot order=cd -drive file=hd.img,format=raw,index=0,media=disk -cdrom alpine-extended-3.10.0-x86_64.iso
@if errorlevel 1 pause
@nitinmuteja
Copy link

Add the following repo in apk /etc/apk/repositories file to install docker

http://dl-cdn.alpinelinux.org/alpine/latest-stable/community

@nitinmuteja
Copy link

Shell scripts written in windows won't work on qemu alpine image.
Install dos2unix using apk add dos2unix.
Convert files using dos2unix shellscript.sh and then you would be able to execute them. Else would run into unknown issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment