# Get Start with Redox ###### tags: `Rust`, `Redox`, `OS` > 本章為讀[官方網站](https://doc.redox-os.org/book/)後做出的筆記。 > > 並參考日本人的[影片直播](https://www.youtube.com/watch?v=g7UxeDJQbx0&list=PL8U-_gKA4tWtMfc-wSCbUyMuxPnw6SKrV&index=1)與[筆記](https://docs.google.com/document/d/1h0qSy7HjNTr_aEpBbfyxHOvdsKKepRqp1QlcJoGMsMc/edit#), 基本上看到日文就是從那裡擷取來的, 都會加上引用標記 :) ## 在虛擬機上運行 Redox 印象檔 1. 下載印象檔 https://static.redox-os.org/releases/0.8.0/x86_64/ 當中的 `redox_demo_x86_64_*_harddrive.img` 2. 確認 SHA sum ```bash sha256sum $HOME/Downloads/redox_demo_x86_64*_harddrive.img ``` 3. 以 QEMU 運行 > 注意這與官方的指令略有不同, 以下是可以在 M1 MacBook 運作的指令, 不使用 kvm 技術 ```bash SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-x86_64 -d cpu_reset,guest_errors -smp 4 -m 2048 \ -chardev stdio,id=debug,signal=off,mux=on,"" -serial chardev:debug -mon chardev=debug \ -machine q35 -device ich9-intel-hda -device hda-duplex -netdev user,id=net0 \ -device e1000,netdev=net0 -device nec-usb-xhci,id=xhci \ -drive file=`echo ./redox_demo_x86_64*_harddrive.img`,format=raw ``` > 附上官方的版本, 這起用了多種 Redox 的功能 ```bash SDL_VIDEO_X11_DGAMOUSE=0 qemu-system-x86_64 -d cpu_reset,guest_errors -smp 4 -m 2048 \ -chardev stdio,id=debug,signal=off,mux=on,"" -serial chardev:debug -mon chardev=debug \ -machine q35 -device ich9-intel-hda -device hda-duplex -netdev user,id=net0 \ -device e1000,netdev=net0 -device nec-usb-xhci,id=xhci -enable-kvm -cpu host \ -drive file=`echo $HOME/Downloads/redox_demo_x86_64*_harddrive.img`,format=raw ``` ## 在 `M1 macOS` 建置 Redox > ### 我的 macOS 環境 > ![我的 macOS 相關資訊](https://i.imgur.com/Gi4CYWS.png) > > ```zsh > uname -a > Darwin yangziqingdeMacBook-Air.local 21.5.0 Darwin Kernel Version 21.5.0: Tue Apr 26 21:08:29 PDT 2022; root:xnu-8020.121.3~4/RELEASE_ARM64_T8101 arm64 > ``` 大失敗... ## 在 `x86_64 Arch Linux` 建置 Redox > ### 我的 Arch Linux 環境 > > ```zsh > uname -a > Linux archroiko 6.1.8-arch1-1 #1 SMP PREEMPT_DYNAMIC Tue, 24 Jan 2023 21:07:04 +0000 x86_64 GNU/Linux > ``` 由於並非 Debian 系列, [官方](https://doc.redox-os.org/book/ch02-05-building-redox.html#supported-distros-and-podman-build)推薦使用 `Podman` (一個虛擬機管理器) 來生成 containers 並執行虛擬機印象檔。 ### 以 Podman 建置 Redox 先上指令: ```bash= mkdir -p ~/tryredox # create workspace cd ~/tryredox curl -sf https://gitlab.redox-os.org/redox-os/redox/raw/master/podman_bootstrap.sh -o podman_bootstrap.sh # download script time bash -e podman_bootstrap.sh # download packages needed for podman build make all # building process ``` 預設的環境於 Ubuntu 上, 故我們要生成一安裝好 Rust 與相關 package 的 Ubuntu image。 最終以於本機運行的 FUSE 建置成的印象檔將位於 `build/$ARCH/$CONFIG/harddrive.img` 中的 `harddrive.img` 或 `livedisk.iso`。 將 `PODMAN_BUILD` 環境參數設為 1 會使 `make all` 呼叫 Podman 的建置流程。 ## 以 QEMU 運行建置好的 Redox ```zsh make qemu ``` 便會開啟 [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) 伺服器如下... ![make qeum img](https://i.imgur.com/dzRcN4h.png) 我使用 [TigerVNC](https://tigervnc.org/) 連線之, 得 > 下載指令 > ```zsh > sudo pacman -S tigervnc > ``` > > 運行 > ```zsh > vncviewer > ``` ![SelectResolution](https://i.imgur.com/w4t7XF0.png) 便可挑選解析度後登入。 ![Login](https://i.imgur.com/PavFplf.png) 預設帳號: `root`; 密碼: `password`。 也可以關閉 VNC 畫面, 直接使用終端介面。 ![CLI](https://i.imgur.com/Vf3hnYm.png)