https://kernel-handbook.alioth.debian.org/ch-common-tasks.html should mention at each step how to clean up later for that step. I.e., how to restore one's disks to the state they were in before downloading, installing, etc. all those packages.