Skip to content

Commit

Permalink
[v4.4] system reset: show graphRoot/runRoot before removal
Browse files Browse the repository at this point in the history
Backport of commit 6aaf6a2.

system reset it says it will delete containers, images, networks, etc...
However it will also delete the graphRoot and runRoot directories.
Normally this is not an issue, however in same cases these directories
were set to the users home directory or some other important system
directory.

As first step simply show the directories that are configured and thus
will be deleted by reset. As future step we could implement some
safeguard will will not delete some known important directories however
I tried to keep it simple for now.

[NO NEW TESTS NEEDED]

see containers#18349, containers#18295, and containers#19870

Signed-off-by: Paul Holzinger <[email protected]>
Signed-off-by: Valentin Rothberg <[email protected]>
  • Loading branch information
Luap99 authored and vrothberg committed Sep 6, 2023
1 parent 4213001 commit 49803be
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions cmd/podman/system/reset.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,13 @@ func reset(cmd *cobra.Command, args []string) {
- all machines
- all volumes`)

info, _ := registry.ContainerEngine().Info(registry.Context())
// lets not hard fail in case of an error
if info != nil {
fmt.Printf(" - the graphRoot directory: %q\n", info.Store.GraphRoot)
fmt.Printf(" - the runRoot directory: %q\n", info.Store.RunRoot)
}

if len(listCtn) > 0 {
fmt.Println(`WARNING! The following external containers will be purged:`)
// print first 12 characters of ID and first configured name alias
Expand Down
4 changes: 4 additions & 0 deletions docs/source/markdown/podman-system-reset.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ podman\-system\-reset - Reset storage back to initial state

## DESCRIPTION
**podman system reset** removes all pods, containers, images, networks and volumes, and machines.
It also removes the configured graphRoot and runRoot directories. Make sure these are not set to
some important directory.

This command must be run **before** changing any of the following fields in the
`containers.conf` or `storage.conf` files: `driver`, `static_dir`, `tmp_dir`
Expand Down Expand Up @@ -38,6 +40,8 @@ WARNING! This will remove:
- all build cache
- all machines
- all volumes
- the graphRoot directory: /var/lib/containers/storage
- the runRoot directory: /run/containers/storage
Are you sure you want to continue? [y/N] y
```

Expand Down

0 comments on commit 49803be

Please sign in to comment.