|
1 | | -# Linux VM |
| 1 | +# Persistent Linux VM |
2 | 2 |
|
3 | | -Your main VM is `slicer-1` in the `slicer` host group. It's a persistent arm64 Linux environment that boots with the daemon and has your Mac home folder shared in via VirtioFS. This is where you do your day-to-day Linux work - running Docker, K3s, coding agents, Go/Rust builds, and anything else you'd do on a Linux workstation. |
| 3 | +Slicer for Mac has two types of VMs. |
4 | 4 |
|
5 | | -SSH is usually not required for normal workflows. Most tasks are faster with the Slicer CLI: |
| 5 | +1. A Persistent Linux VM named `slicer-1` - analogous to WSL2 - your *Linux twin* for macOS. |
| 6 | +2. Additional persistent or ephemeral VMs ["sandboxes"](/mac/sandboxes.md) can be launched into the `sbox` host group. |
| 7 | + |
| 8 | +Unlike most sandboxes that optimise for a narrow use-case, each VM is a full Linux Kernel with support for Docker, K3s, eBPF, coding agents, Go/Rust builds with systemd as the init. |
| 9 | + |
| 10 | +Additionally, you can share your home folder or any other folder directly into the VM via VirtioFS. |
| 11 | + |
| 12 | +A built-in guest agent can be used instead of SSH for faster, more efficient access: |
6 | 13 |
|
7 | 14 | - `slicer vm shell slicer-1` |
8 | 15 | - `slicer vm cp ...` |
9 | 16 | - `slicer vm forward ...` |
10 | 17 |
|
11 | | -Use SSH only when you need direct shell access outside this interface. You can add keys directly in the guest by writing to `~/.ssh/authorized_keys`: |
| 18 | +SSH is pre-installed, and accessible via the VM's IP address, as shown on `slicer vm list`. |
| 19 | + |
| 20 | +You can add your SSH keys to: `~/.ssh/authorized_keys`, or import them directly from GitHub: |
12 | 21 |
|
13 | 22 | ```bash |
| 23 | +slicer vm shell slicer-1 |
| 24 | + |
14 | 25 | curl -sLS https://github.com/alexellis.keys > ~/.ssh/authorized_keys |
15 | 26 | ``` |
16 | 27 |
|
| 28 | +## Architecture diagram |
| 29 | + |
| 30 | +```text |
| 31 | + +----------------------------+ |
| 32 | + | slicer CLI | |
| 33 | + | (vm shell / vm cp / API) | |
| 34 | + +-------------+--------------+ |
| 35 | + | |
| 36 | + v |
| 37 | + +--------------------------------+-----------------------------------+ |
| 38 | + | slicer-mac daemon on macOS | |
| 39 | + | Reads `slicer-mac.yaml` and controls local microVMs | |
| 40 | + +-----------------------+----------------------+---------------------+ |
| 41 | + | | |
| 42 | + | | |
| 43 | + v v |
| 44 | + +-----------------------------+ +----------------------------+ |
| 45 | + | host_group: slicer | | host_group: sbox | |
| 46 | + | Long-lived primary workload | | Disposable / on-demand VMs | |
| 47 | + +--------------+--------------+ +-------------+--------------+ |
| 48 | + | | |
| 49 | + v v |
| 50 | + +-------------+ +----------------+ |
| 51 | + | slicer-1 | | sbox-1 | |
| 52 | + | main VM | | sample sbox VM | |
| 53 | + +-------------+ +----------------+ |
| 54 | +``` |
| 55 | + |
| 56 | +Docker's socket is port-forwarded to your Mac as a Unix socket, so `docker` commands on the Mac talk directly to the VM. K3s exposes port 6443, so `kubectl` on your Mac can target the cluster running inside `slicer-1`. |
| 57 | + |
| 58 | +## The VM lifecycle |
| 59 | + |
| 60 | +It's important to shut down persistent VMs like `slicer-1` gracefully: |
| 61 | + |
| 62 | +```bash |
| 63 | +slicer vm shutdown slicer-1 |
| 64 | +slicer vm exec slicer-1 -- sudo shutdown -h 0 |
| 65 | +``` |
| 66 | + |
| 67 | +If your VM crashes or you kill slicer-mac without letting it shut down the VMs gracefully, you may need to check the disk image, which you can do via the [Troubleshooting](/mac/troubleshooting) page. |
| 68 | + |
| 69 | +If you ever want to "reset" your `slicer-1` VM, you can delete it and then relaunch it. |
| 70 | + |
| 71 | +First shut down slicer-mac. |
| 72 | + |
| 73 | +Then run `rm -rf ~/slicer-mac/slicer-1.img` |
| 74 | + |
| 75 | +Then restart slicer-mac, and you'll get the VM re-created. |
| 76 | + |
17 | 77 | ## Folder sharing |
18 | 78 |
|
| 79 | +Folders can be shared directly into any Slicer VM by specifying paths in the slicer-mac.yaml config file or via an API request. |
| 80 | + |
| 81 | +Most of the time copying folders between the host and guest, will be fast enough and more convenient: `slicer cp -r ./source vm:~/destination`. |
| 82 | + |
19 | 83 | See [Folder sharing](/mac/folder-sharing) for setup details. |
20 | 84 |
|
21 | 85 | ## Forward Docker |
@@ -72,36 +136,6 @@ kubectl get nodes |
72 | 136 |
|
73 | 137 | With K3s running inside Slicer, you can test controllers locally, validate Helm charts with a real install, or try RBAC changes without touching a shared cluster. |
74 | 138 |
|
75 | | -## Architecture diagram |
76 | | - |
77 | | -```text |
78 | | - +----------------------------+ |
79 | | - | slicer CLI | |
80 | | - | (vm shell / vm cp / API) | |
81 | | - +-------------+--------------+ |
82 | | - | |
83 | | - v |
84 | | - +--------------------------------+-----------------------------------+ |
85 | | - | slicer-mac daemon on macOS | |
86 | | - | Reads `slicer-mac.yaml` and controls local microVMs | |
87 | | - +-----------------------+----------------------+---------------------+ |
88 | | - | | |
89 | | - | | |
90 | | - v v |
91 | | - +-----------------------------+ +----------------------------+ |
92 | | - | host_group: slicer | | host_group: sbox | |
93 | | - | Long-lived primary workload | | Disposable / on-demand VMs | |
94 | | - +--------------+--------------+ +-------------+--------------+ |
95 | | - | | |
96 | | - v v |
97 | | - +-------------+ +----------------+ |
98 | | - | slicer-1 | | sbox-1 | |
99 | | - | main VM | | sample sbox VM | |
100 | | - +-------------+ +----------------+ |
101 | | -``` |
102 | | - |
103 | | -Docker's socket is port-forwarded to your Mac as a Unix socket, so `docker` commands on the Mac talk directly to the VM. K3s exposes port 6443, so `kubectl` on your Mac can target the cluster running inside `slicer-1`. |
104 | | - |
105 | 139 | ## Next steps |
106 | 140 |
|
107 | 141 | - [Sandboxes](/mac/sandboxes) - spin up ephemeral VMs for AI agents and automation |
|
0 commit comments