ZIP is stuck with a garbage file

Solution 1:

Suggested solution: Try to zip each directory separately, and for sure, don't try to recursively zip all files under /

Detailed answer:

zip's manpage explain the option you used, e.g. -r means:

-r
--recurse-paths
    Travel the directory structure recursively

When you are running the following command:

zip -ur zipfile.zip / 

zip tries to compress the entire files in the system (from root / and below).

zip uses a temporary file (in your case you called it "garbage file") which holds the data it gather so far. Once the zip operation completed zip moves this temporary file to the resulted zip file.

In your case, you requested zip to compress all files in your system, which includes also the temporary file created by zip.

This might cause endless loop, as zip might try to add the temporary file to itself.

Also, you might try to add devices under /dev folder and similar files which I'm not sure that you would like to zip them.