Skip to content

Commit 3bef46a

Browse files
authored
Merge pull request #95 from AerynOS/moss/state-remove-ranges
state-mgmt: Restructure, and document state remove
2 parents 12b8a33 + 22108bc commit 3bef46a

1 file changed

Lines changed: 109 additions & 49 deletions

File tree

Lines changed: 109 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,126 +1,186 @@
11
---
22
title: Manage Moss States and Packages
3-
lastUpdated: 2026-02-20T13:33:00Z
4-
description: Learn how to inspect and switch states, search for software, and keep an AerynOS system up to date with moss.
3+
lastUpdated: 2026-03-12T10:33:00Z
4+
description: Learn how to update, install, remove, and search for packages, and how to inspect, switch and clean up states with moss.
55
---
66

77
Moss keeps track of packaging-related operations that change the state of the /usr directory by creating a new filesystem transaction (fstx) for each associated moss operation, be it package installation, removal, or upgrades.
88

9-
Use the commands below to inspect and manage those states, discover software, and keep your system current.
9+
Use the commands below to manage your installed software packages, and keep your system current.
1010

11-
## Check the current state
1211

13-
1. List the active state to confirm what is running right now.
12+
## Update the system
13+
14+
Keep the entire system current with a sync operation.
1415

1516
```bash
16-
moss state active
17+
sudo moss sync --update
1718
```
1819

19-
2. Review the state history when you need context for a rollback.
20+
`--update` (`-u`) pulls fresh repository metadata before applying upgrades. Moss records the result as a new state, so you can roll back if something goes wrong.
21+
22+
23+
## Search for packages
24+
25+
Use keyword searches to discover software by name or summary.
2026

2127
```bash
22-
moss state list
28+
sudo moss search something
2329
```
2430

25-
Use the state ID (the number after `State #`) when you need to query or activate a specific snapshot.
31+
Add `--installed` (`-i`) if you only want to search software that is already present on the system.
2632

27-
## Activate a different state
2833

29-
Follow these steps to roll back or advance to another state safely.
34+
## Search for installed files
3035

31-
1. Identify the target state ID with `moss state list`.
32-
2. Activate that state.
36+
Look up which package delivered a specific file when you troubleshoot or audit an installation.
3337

3438
```bash
35-
sudo moss state activate 128
39+
sudo moss search-file filename
3640
```
3741

38-
3. Verify the change.
42+
`moss search-file` scans files from installed packages only.
43+
44+
45+
## Install new software packages
46+
47+
1. Refresh repository metadata when needed.
3948

4049
```bash
41-
moss state active
50+
sudo moss repo update
4251
```
4352

44-
Activating a state atomically swaps the currently active state's /usr directory with the new state's /usr directory, using the Linux kernel [`renameat2` syscall](https://www.man7.org/linux/man-pages/man2/rename.2.html).
53+
2. Install one or more packages.
4554

46-
On successful activation of the new state, it is recommended to reboot the system, so that long-running services start with the expected binaries, libraries, and configurations.
55+
```bash
56+
sudo moss install somepackage
57+
```
4758

48-
## Search for packages
59+
Moss creates a new state automatically. Confirm success with `moss state active`.
4960

50-
Use keyword searches to discover software by name or summary.
61+
62+
## Remove software packages
63+
64+
Uninstall packages you no longer need.
5165

5266
```bash
53-
sudo moss search fractional
67+
sudo moss remove somepackage
5468
```
5569

56-
Add `--installed` (`-i`) if you only want to search software that is already present on the system.
70+
Moss snapshots the removal in a new state. Use `moss state list` to find the previous state if you have to recover.
5771

58-
## Search for installed files
5972

60-
Look up which package delivered a specific file when you troubleshoot or audit an installation.
73+
## List currently installed software packages
74+
6175

6276
```bash
63-
sudo moss search-file libEGL.so
77+
moss list installed
6478
```
6579

66-
`moss search-file` scans files from installed packages only.
6780

68-
## Fetch package stones
81+
## Atomic and independent states
6982

70-
Use `moss fetch` to download one or more package `.stone` files by name without installing them on the current system.
83+
In the preceding examples, it was briefly mentioned that moss creates new "states".
84+
85+
When using moss, state management is an important concept. This section details the fundamentals of moss state management.
86+
87+
Moss is based on the concept of atomic updates. Atomic in this context means "independent units". Each time the user instructs moss to change the state of the system, moss creates a new, independent state. Because each state is independent, it allows moss to roll back to an earlier state, and roll forward to a later state.
88+
89+
90+
### Check the current active state
91+
92+
1. List the active state to confirm what is running right now.
7193

7294
```bash
73-
moss fetch howdy-git
95+
moss state active
7496
```
7597

76-
Fetch multiple packages into a custom output directory:
98+
2. Review the state history when you need context for a rollback.
7799

78100
```bash
79-
moss fetch howdy-git fractional --output-dir ~/stones
101+
moss state list
80102
```
81103

82-
`moss fetch` writes downloaded files to the current directory by default. Add `--verbose` when you need more detailed progress output.
83-
If a package cannot be resolved, refresh repository metadata and try again:
104+
Use the state ID (the number after `State #`) when you need to query, activate, or remove a specific state.
84105

85-
## Install software
86106

87-
1. Refresh repository metadata when needed.
107+
### Activate a different state
108+
109+
Follow these steps to roll back or advance to another state safely.
110+
111+
1. Identify the target state ID with `moss state list`.
112+
2. Activate that state.
88113

89114
```bash
90-
sudo moss repo update
115+
sudo moss state activate 128
91116
```
92117

93-
2. Install one or more packages.
118+
3. Verify the change.
94119

95120
```bash
96-
sudo moss install howdy-git
121+
moss state active
97122
```
98123

99-
Moss creates a new state automatically. Confirm success with `moss state active`.
124+
Activating a state atomically swaps the currently active state's /usr directory with the new state's /usr directory, using the Linux kernel [`renameat2` syscall](https://www.man7.org/linux/man-pages/man2/rename.2.html).
100125

101-
## Update the system
126+
On successful activation of the new state, it is recommended to reboot the system, so that long-running services start with the expected binaries, libraries, and configurations.
102127

103-
Keep the entire system current with a sync operation.
128+
129+
### Clean up retained states
130+
131+
Over time, a system managed by moss will accumulate more and more states. Each state takes up space that is equivalent to the difference in packages between one state to another. If two states share a lot of package versions, the storage needed to keep the difference between states will be small.
132+
133+
There are two ways to clean up retained states:
134+
135+
- Prune, which removes all states except the N latest states
136+
- Remove, which is capable of removing individual states and ranges of states.
137+
138+
### Prune states
139+
140+
This will prune state history to keep only the 10 latest states, including the current active state:
104141

105142
```bash
106-
sudo moss sync --update
143+
sudo moss state prune
107144
```
108145

109-
`--update` (`-u`) pulls fresh repository metadata before applying upgrades. Moss records the result as a new state, so you can roll back if something goes wrong.
146+
If you want to keep a different number of states, the `-k` / `--keep` parameter will let you specify the number of states you wish to keep:
147+
148+
```bash
149+
# Keep the five latest states, including the active state
150+
sudo moss state prune --keep 5
151+
# or
152+
sudo moss state prune -k 5
153+
```
110154

111-
## Remove software
155+
### Remove specific states
112156

113-
Uninstall packages you no longer need.
157+
Sometimes, it is useful to be able to remove one or more specific states. This can be accomplished with the `state remove` operation.
114158

115159
```bash
116-
sudo moss remove howdy-git
160+
moss state remove 2 8-12 15 17-21
117161
```
118162

119-
Moss snapshots the removal in a new state. Use `moss state list` to find the previous state if you have to recover.
163+
As you can see, `state remove` enables you to remove both individual states and ranges of states. Ranges are inclusive, meaning the start and end states of the specified range are also removed.
120164

121-
## List currently installed software
122165

166+
## Fetch package .stone files for backup purposes
167+
168+
If you would like to keep an archive of stones, moss supports a fetch operation.
169+
170+
Use `moss fetch` to download one or more package `.stone` files by name without installing them on the current system.
123171

124172
```bash
125-
moss list installed
173+
moss fetch somepackage
174+
```
175+
176+
Fetch multiple packages into a custom output directory:
177+
178+
```bash
179+
moss fetch package1 package2 --output-dir ~/stones
126180
```
181+
182+
`moss fetch` writes downloaded files to the current directory by default. Add `--verbose` when you need more detailed progress output. If a package cannot be resolved, refresh repository metadata and try again.
183+
184+
Note also that moss fetches .stones against currently active repository `stone.index` files.
185+
186+
You can list your currently active repository index with `moss repo list`.

0 commit comments

Comments
 (0)